From aa22ca1d560f44b6bae4bf09e346475f1d22f59d Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Wed, 7 Aug 2024 13:02:51 +0200 Subject: [PATCH] Handle pitch/yaw->data item frame rotation change in 1.16.4->1.17 (#4064) See https://github.com/ViaVersion/ViaBackwards/pull/848 --- .../rewriter/EntityPacketRewriter1_17.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/EntityPacketRewriter1_17.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/EntityPacketRewriter1_17.java index a5aa2d3fd..e47f8795c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/EntityPacketRewriter1_17.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/EntityPacketRewriter1_17.java @@ -48,6 +48,30 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter { + final int entityType = wrapper.get(Types.VAR_INT, 1); + if (entityType != EntityTypes1_17.ITEM_FRAME.getId()) { + return; + } + + // Older clients will ignore the data field and the server sets the item frame rotation by the yaw/pitch field inside the packet, + // newer clients do the opposite and ignore yaw/pitch and use the data field from the packet. + final int entityId = wrapper.get(Types.VAR_INT, 0); + + final byte pitch = wrapper.get(Types.BYTE, 0); + final byte yaw = wrapper.get(Types.BYTE, 1); + + final PacketWrapper setDirection = PacketWrapper.create(ClientboundPackets1_17.MOVE_ENTITY_ROT, wrapper.user()); + setDirection.write(Types.VAR_INT, entityId); + setDirection.write(Types.BYTE, yaw); + setDirection.write(Types.BYTE, pitch); + setDirection.write(Types.BOOLEAN, false); // On Ground + + wrapper.send(Protocol1_16_4To1_17.class); + wrapper.cancel(); + setDirection.send(Protocol1_16_4To1_17.class); + }); + protocol.registerClientbound(ClientboundPackets1_16_2.REMOVE_ENTITIES, null, wrapper -> { int[] entityIds = wrapper.read(Types.VAR_INT_ARRAY_PRIMITIVE); wrapper.cancel();