cave carve threshold
parent
eeb514fab0
commit
e3b5b54489
|
@ -11,7 +11,7 @@ public class Block
|
|||
{ // add properties to this builder!
|
||||
private boolean visible = true;
|
||||
private boolean fullCube = true;
|
||||
private boolean canCaveCarve = true;
|
||||
private float caveCarveThreshold = -1f; // cannot carve
|
||||
private final String identifier;
|
||||
|
||||
public Properties(String identifier)
|
||||
|
@ -29,15 +29,16 @@ public class Block
|
|||
return this;
|
||||
}
|
||||
|
||||
public Properties cannotCarveCave()
|
||||
public Properties caveCarveThreshold(float threshold)
|
||||
{
|
||||
this.canCaveCarve = false;
|
||||
this.caveCarveThreshold = threshold;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public final TexturedModel model;
|
||||
private final boolean visible, fullCube, canCaveCarve;
|
||||
private final boolean visible, fullCube;
|
||||
private final float caveCarveThreshold;
|
||||
public final String identifier;
|
||||
|
||||
public boolean isFullCube()
|
||||
|
@ -46,8 +47,8 @@ public class Block
|
|||
public boolean isVisible()
|
||||
{ return this.visible; }
|
||||
|
||||
public boolean canCaveCarve()
|
||||
{ return this.canCaveCarve; }
|
||||
public float getCaveCarveThreshold()
|
||||
{ return this.caveCarveThreshold; }
|
||||
|
||||
protected Block(Properties properties)
|
||||
{ this((TexturedModel) null, properties); }
|
||||
|
@ -61,7 +62,7 @@ public class Block
|
|||
this.visible = properties.visible;
|
||||
this.fullCube = properties.fullCube;
|
||||
this.identifier = properties.identifier;
|
||||
this.canCaveCarve = properties.canCaveCarve;
|
||||
this.caveCarveThreshold = properties.caveCarveThreshold;
|
||||
IDENTIFIER_TO_BLOCK.put(this.identifier, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ 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).fullCube(false).cannotCarveCave());
|
||||
public static final Block GRASS = new Block(new Properties("block/cubes/soil/grass/grass_top.png"));
|
||||
public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties("dirt"));
|
||||
public static final Block ANDESITE = new Block("block/cubes/stone/basic/andesite.png", new Properties("andesite"));
|
||||
public static final Block DIORITE = new Block("block/cubes/stone/basic/diorite.png", new Properties("diorite"));
|
||||
public static final Block GRANITE = new Block("block/cubes/stone/basic/granite.png", new Properties("granite"));
|
||||
public static final Block GNEISS = new Block("block/cubes/stone/basic/gneiss.png", new Properties("gneiss"));
|
||||
public static final Block AIR = new Block(new Properties("air").visible(false).fullCube(false));
|
||||
public static final Block GRASS = new Block(new Properties("block/cubes/soil/grass/grass_top.png").caveCarveThreshold(0.11f));
|
||||
public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties("dirt").caveCarveThreshold(0.12f));
|
||||
public static final Block ANDESITE = new Block("block/cubes/stone/basic/andesite.png", new Properties("andesite").caveCarveThreshold(0.15f));
|
||||
public static final Block DIORITE = new Block("block/cubes/stone/basic/diorite.png", new Properties("diorite").caveCarveThreshold(0.18f));
|
||||
public static final Block GRANITE = new Block("block/cubes/stone/basic/granite.png", new Properties("granite").caveCarveThreshold(0.17f));
|
||||
public static final Block GNEISS = new Block("block/cubes/stone/basic/gneiss.png", new Properties("gneiss").caveCarveThreshold(0.14f));
|
||||
|
||||
public static Block init()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.github.halotroop.litecraft.world.gen;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import com.github.halotroop.litecraft.types.block.Blocks;
|
||||
import com.github.halotroop.litecraft.types.block.*;
|
||||
import com.github.halotroop.litecraft.util.noise.OctaveSimplexNoise;
|
||||
import com.github.halotroop.litecraft.world.BlockAccess;
|
||||
import com.github.halotroop.litecraft.world.gen.modifier.WorldModifier;
|
||||
|
@ -10,7 +10,6 @@ import com.github.halotroop.litecraft.world.gen.modifier.WorldModifier;
|
|||
public class CavesModifier implements WorldModifier, WorldGenConstants
|
||||
{
|
||||
private OctaveSimplexNoise caveNoise;
|
||||
private static final double THRESHOLD = 0.1;
|
||||
//
|
||||
@Override
|
||||
public void initialize(long seed)
|
||||
|
@ -81,14 +80,11 @@ public class CavesModifier implements WorldModifier, WorldGenConstants
|
|||
{
|
||||
int totalX = subX + scTotalX;
|
||||
// calculate whether to replace block with air
|
||||
// if the noise is within the threshold for caves
|
||||
if (-THRESHOLD < lerpNoise && lerpNoise < THRESHOLD)
|
||||
// if the noise is within the threshold for that block for caves
|
||||
float threshold = world.getBlock(totalX, totalY, totalZ).getCaveCarveThreshold();
|
||||
if (-threshold < lerpNoise && lerpNoise < threshold)
|
||||
{
|
||||
// if the cave can carve into the block
|
||||
if (world.getBlock(totalX, totalY, totalZ).canCaveCarve())
|
||||
{
|
||||
world.setBlock(totalX, totalY, totalZ, Blocks.AIR);
|
||||
}
|
||||
world.setBlock(totalX, totalY, totalZ, Blocks.AIR);
|
||||
}
|
||||
// add progress to the noise
|
||||
lerpNoise += lerpProg;
|
||||
|
|
Loading…
Reference in New Issue