test chunk array perf
This commit is contained in:
parent
20abca12f2
commit
e2ec9f0c84
2 changed files with 9 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
||||||
package client.world;
|
package client.world;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import common.biome.Biome;
|
import common.biome.Biome;
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.init.Blocks;
|
import common.init.Blocks;
|
||||||
|
@ -16,6 +18,7 @@ public class ChunkClient extends Chunk {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearArrays() {
|
private void clearArrays() {
|
||||||
|
Arrays.fill(this.core, null);
|
||||||
this.blocks.clearMap();
|
this.blocks.clearMap();
|
||||||
this.blockList.clear();
|
this.blockList.clear();
|
||||||
this.bottom = Integer.MAX_VALUE;
|
this.bottom = Integer.MAX_VALUE;
|
||||||
|
|
|
@ -29,6 +29,7 @@ public abstract class Chunk {
|
||||||
protected final World world;
|
protected final World world;
|
||||||
protected final State filler;
|
protected final State filler;
|
||||||
protected final Block fillerBlock;
|
protected final Block fillerBlock;
|
||||||
|
protected final BlockArray[] core = new BlockArray[32];
|
||||||
protected final IntHashMap<BlockArray> blocks = new IntHashMap();
|
protected final IntHashMap<BlockArray> blocks = new IntHashMap();
|
||||||
protected final Set<BlockArray> blockList = Sets.newHashSet();
|
protected final Set<BlockArray> blockList = Sets.newHashSet();
|
||||||
protected final byte[] biomes = new byte[256];
|
protected final byte[] biomes = new byte[256];
|
||||||
|
@ -69,12 +70,15 @@ public abstract class Chunk {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockArray getArray(int y) {
|
public BlockArray getArray(int y) {
|
||||||
return this.blocks.lookup(y);
|
return y >= -16 && y < 16 ? this.core[y + 16] : this.blocks.lookup(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setArray(BlockArray array) {
|
protected void setArray(BlockArray array) {
|
||||||
int y = array.getY() >> 4;
|
int y = array.getY() >> 4;
|
||||||
this.blocks.addKey(y, array);
|
if(y >= -16 && y < 16)
|
||||||
|
this.core[y + 16] = array;
|
||||||
|
else
|
||||||
|
this.blocks.addKey(y, array);
|
||||||
this.blockList.add(array);
|
this.blockList.add(array);
|
||||||
y <<= 4;
|
y <<= 4;
|
||||||
this.bottom = y < this.bottom ? y : this.bottom;
|
this.bottom = y < this.bottom ? y : this.bottom;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue