mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-04-23 15:33:58 +00:00
middle click for block in creative + scroll wheel fix
* added the ability to middle click on blocks the player is looking at and get the block in your inventory. * fixed a weird bug with scrolling in the creative inventory.
This commit is contained in:
parent
1945f72a86
commit
08f39feedc
|
|
@ -777,11 +777,11 @@ void UIController::tickInput()
|
|||
}
|
||||
|
||||
|
||||
int wheel = g_KBMInput.GetMouseWheel();
|
||||
if (wheel > 0)
|
||||
handleKeyPress(0, ACTION_MENU_UP);
|
||||
else if (wheel < 0)
|
||||
handleKeyPress(0, ACTION_MENU_DOWN);
|
||||
//int wheel = g_KBMInput.GetMouseWheel();
|
||||
//if (wheel > 0)
|
||||
//handleKeyPress(0, ACTION_MENU_UP);
|
||||
//else if (wheel < 0)
|
||||
//handleKeyPress(0, ACTION_MENU_DOWN);
|
||||
}
|
||||
#endif
|
||||
handleInput();
|
||||
|
|
@ -1049,6 +1049,17 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
|
|||
if (g_KBMInput.IsMouseButtonReleased(KeyboardMouseInput::MOUSE_LEFT)) { released = true; down = false; }
|
||||
if (!pressed && !released && g_KBMInput.IsMouseButtonDown(KeyboardMouseInput::MOUSE_LEFT)) { down = true; }
|
||||
}
|
||||
|
||||
// scroll
|
||||
if (!g_KBMInput.IsMouseGrabbed())
|
||||
{
|
||||
int wheel = g_KBMInput.GetMouseWheel();
|
||||
if ((key == ACTION_MENU_OTHER_STICK_UP && wheel >0) || (key == ACTION_MENU_OTHER_STICK_DOWN && wheel < 0))
|
||||
{
|
||||
pressed = true;
|
||||
down = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3295,6 +3295,67 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64 // allows for the player to get the block they are looking at in creative by middle clicking.
|
||||
if (iPad == 0 && player->abilities.instabuild && g_KBMInput.IsMouseButtonPressed(KeyboardMouseInput::MOUSE_MIDDLE) && hitResult != NULL && hitResult->type == HitResult::TILE)
|
||||
{
|
||||
//printf("MIDDLE CLICK TEST!!");
|
||||
int tileId = level->getTile(hitResult->x, hitResult->y, hitResult->z);
|
||||
Tile *tile = (tileId > 0 && tileId < Tile::TILE_NUM_COUNT) ? Tile::tiles[tileId] : NULL;
|
||||
|
||||
if (tile != NULL)
|
||||
{
|
||||
int cloneId = tile->cloneTileId(level, hitResult->x, hitResult->y, hitResult->z);
|
||||
|
||||
if (cloneId > 0 && cloneId < Item::ITEM_NUM_COUNT && Item::items[cloneId] != NULL)
|
||||
{
|
||||
int cloneData = tile->cloneTileData(level, hitResult->x, hitResult->y, hitResult->z);
|
||||
bool checkData = Item::items[cloneId]->isStackedByData();
|
||||
|
||||
int quickbarSlot = -1;
|
||||
|
||||
for (int slot = 0; slot < Inventory::getSelectionSize(); ++slot)
|
||||
{
|
||||
shared_ptr<ItemInstance> quickbarItem = player->inventory->items[slot];
|
||||
if (quickbarItem == NULL || quickbarItem->id != cloneId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!checkData || quickbarItem->getAuxValue() == cloneData)
|
||||
{
|
||||
quickbarSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (quickbarSlot >= 0)
|
||||
{
|
||||
player->inventory->selected = quickbarSlot;
|
||||
}
|
||||
else
|
||||
{
|
||||
player->inventory->grabTexture(cloneId, cloneData, checkData, true);
|
||||
}
|
||||
|
||||
// should prevent ghost items/blocks
|
||||
shared_ptr<ItemInstance> selctedItem = player->inventory->getSelected();
|
||||
if (gameMode != NULL && selctedItem != NULL)
|
||||
{
|
||||
const int creativeHotbarSlotStart = 36;
|
||||
gameMode->handleCreativeModeItemAdd(selctedItem, creativeHotbarSlotStart + player->inventory->selected);
|
||||
}
|
||||
|
||||
if (gameMode != NULL && gameMode->getTutorial() != NULL)
|
||||
{
|
||||
gameMode->getTutorial()->onSelectedItemChanged(player->inventory->getSelected());
|
||||
}
|
||||
|
||||
player->updateRichPresence();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( gameMode->isInputAllowed(MINECRAFT_ACTION_ACTION) )
|
||||
{
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_ACTION)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue