From 6b20d04c7145f4c6c93bd8636ed8523d0fee3bd9 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 26 Jun 2020 09:34:25 +1000 Subject: [PATCH] SPIGOT-5826: Don't store chunk in block states --- .../bukkit/craftbukkit/block/CraftBlockState.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index d3017db1bd..11aa2dc18c 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -23,7 +23,6 @@ import org.bukkit.plugin.Plugin; public class CraftBlockState implements BlockState { protected final CraftWorld world; - private final CraftChunk chunk; private final BlockPosition position; protected IBlockData data; protected int flag; @@ -32,7 +31,6 @@ public class CraftBlockState implements BlockState { this.world = (CraftWorld) block.getWorld(); this.position = ((CraftBlock) block).getPosition(); this.data = ((CraftBlock) block).getNMS(); - this.chunk = (CraftChunk) block.getChunk(); this.flag = 3; } @@ -44,7 +42,6 @@ public class CraftBlockState implements BlockState { public CraftBlockState(Material material) { world = null; data = CraftMagicNumbers.getBlock(material).getBlockData(); - chunk = null; position = BlockPosition.ZERO; } @@ -80,7 +77,7 @@ public class CraftBlockState implements BlockState { @Override public Chunk getChunk() { requirePlaced(); - return chunk; + return world.getChunkAt(getX() >> 4, getZ() >> 4); } public void setData(IBlockData data) { @@ -263,25 +260,25 @@ public class CraftBlockState implements BlockState { @Override public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { requirePlaced(); - chunk.getCraftWorld().getBlockMetadata().setMetadata(getBlock(), metadataKey, newMetadataValue); + world.getBlockMetadata().setMetadata(getBlock(), metadataKey, newMetadataValue); } @Override public List getMetadata(String metadataKey) { requirePlaced(); - return chunk.getCraftWorld().getBlockMetadata().getMetadata(getBlock(), metadataKey); + return world.getBlockMetadata().getMetadata(getBlock(), metadataKey); } @Override public boolean hasMetadata(String metadataKey) { requirePlaced(); - return chunk.getCraftWorld().getBlockMetadata().hasMetadata(getBlock(), metadataKey); + return world.getBlockMetadata().hasMetadata(getBlock(), metadataKey); } @Override public void removeMetadata(String metadataKey, Plugin owningPlugin) { requirePlaced(); - chunk.getCraftWorld().getBlockMetadata().removeMetadata(getBlock(), metadataKey, owningPlugin); + world.getBlockMetadata().removeMetadata(getBlock(), metadataKey, owningPlugin); } @Override