diff --git a/common/src/main/java/common/world/BlockArray.java b/common/src/main/java/common/world/BlockArray.java index 2308fa1a..e0368b89 100755 --- a/common/src/main/java/common/world/BlockArray.java +++ b/common/src/main/java/common/world/BlockArray.java @@ -8,15 +8,19 @@ import common.init.Blocks; import common.util.NibbleArray; public class BlockArray { - private int yBase; + private final int yBase; + private final State filler; + private int blocks; private int ticked; + private int filled; private char[] data; private NibbleArray blocklight; private NibbleArray skylight; public BlockArray(int y, boolean sky, State filler) { this.yBase = y; + this.filler = filler; this.data = new char[4096]; this.blocklight = new NibbleArray(); if(sky) @@ -47,6 +51,10 @@ public class BlockArray { if(block.getTickRandomly()) ++this.ticked; } + if(ostate == this.filler) + ++this.filled; + if(state == this.filler) + --this.filled; this.data[y << 8 | z << 4 | x] = (char)BlockRegistry.getId(state); } @@ -54,6 +62,10 @@ public class BlockArray { return this.get(x, y, z).getBlock(); } + public boolean hasData() { + return this.filler != null ? (this.filled > 0) : (this.blocks > 0); + } + public boolean isEmpty() { return this.blocks == 0; } @@ -85,15 +97,19 @@ public class BlockArray { public void update() { this.blocks = 0; this.ticked = 0; + this.filled = 0; for(int i = 0; i < 16; ++i) { for(int j = 0; j < 16; ++j) { for(int k = 0; k < 16; ++k) { - Block block = this.getBlock(i, j, k); + State state = this.get(i, j, k); + Block block = state.getBlock(); if(block != Blocks.air) { ++this.blocks; if(block.getTickRandomly()) ++this.ticked; } + if(this.filler != null && state != this.filler) + ++this.filled; } } } diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 8528c206..f2312da8 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -875,14 +875,14 @@ public class Player extends User implements ICrafting, Executor, IPlayer if(extend == null) { for(BlockArray arr : aextendedblockstorage) { - if(arr != null && (!biomes || !arr.isEmpty())) + if(arr != null && (!biomes || arr.hasData())) list.add(arr); } } else { for(int cy : extend) { BlockArray arr = chunk.getArray(cy); - if(arr != null && (!biomes || !arr.isEmpty())) + if(arr != null && (!biomes || arr.hasData())) list.add(arr); } } diff --git a/server/src/main/java/server/world/Region.java b/server/src/main/java/server/world/Region.java index a03fe1b7..910b791b 100755 --- a/server/src/main/java/server/world/Region.java +++ b/server/src/main/java/server/world/Region.java @@ -562,7 +562,7 @@ public class Region { for(int n = 0; n < sects.size(); ++n) { TagObject sect = sects.get(n); int y = sect.getInt("Y"); - BlockArray storage = new BlockArray(y << 4, light, null); + BlockArray storage = new BlockArray(y << 4, light, y < 0 ? world.dimension.getFiller() : null); byte[] blocks = sect.getByteArray("Dat0"); NibbleArray data = new NibbleArray(sect.getByteArray("Dat1")); NibbleArray adddata = sect.hasByteArray("Dat2") ? new NibbleArray(sect.getByteArray("Dat2")) : null;