From 206368b77764e58e38cd6b6f5518cc0149d78126 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Thu, 10 Jun 2021 22:10:22 +0200 Subject: [PATCH] Fix 1.12->1.13 entity tracking Fixes #2526 --- .../packets/EntityPackets.java | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/EntityPackets.java index 965b4e439..35737bc72 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/EntityPackets.java @@ -53,39 +53,38 @@ public class EntityPackets { int entityId = wrapper.get(Type.VAR_INT, 0); byte type = wrapper.get(Type.BYTE, 0); Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true); + if (entType == null) return; - if (entType != null) { - if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) { - int oldId = wrapper.get(Type.INT, 0); - int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15)); - wrapper.set(Type.INT, 0, WorldPackets.toNewId(combined)); + // Register Type ID + wrapper.user().getEntityTracker(Protocol1_13To1_12_2.class).addEntity(entityId, entType); + + if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) { + int oldId = wrapper.get(Type.INT, 0); + int combined = (((oldId & 4095) << 4) | (oldId >> 12 & 15)); + wrapper.set(Type.INT, 0, WorldPackets.toNewId(combined)); + } + + // Fix ItemFrame hitbox + if (entType.is(Entity1_13Types.EntityType.ITEM_FRAME)) { + int data = wrapper.get(Type.INT, 0); + + switch (data) { + // South + case 0: + data = 3; + break; + // West + case 1: + data = 4; + break; + // North is the same + // East + case 3: + data = 5; + break; } - // Fix ItemFrame hitbox - if (entType.is(Entity1_13Types.EntityType.ITEM_FRAME)) { - int data = wrapper.get(Type.INT, 0); - - switch (data) { - // South - case 0: - data = 3; - break; - // West - case 1: - data = 4; - break; - // North is the same - // East - case 3: - data = 5; - break; - } - - wrapper.set(Type.INT, 0, data); - - // Register Type ID - wrapper.user().getEntityTracker(Protocol1_13To1_12_2.class).addEntity(entityId, entType); - } + wrapper.set(Type.INT, 0, data); } } });