pull/12/head
valoeghese 2020-03-01 12:17:05 +13:00
parent def0540622
commit f42231f1a4
3 changed files with 12 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import com.github.halotroop.litecraft.types.block.Block.Properties;
public final class Blocks
{
public static final Block AIR = new Block(new Properties("air").visible(false));
public static final Block GRASS = new Block(new Properties("block/cubes/soil/grass/grass_top.png").canCaveCarve(true));
public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties("dirt").canCaveCarve(true));
public static final Block ANDESITE = new Block("block/cubes/stone/basic/andesite.png", new Properties("andesite").canCaveCarve(true));
public static final Block DIORITE = new Block("block/cubes/stone/basic/diorite.png", new Properties("diorite").canCaveCarve(true));

View File

@ -22,6 +22,7 @@ public class CavesModifier implements WorldModifier, WorldGenConstants
@Override
public void modifyWorld(BlockAccess world, Random rand, int chunkStartX, int chunkStartY, int chunkStartZ)
{
for (int i = 0; i < 8; ++i) world.setBlock(chunkStartX + i, chunkStartY + i, chunkStartZ + i, Blocks.DIORITE);
final int subChunks = CHUNK_SIZE >> 2; // in 4x4x4 blocks
for (int subChunkX = 0; subChunkX < subChunks; subChunkX++)
@ -37,14 +38,14 @@ public class CavesModifier implements WorldModifier, WorldGenConstants
int scOffsetY = subChunkY << 2; // sub chunk offset y
int scTotalY = scOffsetY + chunkStartY;
// calculate noise at each corner of the cube [lower|upper][south|north][west|east]
double noiseLSW = this.caveNoise.sample(subChunkX, subChunkY, subChunkZ); // base = lower south west
double noiseUSW = this.caveNoise.sample(subChunkX, subChunkY + 1, subChunkZ);
double noiseLNW = this.caveNoise.sample(subChunkX, subChunkY, subChunkZ + 1);
double noiseUNW = this.caveNoise.sample(subChunkX, subChunkY + 1, subChunkZ + 1);
double noiseLSE = this.caveNoise.sample(subChunkX + 1, subChunkY, subChunkZ);
double noiseUSE = this.caveNoise.sample(subChunkX + 1, subChunkY + 1, subChunkZ);
double noiseLNE = this.caveNoise.sample(subChunkX + 1, subChunkY, subChunkZ + 1);
double noiseUNE = this.caveNoise.sample(subChunkX + 1, subChunkY + 1, subChunkZ + 1);
double noiseLSW = this.caveNoise.sample(scTotalX, scTotalY, scTotalZ); // base = lower south west
double noiseUSW = this.caveNoise.sample(scTotalX, scTotalY + 4, scTotalZ);
double noiseLNW = this.caveNoise.sample(scTotalX, scTotalY, scTotalZ + 4);
double noiseUNW = this.caveNoise.sample(scTotalX, scTotalY + 4, scTotalZ + 4);
double noiseLSE = this.caveNoise.sample(scTotalX + 4, scTotalY, scTotalZ);
double noiseUSE = this.caveNoise.sample(scTotalX + 4, scTotalY + 4, scTotalZ);
double noiseLNE = this.caveNoise.sample(scTotalX + 4, scTotalY, scTotalZ + 4);
double noiseUNE = this.caveNoise.sample(scTotalX + 4, scTotalY + 4, scTotalZ + 4);
// calculate y lerp progresses
// lerp = low + progress * (high - low)
double ypSW = 0.25 * (noiseUSW - noiseLSW);

View File

@ -40,6 +40,8 @@ public class EarthChunkGenerator implements ChunkGenerator, WorldGenConstants
block = pickStone(rockNoise);
else if (totalY < height)
block = Blocks.DIRT;
else if (totalY == height)
block = Blocks.GRASS;
chunk.setBlock(x, y, z, block);
}
}