initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
59
java/src/game/worldgen/GeneratorDebug.java
Executable file
59
java/src/game/worldgen/GeneratorDebug.java
Executable file
|
@ -0,0 +1,59 @@
|
|||
package game.worldgen;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.collect.Lists;
|
||||
import game.init.BlockRegistry;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class GeneratorDebug implements ChunkGenerator
|
||||
{
|
||||
private static final List<State> STATES = Lists.<State>newArrayList();
|
||||
private static final int XSTRETCH;
|
||||
private static final int ZSTRETCH;
|
||||
|
||||
static {
|
||||
for(Block block : BlockRegistry.REGISTRY) {
|
||||
STATES.addAll(block.getValidStates());
|
||||
}
|
||||
XSTRETCH = ExtMath.ceilf(ExtMath.sqrtf((float)STATES.size()));
|
||||
ZSTRETCH = ExtMath.ceilf((float)STATES.size() / (float)XSTRETCH);
|
||||
}
|
||||
|
||||
public static State getState(int x, int z) {
|
||||
State state = null;
|
||||
if(x > 0 && z > 0 && x % 2 != 0 && z % 2 != 0) {
|
||||
x = x / 2;
|
||||
z = z / 2;
|
||||
if(x <= XSTRETCH && z <= ZSTRETCH) {
|
||||
int idx = ExtMath.absi(x * XSTRETCH + z);
|
||||
if(idx < STATES.size()) {
|
||||
state = STATES.get(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public int getMaximumHeight() {
|
||||
return 72;
|
||||
}
|
||||
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
|
||||
{
|
||||
for(int bx = 0; bx < 16; ++bx) {
|
||||
for(int bz = 0; bz < 16; ++bz) {
|
||||
int sx = x * 16 + bx;
|
||||
int sz = z * 16 + bz;
|
||||
// primer.set(bx, 60, bz, Blocks.glass.getDefaultState());
|
||||
State state = getState(sx, sz);
|
||||
if(state != null) {
|
||||
primer.set(bx, 1, bz, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue