1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Don't send item use when player is already using item (#5567)

This commit is contained in:
oryxel
2025-05-31 16:53:18 +07:00
committed by GitHub
parent 8555fdeb84
commit c80a8a7c41
3 changed files with 12 additions and 0 deletions

View File

@@ -1343,6 +1343,10 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
* Convenience method to reduce amount of duplicate code. Sends ServerboundUseItemPacket.
*/
public void useItem(Hand hand) {
if (playerEntity.getFlag(EntityFlag.USING_ITEM)) {
return;
}
sendDownstreamGamePacket(new ServerboundUseItemPacket(
hand, worldCache.nextPredictionSequence(), playerEntity.getYaw(), playerEntity.getPitch()));
}

View File

@@ -33,6 +33,7 @@ import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerType;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.cloudburstmc.protocol.bedrock.data.inventory.transaction.InventoryActionData;
@@ -446,6 +447,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
break;
case ITEM_RELEASE:
if (packet.getActionType() == 0) {
session.getPlayerEntity().setFlag(EntityFlag.USING_ITEM, false);
session.releaseItem();
session.getBundleCache().markRelease();
}

View File

@@ -29,6 +29,7 @@ import org.cloudburstmc.protocol.bedrock.data.ParticleType;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityEventType;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerId;
import org.cloudburstmc.protocol.bedrock.packet.EntityEventPacket;
import org.cloudburstmc.protocol.bedrock.packet.InventoryContentPacket;
@@ -46,6 +47,7 @@ import org.geysermc.geyser.entity.type.LivingEntity;
import org.geysermc.geyser.entity.type.living.animal.ArmadilloEntity;
import org.geysermc.geyser.entity.type.living.monster.CreakingEntity;
import org.geysermc.geyser.entity.type.living.monster.WardenEntity;
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
@@ -118,6 +120,10 @@ public class JavaEntityEventTranslator extends PacketTranslator<ClientboundEntit
entityEventPacket.setType(EntityEventType.SHAKE_WETNESS);
break;
case PLAYER_FINISH_USING_ITEM:
if (entity instanceof SessionPlayerEntity) {
entity.setFlag(EntityFlag.USING_ITEM, false);
}
entityEventPacket.setType(EntityEventType.USE_ITEM);
break;
case FISHING_HOOK_PULL_PLAYER: