From eca380a3a41ff8e367c5373892b7658579893171 Mon Sep 17 00:00:00 2001 From: TheMode Date: Tue, 22 Jun 2021 23:14:26 +0200 Subject: [PATCH] use world coord to save block entities --- .../java/net/minestom/server/instance/AnvilLoader.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/AnvilLoader.java b/src/main/java/net/minestom/server/instance/AnvilLoader.java index 31f6a2231..3770e3915 100644 --- a/src/main/java/net/minestom/server/instance/AnvilLoader.java +++ b/src/main/java/net/minestom/server/instance/AnvilLoader.java @@ -152,13 +152,13 @@ public class AnvilLoader implements IChunkLoader { private void loadTileEntities(Chunk loadedChunk, ChunkColumn fileChunk) { for (NBTCompound te : fileChunk.getTileEntities()) { final String tileEntityID = te.getString("id"); - final var x = te.getInt("x"); - final var y = te.getInt("y"); - final var z = te.getInt("z"); if (tileEntityID == null) { LOGGER.warn("Tile entity has failed to load due to invalid namespace"); continue; } + final var x = te.getInt("x"); + final var y = te.getInt("y"); + final var z = te.getInt("z"); if (x == null || y == null || z == null) { LOGGER.warn("Tile entity " + tileEntityID + " has failed to load due to invalid coordinate"); continue; @@ -255,9 +255,9 @@ public class AnvilLoader implements IChunkLoader { if (handler != null) { NBTCompound nbt = Objects.requireNonNullElseGet(block.nbt(), NBTCompound::new); nbt.setString("id", handler.getNamespaceId().asString()); - nbt.setInt("x", x); + nbt.setInt("x", x + Chunk.CHUNK_SIZE_X * chunk.getChunkX()); nbt.setInt("y", y); - nbt.setInt("z", z); + nbt.setInt("z", z + Chunk.CHUNK_SIZE_Z * chunk.getChunkZ()); nbt.setByte("keepPacked", (byte) 0); tileEntities.add(nbt); }