From 6bbcf7d7842a4c2235e6284dcf54d1221daca7db Mon Sep 17 00:00:00 2001 From: RK_01 <50594595+RaphiMC@users.noreply.github.com> Date: Sat, 13 Jul 2024 11:00:12 +0200 Subject: [PATCH] Fix respawn "keep data" translation (#4015) --- .../v1_15_2to1_16/rewriter/EntityPacketRewriter1_16.java | 8 ++++++-- .../v1_18_2to1_19/rewriter/EntityPacketRewriter1_19.java | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/EntityPacketRewriter1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/EntityPacketRewriter1_16.java index 96ca62b3f..7fc9d6b71 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/EntityPacketRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/EntityPacketRewriter1_16.java @@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16; import com.viaversion.viaversion.api.minecraft.entitydata.EntityData; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.api.type.types.version.Types1_16; @@ -119,10 +120,13 @@ public class EntityPacketRewriter1_16 extends EntityRewriter { wrapper.write(Types.BYTE, (byte) -1); // Previous gamemode, set to none + // <= 1.14.4 didn't keep attributes on respawn and 1.15.x always kept them + final boolean keepAttributes = wrapper.user().getProtocolInfo().serverProtocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_15); + String levelType = wrapper.read(Types.STRING); wrapper.write(Types.BOOLEAN, false); // debug wrapper.write(Types.BOOLEAN, levelType.equals("flat")); - wrapper.write(Types.BOOLEAN, true); // keep all playerdata + wrapper.write(Types.BOOLEAN, keepAttributes); // keep player attributes }); } }); @@ -227,4 +231,4 @@ public class EntityPacketRewriter1_16 extends EntityRewriter