Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
SPIGOT-5826: Don't store chunk in block states
Dieser Commit ist enthalten in:
Ursprung
6abb4398b9
Commit
6b20d04c71
@ -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<MetadataValue> 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
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren