From dd22c73eb46317f7450d117b6ac6a42cd7099bd3 Mon Sep 17 00:00:00 2001 From: Kaooot <37877491+Kaooot@users.noreply.github.com> Date: Wed, 14 Aug 2024 21:44:46 +0200 Subject: [PATCH] Add missing client interact prediction to InventoryTransactionPacket --- .../protocol/bedrock/codec/v712/BedrockCodecHelper_v712.java | 2 ++ .../protocol/bedrock/packet/InventoryTransactionPacket.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/BedrockCodecHelper_v712.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/BedrockCodecHelper_v712.java index d81c15e12..1e1f79e43 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/BedrockCodecHelper_v712.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v712/BedrockCodecHelper_v712.java @@ -133,6 +133,7 @@ public void writeItemUse(ByteBuf buffer, InventoryTransactionPacket packet) { this.writeVector3f(buffer, packet.getPlayerPosition()); this.writeVector3f(buffer, packet.getClickPosition()); VarInts.writeUnsignedInt(buffer, packet.getBlockDefinition().getRuntimeId()); + VarInts.writeUnsignedInt(buffer, packet.getClientInteractPrediction().ordinal()); } @Override @@ -146,6 +147,7 @@ public void readItemUse(ByteBuf buffer, InventoryTransactionPacket packet) { packet.setPlayerPosition(this.readVector3f(buffer)); packet.setClickPosition(this.readVector3f(buffer)); packet.setBlockDefinition(this.blockDefinitions.getDefinition(VarInts.readUnsignedInt(buffer))); + packet.setClientInteractPrediction(ItemUseTransaction.PredictedResult.values()[VarInts.readUnsignedInt(buffer)]); } protected void writeFullContainerName(ByteBuf buffer, FullContainerName containerName) { diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventoryTransactionPacket.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventoryTransactionPacket.java index 5b32f6ae0..7b35139a9 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventoryTransactionPacket.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/packet/InventoryTransactionPacket.java @@ -52,6 +52,11 @@ public class InventoryTransactionPacket implements BedrockPacket { */ private ItemUseTransaction.TriggerType triggerType; + /** + * @since v712 + */ + private ItemUseTransaction.PredictedResult clientInteractPrediction; + @Override public final PacketSignal handle(BedrockPacketHandler handler) { return handler.handle(this);