fix: Armor swapping executed even when interacting with a block (#168)
Sync branches with main / sync (push) Waiting to run
Nightly Release / build (push) Canceled after 0s
Nightly Release / release (push) Canceled after 0s
Nightly Release / cleanup (push) Canceled after 0s

(This PR fixes [this issue](https://discord.com/channels/1482443865754701868/1534141325904183336) from the Discord server: )

Previously, when holding a piece of armor and right-clicking an interactable block (furnance, crafting table, levers, etc.) the armor would be equipped to the player.
This isn't the expected behavior. The interacted block should suppress any held item functionality (if not crouched)

This PR adds the "bool blockHandled" variable to the "handleUseItem" function. If the player interact with an interactable block, the variable is set to true.
This variable can be used for future packets added in this function

Reviewed-on: https://git.neolegacy.dev/neoStudiosLCE/neoLegacy/pulls/168
Co-authored-by: ACL <puffymono@gmail.com>
Co-committed-by: ACL <puffymono@gmail.com>
This commit is contained in:
ACL
2026-08-08 16:58:45 +01:00
committed by Fireblade
parent a809e71d58
commit c85b2a8740
2 changed files with 5 additions and 3 deletions
+4 -3
View File
@@ -690,6 +690,7 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
ServerLevel *level = server->getLevel(player->dimension);
shared_ptr<ItemInstance> item = player->inventory->getSelected();
bool informClient = false;
bool blockHandled = false;
int x = packet->getX();
int y = packet->getY();
int z = packet->getZ();
@@ -776,8 +777,7 @@ void PlayerConnection::handleUseItem(shared_ptr<UseItemPacket> packet)
int savedItemId = item ? item->id : 0;
int savedItemCount = item ? item->count : 0;
#endif
player->gameMode->useItemOn(player, level, item, x, y, z, face, packet->getClickX(), packet->getClickY(), packet->getClickZ());
player->gameMode->useItemOn(player, level, item, x, y, z, face, packet->getClickX(), packet->getClickY(), packet->getClickZ(), false, &blockHandled);
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
if (validFace)
@@ -897,7 +897,8 @@ skipUseItemOn:
}
//Migrate QuickEquip packet here instead
if (item != nullptr && (item->getItem()->getBaseItemType() == Item::eBaseItemType_helmet
if (item != nullptr && !blockHandled
&& (item->getItem()->getBaseItemType() == Item::eBaseItemType_helmet
|| item->getItem()->getBaseItemType() == Item::eBaseItemType_chestplate
|| item->getItem()->getBaseItemType() == Item::eBaseItemType_leggings
|| item->getItem()->getBaseItemType() == Item::eBaseItemType_boots)) {