tcr/java/src/game/worldgen/ChunkPrimer.java
2025-03-12 18:13:11 +01:00

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);
}
}