Finish slope palette implementation

This commit is contained in:
dfsek
2020-11-11 01:00:34 -07:00
parent d75cd81408
commit 48e45dfe23
6 changed files with 44 additions and 11 deletions

Binary file not shown.

View File

@@ -39,6 +39,10 @@ public class BiomeConfig extends TerraConfig {
private final List<StructureConfig> structures;
private final ConfigPack config;
private final Palette<BlockData> slant;
private final double ySlantOffsetTop;
private final double ySlantOffsetBottom;
private final double xzSlantOffset;
private String eq;
public BiomeConfig(File file, ConfigPack config) throws InvalidConfigurationException, IOException {
@@ -123,13 +127,16 @@ public class BiomeConfig extends TerraConfig {
Debug.info("Using super snow");
} else snow = new BiomeSnowConfig(this);
// Get slant palette
if(contains("slant-palette")) {
String slantS = getString("slant-palette");
// Get slant stuff
if(contains("slant")) {
String slantS = getString("slant.palette");
slant = config.getPalette(slantS).getPalette();
Debug.info("Using slant palette: " + slantS);
if(slant == null) throw new NotFoundException("Slant Palette", slantS, getID());
} else slant = null;
ySlantOffsetTop = getDouble("slant.y-offset.top", 0.25);
ySlantOffsetBottom = getDouble("slant.y-offset.bottom", 0.25);
xzSlantOffset = getDouble("slant.x-z-offset", 1);
//Make sure equation is non-null
if(eq == null || eq.equals(""))
@@ -190,6 +197,18 @@ public class BiomeConfig extends TerraConfig {
return slant;
}
public double getYSlantOffsetTop() {
return ySlantOffsetTop;
}
public double getYSlantOffsetBottom() {
return ySlantOffsetBottom;
}
public double getXZSlantOffset() {
return xzSlantOffset;
}
@Override
public String toString() {
return "Biome with ID " + getID() + " and noise equation " + eq;

View File

@@ -83,13 +83,16 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
private static Palette<BlockData> getPalette(int x, int y, int z, BiomeConfig c, ChunkInterpolator interpolator) {
Palette<BlockData> slant = c.getSlant();
if(slant != null) {
boolean north = interpolator.getNoise(x, y, z + 1) > 0;
boolean south = interpolator.getNoise(x, y, z - 1) > 0;
boolean east = interpolator.getNoise(x + 1, y, z) > 0;
boolean west = interpolator.getNoise(x - 1, y, z) > 0;
double xzOffset = c.getXZSlantOffset();
boolean north = interpolator.getNoise(x, y, z + xzOffset) > 0;
boolean south = interpolator.getNoise(x, y, z - xzOffset) > 0;
boolean east = interpolator.getNoise(x + xzOffset, y, z) > 0;
boolean west = interpolator.getNoise(x - xzOffset, y, z) > 0;
boolean top = interpolator.getNoise(x, y + 0.25, z) > 0;
boolean bottom = interpolator.getNoise(x, y - 0.25, z) > 0;
double ySlantOffsetTop = c.getYSlantOffsetTop();
double ySlantOffsetBottom = c.getYSlantOffsetBottom();
boolean top = interpolator.getNoise(x, y + ySlantOffsetTop, z) > 0;
boolean bottom = interpolator.getNoise(x, y - ySlantOffsetBottom, z) > 0;
if((top && bottom) && (north || south || east || west) && (!(north && south && east && west))) return slant;
}

View File

@@ -7,6 +7,7 @@ import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.polydev.gaea.biome.Generator;
import org.polydev.gaea.math.FastNoiseLite;
import org.polydev.gaea.math.Interpolator;
import org.polydev.gaea.world.palette.Palette;
import parsii.eval.Expression;
import parsii.eval.Parser;
@@ -106,4 +107,9 @@ public class UserDefinedGenerator extends Generator {
public boolean useMinimalInterpolation() {
return preventSmooth;
}
@Override
public Interpolator.Type getInterpolationType() {
return Interpolator.Type.LINEAR;
}
}

View File

@@ -14,7 +14,12 @@ vanilla: SAVANNA
erodible: false
prevent-smooth: true
slant-palette: STONE
slant:
palette: STONE
y-offset:
top: 1
bottom: 0.25
x-z-offset: 1
flora:
chance: 40

View File

@@ -1,5 +1,5 @@
layers:
- materials:
- "minecraft:diamond_block": 1
- "minecraft:stone": 1
layers: 1
id: "STONE"