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.
@@ -39,6 +39,10 @@ public class BiomeConfig extends TerraConfig {
private final List<StructureConfig> structures; private final List<StructureConfig> structures;
private final ConfigPack config; private final ConfigPack config;
private final Palette<BlockData> slant; private final Palette<BlockData> slant;
private final double ySlantOffsetTop;
private final double ySlantOffsetBottom;
private final double xzSlantOffset;
private String eq; private String eq;
public BiomeConfig(File file, ConfigPack config) throws InvalidConfigurationException, IOException { public BiomeConfig(File file, ConfigPack config) throws InvalidConfigurationException, IOException {
@@ -123,13 +127,16 @@ public class BiomeConfig extends TerraConfig {
Debug.info("Using super snow"); Debug.info("Using super snow");
} else snow = new BiomeSnowConfig(this); } else snow = new BiomeSnowConfig(this);
// Get slant palette // Get slant stuff
if(contains("slant-palette")) { if(contains("slant")) {
String slantS = getString("slant-palette"); String slantS = getString("slant.palette");
slant = config.getPalette(slantS).getPalette(); slant = config.getPalette(slantS).getPalette();
Debug.info("Using slant palette: " + slantS); Debug.info("Using slant palette: " + slantS);
if(slant == null) throw new NotFoundException("Slant Palette", slantS, getID()); if(slant == null) throw new NotFoundException("Slant Palette", slantS, getID());
} else slant = null; } 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 //Make sure equation is non-null
if(eq == null || eq.equals("")) if(eq == null || eq.equals(""))
@@ -190,6 +197,18 @@ public class BiomeConfig extends TerraConfig {
return slant; return slant;
} }
public double getYSlantOffsetTop() {
return ySlantOffsetTop;
}
public double getYSlantOffsetBottom() {
return ySlantOffsetBottom;
}
public double getXZSlantOffset() {
return xzSlantOffset;
}
@Override @Override
public String toString() { public String toString() {
return "Biome with ID " + getID() + " and noise equation " + eq; return "Biome with ID " + getID() + " and noise equation " + eq;
@@ -83,13 +83,16 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
private static Palette<BlockData> getPalette(int x, int y, int z, BiomeConfig c, ChunkInterpolator interpolator) { private static Palette<BlockData> getPalette(int x, int y, int z, BiomeConfig c, ChunkInterpolator interpolator) {
Palette<BlockData> slant = c.getSlant(); Palette<BlockData> slant = c.getSlant();
if(slant != null) { if(slant != null) {
boolean north = interpolator.getNoise(x, y, z + 1) > 0; double xzOffset = c.getXZSlantOffset();
boolean south = interpolator.getNoise(x, y, z - 1) > 0; boolean north = interpolator.getNoise(x, y, z + xzOffset) > 0;
boolean east = interpolator.getNoise(x + 1, y, z) > 0; boolean south = interpolator.getNoise(x, y, z - xzOffset) > 0;
boolean west = interpolator.getNoise(x - 1, y, z) > 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; double ySlantOffsetTop = c.getYSlantOffsetTop();
boolean bottom = interpolator.getNoise(x, y - 0.25, z) > 0; 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; if((top && bottom) && (north || south || east || west) && (!(north && south && east && west))) return slant;
} }
@@ -7,6 +7,7 @@ import org.bukkit.World;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.polydev.gaea.biome.Generator; import org.polydev.gaea.biome.Generator;
import org.polydev.gaea.math.FastNoiseLite; import org.polydev.gaea.math.FastNoiseLite;
import org.polydev.gaea.math.Interpolator;
import org.polydev.gaea.world.palette.Palette; import org.polydev.gaea.world.palette.Palette;
import parsii.eval.Expression; import parsii.eval.Expression;
import parsii.eval.Parser; import parsii.eval.Parser;
@@ -106,4 +107,9 @@ public class UserDefinedGenerator extends Generator {
public boolean useMinimalInterpolation() { public boolean useMinimalInterpolation() {
return preventSmooth; return preventSmooth;
} }
@Override
public Interpolator.Type getInterpolationType() {
return Interpolator.Type.LINEAR;
}
} }
@@ -14,7 +14,12 @@ vanilla: SAVANNA
erodible: false erodible: false
prevent-smooth: true prevent-smooth: true
slant-palette: STONE slant:
palette: STONE
y-offset:
top: 1
bottom: 0.25
x-z-offset: 1
flora: flora:
chance: 40 chance: 40
@@ -1,5 +1,5 @@
layers: layers:
- materials: - materials:
- "minecraft:diamond_block": 1 - "minecraft:stone": 1
layers: 1 layers: 1
id: "STONE" id: "STONE"