Fix 1.18 spawner entity

This commit is contained in:
Nassim Jahnke 2021-11-10 17:31:52 +01:00
parent a49c395486
commit 3a87eb463a
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -53,7 +53,10 @@ public final class WorldPackets {
map(Type.POSITION1_14); map(Type.POSITION1_14);
handler(wrapper -> { handler(wrapper -> {
final short id = wrapper.read(Type.UNSIGNED_BYTE); 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); Via.getPlatform().getLogger().warning("Unknown block entity: " + id);
} }
handleSpawners(typeId, tag);
final byte packedXZ = (byte) ((xTag.asInt() & 15) << 4 | (zTag.asInt() & 15)); final byte packedXZ = (byte) ((xTag.asInt() & 15) << 4 | (zTag.asInt() & 15));
blockEntities.add(new BlockEntityImpl(packedXZ, yTag.asShort(), typeId, tag)); 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);
}
}
}
} }