24 lines
626 B
Java
Executable file
24 lines
626 B
Java
Executable file
package game.worldgen;
|
|
|
|
import game.init.BlockRegistry;
|
|
import game.init.Blocks;
|
|
import game.world.State;
|
|
|
|
public class ChunkPrimer {
|
|
public final int height;
|
|
private final short[] data;
|
|
|
|
public ChunkPrimer(int height) {
|
|
this.data = new short[Math.max(height, 256) * 256];
|
|
this.height = height;
|
|
}
|
|
|
|
public State get(int x, int y, int z) {
|
|
State state = BlockRegistry.STATEMAP.getByValue(this.data[x << 4 | z | y << 8]);
|
|
return state != null ? state : Blocks.air.getState();
|
|
}
|
|
|
|
public void set(int x, int y, int z, State state) {
|
|
this.data[x << 4 | z | y << 8] = (short)BlockRegistry.STATEMAP.get(state);
|
|
}
|
|
}
|