diff --git a/Minecraft.Client/Common/App_enums.h b/Minecraft.Client/Common/App_enums.h index 15a179787..bcfb5f2e4 100644 --- a/Minecraft.Client/Common/App_enums.h +++ b/Minecraft.Client/Common/App_enums.h @@ -862,6 +862,7 @@ enum EControllerActions MINECRAFT_ACTION_INVENTORY, MINECRAFT_ACTION_PAUSEMENU, MINECRAFT_ACTION_DROP, + MINECRAFT_ACTION_PICK_ITEM, MINECRAFT_ACTION_SNEAK_TOGGLE, MINECRAFT_ACTION_CRAFTING, MINECRAFT_ACTION_RENDER_THIRD_PERSON, diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index f41dbf566..a3c9fe2f0 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -1479,83 +1479,9 @@ void Minecraft::run_middle() if(g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_RIGHT)) localplayers[i]->ullButtonsPressed|=1LL<type == HitResult::TILE) + if (g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_MIDDLE)) { - auto inventory = localplayers[i]->inventory; - auto inventoryMenu = localplayers[i]->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, - localplayers[i] - ); - } - // 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 clicked = inventoryMenu->clicked( - itemSlot, - currentHotbarSlot, - AbstractContainerMenu::CLICK_SWAP, - localplayers[i] - ); - - localplayers[i]->connection->send(make_shared( - containerId, - itemSlot, - currentHotbarSlot, - AbstractContainerMenu::CLICK_SWAP, - clicked, - changeUid - )); - } - } - else if (isInCreative) - { - localplayers[i]->inventory->grabTexture(clonedTileId, clonedTileData, true, true); - - shared_ptr selectedItem = localplayers[i]->inventory->getSelected(); - if (gameMode && selectedItem) - { - // Hotbar starts at slot 36 - // Sync new item instance with the server in creative mode - gameMode->handleCreativeModeItemAdd(selectedItem, 36 + localplayers[i]->inventory->selected); - } - } - } + localplayers[i]->ullButtonsPressed|=1LL<ullButtonsPressed&(1LL<GetCount() <= 1) ) ui.SetSelectedItem( iPad, itemName ); } + + if (player->ullButtonsPressed&(1LL<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 clicked = inventoryMenu->clicked( + itemSlot, + currentHotbarSlot, + AbstractContainerMenu::CLICK_SWAP, + player + ); + + player->connection->send(make_shared( + containerId, + itemSlot, + currentHotbarSlot, + AbstractContainerMenu::CLICK_SWAP, + clicked, + changeUid + )); + } + } + else if (isInCreative) + { + inventory->grabTexture(clonedTileId, clonedTileData, true, true); + + shared_ptr 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 {