diff --git a/src/main/java/net/minestom/server/instance/Chunk.java b/src/main/java/net/minestom/server/instance/Chunk.java index 591f7ae85..1edbf629a 100644 --- a/src/main/java/net/minestom/server/instance/Chunk.java +++ b/src/main/java/net/minestom/server/instance/Chunk.java @@ -84,6 +84,17 @@ public class Chunk implements Viewable { setBlock(x, y, z, visualBlockId, customBlock.getCustomBlockId(), data, updateConsumer); } + public void UNSAFE_removeCustomBlock(int x, int y, int z) { + this.customBlocksId[getBlockIndex(x, y, z)] = 0; // Set to none + int index = SerializerUtils.coordToChunkIndex(x, y, z); + this.blocksData.remove(index); + + this.updatableBlocks.remove(index); + this.updatableBlocksLastUpdate.remove(index); + + this.blockEntities.remove(index); + } + private void setBlock(int x, int y, int z, short blockId, short customId, Data data, UpdateConsumer updateConsumer) { int index = SerializerUtils.coordToChunkIndex(x, y, z); if (blockId != 0 diff --git a/src/main/java/net/minestom/server/instance/InstanceContainer.java b/src/main/java/net/minestom/server/instance/InstanceContainer.java index 0698ede38..3a31fd7e3 100644 --- a/src/main/java/net/minestom/server/instance/InstanceContainer.java +++ b/src/main/java/net/minestom/server/instance/InstanceContainer.java @@ -119,7 +119,7 @@ public class InstanceContainer extends Instance { if (previousBlock != null) { Data previousData = chunk.getData(index); previousBlock.onDestroy(this, blockPosition, previousData); - chunk.UNSAFE_setCustomBlock(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), Block.AIR.getBlockId(), (short) 0, null); + chunk.UNSAFE_removeCustomBlock(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ()); } }