From 3a87eb463aced57db852dd24125574e90dcd21ec Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 10 Nov 2021 17:31:52 +0100 Subject: [PATCH] Fix 1.18 spawner entity --- .../packets/WorldPackets.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java index 54b27ccc2..6a9c7f872 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_18to1_17_1/packets/WorldPackets.java @@ -53,7 +53,10 @@ public final class WorldPackets { map(Type.POSITION1_14); handler(wrapper -> { final short id = wrapper.read(Type.UNSIGNED_BYTE); - wrapper.write(Type.VAR_INT, BlockEntityIds.newId(id)); + final int newId = BlockEntityIds.newId(id); + wrapper.write(Type.VAR_INT, newId); + + handleSpawners(newId, wrapper.passthrough(Type.NBT)); }); } }); @@ -120,6 +123,8 @@ public final class WorldPackets { Via.getPlatform().getLogger().warning("Unknown block entity: " + id); } + handleSpawners(typeId, tag); + final byte packedXZ = (byte) ((xTag.asInt() & 15) << 4 | (zTag.asInt() & 15)); blockEntities.add(new BlockEntityImpl(packedXZ, yTag.asShort(), typeId, tag)); } @@ -208,4 +213,15 @@ public final class WorldPackets { } }); } + + private static void handleSpawners(int typeId, final CompoundTag tag) { + if (typeId == 8) { + final CompoundTag entity = tag.get("SpawnData"); + if (entity != null) { + final CompoundTag spawnData = new CompoundTag(); + tag.put("SpawnData", spawnData); + spawnData.put("entity", entity); + } + } + } }