This commit is contained in:
Alezito2008 2026-05-04 22:33:03 -04:00 committed by GitHub
commit b2b30d8a9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 103 additions and 2 deletions

View file

@ -1459,6 +1459,7 @@ void Minecraft::run_middle()
if(InputManager.ButtonPressed(i, ACTION_MENU_GTC_PAUSE)) localplayers[i]->ullButtonsPressed|=1LL<<ACTION_MENU_GTC_PAUSE;
#endif
if(InputManager.ButtonPressed(i, MINECRAFT_ACTION_DROP)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_DROP;
if(InputManager.ButtonPressed(i, MINECRAFT_ACTION_PICK_ITEM)) localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_PICK_ITEM;
// 4J-PB - If we're flying, the sneak needs to be held on to go down
if(localplayers[i]->abilities.flying)
@ -1484,6 +1485,11 @@ void Minecraft::run_middle()
if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT))
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_USE;
if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_MIDDLE))
{
localplayers[i]->ullButtonsPressed|=1LL<<MINECRAFT_ACTION_PICK_ITEM;
}
bool isClosableByEitherKey = ui.IsSceneInStack(i, eUIScene_FurnaceMenu) ||
ui.IsSceneInStack(i, eUIScene_ContainerMenu) ||
ui.IsSceneInStack(i, eUIScene_DispenserMenu) ||
@ -3853,6 +3859,85 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
}
if( !(player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_DROP)) || (selectedItem != nullptr && selectedItem->GetCount() <= 1) ) ui.SetSelectedItem( iPad, itemName );
}
if (player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_PICK_ITEM) && hitResult && hitResult->type == HitResult::TILE)
{
auto inventory = player->inventory;
auto inventoryMenu = player->inventoryMenu;
bool isInCreative = gameMode->hasInfiniteItems();
int x = hitResult->x, y = hitResult->y, z = hitResult->z;
int containerId = inventoryMenu->containerId;
int tileId = level->getTile(x, y, z);
if (tileId > 0 && tileId < Tile::TILE_NUM_COUNT)
{
Tile *tile = Tile::tiles[tileId];
int clonedTileId = tile->cloneTileId(level, x, y, z);
int clonedTileData = tile->cloneTileData(level, x, y, z);
int itemSlot = inventory->getSlot(clonedTileId, clonedTileData);
int firstEmpty = inventory->getFreeSlot();
if (itemSlot >= 0)
{
// Item is already in hotbar
if (itemSlot < 9)
{
inventory->selected = itemSlot;
}
// There are free slots in the hotbar
else if (firstEmpty >= 0 && firstEmpty < 9)
{
inventory->selected = firstEmpty;
// Use quick move the item
gameMode->handleInventoryMouseClick(
containerId,
itemSlot,
AbstractContainerMenu::CLICK_QUICK_MOVE,
true,
player
);
}
// Swap with item in inventory
else {
int currentHotbarSlot = inventory->selected;
short changeUid = inventoryMenu->backup(inventory);
// Perform client side swap and sync with server using CLICK_SWAP to avoid ghost blocks
shared_ptr<ItemInstance> clicked = inventoryMenu->clicked(
itemSlot,
currentHotbarSlot,
AbstractContainerMenu::CLICK_SWAP,
player
);
player->connection->send(make_shared<ContainerClickPacket>(
containerId,
itemSlot,
currentHotbarSlot,
AbstractContainerMenu::CLICK_SWAP,
clicked,
changeUid
));
}
}
else if (isInCreative)
{
inventory->grabTexture(clonedTileId, clonedTileData, true, true);
shared_ptr<ItemInstance> selectedItem = inventory->getSelected();
if (gameMode && selectedItem)
{
// Hotbar starts at slot 36
// Sync new item instance with the server in creative mode
gameMode->handleCreativeModeItemAdd(selectedItem, 36 + player->inventory->selected);
}
}
}
}
}
else
{