initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
24
java/src/game/worldgen/ChunkPrimer.java
Executable file
24
java/src/game/worldgen/ChunkPrimer.java
Executable file
|
@ -0,0 +1,24 @@
|
|||
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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue