From 9c3255d5a4fc6029736ed19986caeddbe4f29b55 Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Wed, 14 Aug 2024 09:38:27 +0200 Subject: [PATCH] Only play totem animation for dying player in 1.11->1.10 (#860) --- .../api/rewriters/LegacyEntityRewriter.java | 5 ++++- .../v1_11to1_10/rewriter/EntityPacketRewriter1_11.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java index 6daa984a..4dc41852 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java @@ -83,7 +83,10 @@ public abstract class LegacyEntityRewriter { ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); clientChunks.setEnvironment(wrapper.get(Types.INT, 1)); - addTrackedEntity(wrapper, wrapper.get(Types.INT, 0), playerType); + + final int entityId = wrapper.get(Types.INT, 0); + addTrackedEntity(wrapper, entityId, playerType); + tracker(wrapper.user()).setClientEntityId(entityId); }); } }); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/rewriter/EntityPacketRewriter1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/rewriter/EntityPacketRewriter1_11.java index 0a561756..b0b57881 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/rewriter/EntityPacketRewriter1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_11to1_10/rewriter/EntityPacketRewriter1_11.java @@ -159,9 +159,15 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter { - byte b = wrapper.get(Types.BYTE, 0); + final int entityId = wrapper.get(Types.INT, 0); + if (entityId != tracker(wrapper.user()).clientEntityId()) { + // Entity events are sent for all players, but we only want to apply this for the self player + return; + } - if (b == 35) { + final byte entityStatus = wrapper.get(Types.BYTE, 0); + if (entityStatus == 35) { + // TODO spawn particles? wrapper.clearPacket(); wrapper.setPacketType(ClientboundPackets1_9_3.GAME_EVENT); wrapper.write(Types.UNSIGNED_BYTE, (short) 10); // Play Elder Guardian animation