refactor TerraBiome

This commit is contained in:
dfsek
2021-01-12 17:39:26 -07:00
parent 9c50dc2ef9
commit 93c33ca455
34 changed files with 148 additions and 116 deletions

View File

@@ -9,7 +9,7 @@ public interface BiomeGrid extends Handle {
*
* @param x - 0-15
* @param z - 0-15
* @return Biome value
* @return TerraBiome value
*/
@NotNull
Biome getBiome(int x, int z);
@@ -20,7 +20,7 @@ public interface BiomeGrid extends Handle {
* @param x - 0-15
* @param y - 0-255
* @param z - 0-15
* @return Biome value
* @return TerraBiome value
*/
@NotNull
Biome getBiome(int x, int y, int z);
@@ -30,7 +30,7 @@ public interface BiomeGrid extends Handle {
*
* @param x - 0-15
* @param z - 0-15
* @param bio - Biome value
* @param bio - TerraBiome value
*/
void setBiome(int x, int z, @NotNull Biome bio);
@@ -40,7 +40,7 @@ public interface BiomeGrid extends Handle {
* @param x - 0-15
* @param y - 0-255
* @param z - 0-15
* @param bio - Biome value
* @param bio - TerraBiome value
*/
void setBiome(int x, int y, int z, @NotNull Biome bio);
}

View File

@@ -9,7 +9,7 @@ public abstract class BiomeGrid {
private final FastNoiseLite noiseZ;
private final int sizeX;
private final int sizeZ;
private Biome[][] grid;
private TerraBiome[][] grid;
public BiomeGrid(long seed, double freq1, double freq2, int sizeX, int sizeZ) {
@@ -33,9 +33,9 @@ public abstract class BiomeGrid {
*
* @param x - X-coordinate at which to fetch biome
* @param z - Z-coordinate at which to fetch biome
* @return Biome - Biome at the given coordinates.
* @return TerraBiome - TerraBiome at the given coordinates.
*/
public Biome getBiome(int x, int z, GenerationPhase phase) {
public TerraBiome getBiome(int x, int z, GenerationPhase phase) {
return grid[getBiomeNoiseX(x, z)][getBiomeNoiseZ(x, z)];
}
@@ -43,9 +43,9 @@ public abstract class BiomeGrid {
* Gets the biome at a location.
*
* @param l - The location at which to fetch the biome.
* @return Biome - Biome at the given coordinates.
* @return TerraBiome - TerraBiome at the given coordinates.
*/
public Biome getBiome(Location l) {
public TerraBiome getBiome(Location l) {
return getBiome(l, GenerationPhase.POST_GEN);
}
@@ -75,19 +75,20 @@ public abstract class BiomeGrid {
return normalize(noiseZ.getNoise(x, z), sizeZ);
}
public Biome[][] getGrid() {
public TerraBiome[][] getGrid() {
return grid;
}
public void setGrid(Biome[][] grid) {
public void setGrid(TerraBiome[][] grid) {
if(grid.length != sizeX) throw new IllegalArgumentException("Invalid length for grid, expected " + sizeX + ", got " + grid.length);
for(Biome[] gridLayer : grid) {
if(gridLayer.length != sizeZ) throw new IllegalArgumentException("Invalid length for grid layer, expected " + sizeZ + ", got " + gridLayer.length);
for(TerraBiome[] gridLayer : grid) {
if(gridLayer.length != sizeZ)
throw new IllegalArgumentException("Invalid length for grid layer, expected " + sizeZ + ", got " + gridLayer.length);
}
this.grid = grid;
}
public Biome getBiome(Location l, GenerationPhase phase) {
public TerraBiome getBiome(Location l, GenerationPhase phase) {
double biomeNoise = noiseX.getNoise(l.getBlockX(), l.getBlockZ());
double climateNoise = noiseZ.getNoise(l.getBlockX(), l.getBlockZ());
return grid[normalize(biomeNoise, sizeX)][normalize(climateNoise, sizeZ)];

View File

@@ -4,15 +4,15 @@ package com.dfsek.terra.api.world.biome;
import com.dfsek.terra.api.platform.world.World;
/**
* Interface to be implemented by a custom generator's Biome enum.<br>
* Interface to be implemented by a custom generator's TerraBiome enum.<br>
* Represents a custom biome, and contains methods to retrieve information about each type.
*/
public interface Biome {
public interface TerraBiome {
/**
* Gets the Vanilla biome to represent the custom biome.
*
* @return Biome - The Vanilla biome.
* @return TerraBiome - The Vanilla biome.
*/
com.dfsek.terra.api.platform.world.Biome getVanillaBiome();

View File

@@ -3,7 +3,7 @@ package com.dfsek.terra.async;
import com.dfsek.terra.api.math.vector.Location;
import com.dfsek.terra.api.math.vector.Vector3;
import com.dfsek.terra.api.platform.TerraPlugin;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.generation.GenerationPhase;
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
import org.jetbrains.annotations.NotNull;
@@ -13,9 +13,9 @@ import java.util.function.Consumer;
/**
* Runnable that locates a biome asynchronously
*/
public class AsyncBiomeFinder extends AsyncFeatureFinder<Biome> {
public class AsyncBiomeFinder extends AsyncFeatureFinder<TerraBiome> {
public AsyncBiomeFinder(TerraBiomeGrid grid, Biome target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraPlugin main) {
public AsyncBiomeFinder(TerraBiomeGrid grid, TerraBiome target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraPlugin main) {
super(grid, target, origin, startRadius, maxRadius, callback, main);
}
@@ -24,10 +24,10 @@ public class AsyncBiomeFinder extends AsyncFeatureFinder<Biome> {
*
* @param x X coordinate
* @param z Z coordinate
* @return Biome at coordinates
* @return TerraBiome at coordinates
*/
@Override
public boolean isValid(int x, int z, Biome target) {
public boolean isValid(int x, int z, TerraBiome target) {
int res = main.getTerraConfig().getBiomeSearchResolution();
return getGrid().getBiome(x * res, z * res, GenerationPhase.POST_GEN).equals(target);
}

View File

@@ -1,8 +1,8 @@
package com.dfsek.terra.biome;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.Generator;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.config.base.ConfigPack;
import com.dfsek.terra.config.builder.GeneratorBuilder;
import com.dfsek.terra.config.templates.BiomeTemplate;
@@ -10,7 +10,7 @@ import com.dfsek.terra.config.templates.BiomeTemplate;
/**
* Class representing a config-defined biome
*/
public class UserDefinedBiome implements Biome {
public class UserDefinedBiome implements TerraBiome {
private final GeneratorBuilder gen;
private final com.dfsek.terra.api.platform.world.Biome vanilla;
private final String id;
@@ -32,7 +32,7 @@ public class UserDefinedBiome implements Biome {
/**
* Gets the Vanilla biome to represent the custom biome.
*
* @return Biome - The Vanilla biome.
* @return TerraBiome - The Vanilla biome.
*/
@Override
public com.dfsek.terra.api.platform.world.Biome getVanillaBiome() {

View File

@@ -1,28 +1,28 @@
package com.dfsek.terra.biome.grid;
import com.dfsek.terra.api.math.vector.Location;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.BiomeGrid;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.generation.GenerationPhase;
/**
* BiomeGrid implementation that holds a single biome.
*/
public class SingleBiomeGrid extends BiomeGrid {
private final Biome biome;
private final TerraBiome biome;
public SingleBiomeGrid(long seed, Biome biome) {
public SingleBiomeGrid(long seed, TerraBiome biome) {
super(seed, 0, 0, 1, 1);
this.biome = biome;
}
@Override
public Biome getBiome(int x, int z, GenerationPhase phase) {
public TerraBiome getBiome(int x, int z, GenerationPhase phase) {
return biome;
}
@Override
public Biome getBiome(Location l) {
public TerraBiome getBiome(Location l) {
return biome;
}
}

View File

@@ -1,8 +1,8 @@
package com.dfsek.terra.biome.grid;
import com.dfsek.terra.api.math.vector.Location;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.BiomeGrid;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.generation.GenerationPhase;
import com.dfsek.terra.config.base.ConfigPack;
import com.dfsek.terra.config.base.ConfigPackTemplate;
@@ -14,7 +14,7 @@ public class UserDefinedGrid extends BiomeGrid {
private final ImageLoader.Channel channelX;
private final ImageLoader.Channel channelZ;
public UserDefinedGrid(long seed, double freq1, double freq2, Biome[][] b, ConfigPack c) {
public UserDefinedGrid(long seed, double freq1, double freq2, TerraBiome[][] b, ConfigPack c) {
super(seed, freq1, freq2, b.length, b[0].length);
super.setGrid(b);
ConfigPackTemplate t = c.getTemplate();
@@ -25,7 +25,7 @@ public class UserDefinedGrid extends BiomeGrid {
}
@Override
public Biome getBiome(int x, int z, GenerationPhase phase) {
public TerraBiome getBiome(int x, int z, GenerationPhase phase) {
if(fromImage) {
int xi = imageLoader.getNoiseVal(x, z, getSizeX() - 1, channelX);
int zi = imageLoader.getNoiseVal(x, z, getSizeZ() - 1, channelZ);
@@ -35,7 +35,7 @@ public class UserDefinedGrid extends BiomeGrid {
}
@Override
public Biome getBiome(Location l, GenerationPhase phase) {
public TerraBiome getBiome(Location l, GenerationPhase phase) {
return this.getBiome(l.getBlockX(), l.getBlockZ(), phase);
}
}

View File

@@ -2,8 +2,8 @@ package com.dfsek.terra.biome.grid.master;
import com.dfsek.terra.api.math.vector.Location;
import com.dfsek.terra.api.math.vector.Vector2;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.BiomeGrid;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.generation.GenerationPhase;
import com.dfsek.terra.biome.BiomeZone;
import com.dfsek.terra.biome.UserDefinedBiome;
@@ -43,7 +43,7 @@ public class TerraRadialBiomeGrid extends TerraBiomeGrid {
}
@Override
public Biome getBiome(int x, int z, GenerationPhase phase) {
public TerraBiome getBiome(int x, int z, GenerationPhase phase) {
int xp = x, zp = z;
if(perturb != null && (phase.equals(GenerationPhase.PALETTE_APPLY) || phase.equals(GenerationPhase.POPULATE))) {
Vector2 perturbCoords = perturb.getShiftedCoords(x, z);
@@ -62,7 +62,7 @@ public class TerraRadialBiomeGrid extends TerraBiomeGrid {
}
@Override
public Biome getBiome(Location l, GenerationPhase phase) {
public TerraBiome getBiome(Location l, GenerationPhase phase) {
return getBiome(l.getBlockX(), l.getBlockZ(), phase);
}
}

View File

@@ -2,8 +2,8 @@ package com.dfsek.terra.biome.grid.master;
import com.dfsek.terra.api.math.vector.Location;
import com.dfsek.terra.api.math.vector.Vector2;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.BiomeGrid;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.generation.GenerationPhase;
import com.dfsek.terra.biome.BiomeZone;
import com.dfsek.terra.biome.UserDefinedBiome;
@@ -38,7 +38,7 @@ public class TerraStandardBiomeGrid extends TerraBiomeGrid {
}
@Override
public Biome getBiome(int x, int z, GenerationPhase phase) {
public TerraBiome getBiome(int x, int z, GenerationPhase phase) {
int xp = x, zp = z;
if(perturb != null && (phase.equals(GenerationPhase.PALETTE_APPLY) || phase.equals(GenerationPhase.POPULATE))) {
Vector2 perturbCoords = perturb.getShiftedCoords(x, z);
@@ -53,7 +53,7 @@ public class TerraStandardBiomeGrid extends TerraBiomeGrid {
@Override
public Biome getBiome(Location l, GenerationPhase phase) {
public TerraBiome getBiome(Location l, GenerationPhase phase) {
return getBiome(l.getBlockX(), l.getBlockZ(), phase);
}
}

View File

@@ -1,6 +1,6 @@
package com.dfsek.terra.biome.pipeline;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.pipeline.expand.BiomeExpander;
import com.dfsek.terra.biome.pipeline.mutator.BiomeMutator;
import com.dfsek.terra.biome.pipeline.source.BiomeSource;
@@ -12,5 +12,5 @@ public interface BiomeHolder {
void fill(BiomeSource source);
Biome getBiome(int x, int z);
TerraBiome getBiome(int x, int z);
}

View File

@@ -1,6 +1,6 @@
package com.dfsek.terra.biome.pipeline;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.pipeline.expand.BiomeExpander;
import com.dfsek.terra.biome.pipeline.mutator.BiomeMutator;
import com.dfsek.terra.biome.pipeline.source.BiomeSource;
@@ -8,22 +8,22 @@ import com.dfsek.terra.biome.pipeline.source.BiomeSource;
public class TerraBiomeHolder implements BiomeHolder {
private final Position original;
private int width;
private Biome[][] biomes;
private TerraBiome[][] biomes;
public TerraBiomeHolder(int width, Position original) {
this.width = width;
biomes = new Biome[width][width];
biomes = new TerraBiome[width][width];
this.original = original;
}
@Override
public void expand(BiomeExpander expander) {
Biome[][] old = biomes;
TerraBiome[][] old = biomes;
int oldWidth = width;
width = 2 * width - 1;
biomes = new Biome[width][width];
biomes = new TerraBiome[width][width];
for(int x = 0; x < oldWidth; x++) {
for(int z = 0; z < oldWidth; z++) {
biomes[x * 2][z * 2] = old[x][z];
@@ -40,7 +40,7 @@ public class TerraBiomeHolder implements BiomeHolder {
public void mutate(BiomeMutator mutator) {
for(int x = 0; x < width; x++) {
for(int z = 0; z < width; z++) {
BiomeMutator.ViewPoint viewPoint = new BiomeMutator.ViewPoint(new Biome[][] {
BiomeMutator.ViewPoint viewPoint = new BiomeMutator.ViewPoint(new TerraBiome[][] {
{getBiome(x - 1, z + 1), getBiome(x, z + 1), getBiome(x + 1, z + 1)},
{getBiome(x - 1, z), getBiome(x, z), getBiome(x + 1, z)},
{getBiome(x - 1, z - 1), getBiome(x, z - 1), getBiome(x + 1, z - 1)}
@@ -60,7 +60,7 @@ public class TerraBiomeHolder implements BiomeHolder {
}
@Override
public Biome getBiome(int x, int z) {
public TerraBiome getBiome(int x, int z) {
if(x >= width || z >= width || x < 0 || z < 0) return null;
return biomes[x][z];
}

View File

@@ -1,8 +1,8 @@
package com.dfsek.terra.biome.pipeline.expand;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.pipeline.Position;
public interface BiomeExpander {
Biome getBetween(Position center, Biome... others);
TerraBiome getBetween(Position center, TerraBiome... others);
}

View File

@@ -2,7 +2,7 @@ package com.dfsek.terra.biome.pipeline.expand;
import com.dfsek.terra.api.math.MathUtil;
import com.dfsek.terra.api.math.noise.samplers.NoiseSampler;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.pipeline.Position;
public class FractalExpander implements BiomeExpander {
@@ -13,7 +13,7 @@ public class FractalExpander implements BiomeExpander {
}
@Override
public Biome getBetween(Position center, Biome... others) {
public TerraBiome getBetween(Position center, TerraBiome... others) {
return others[MathUtil.normalizeIndex(sampler.getNoise(center.getAsVector()), others.length)];
}
}

View File

@@ -1,19 +1,19 @@
package com.dfsek.terra.biome.pipeline.mutator;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.pipeline.Position;
public interface BiomeMutator {
Biome mutate(ViewPoint viewPoint, Position position);
TerraBiome mutate(ViewPoint viewPoint, Position position);
class ViewPoint {
private final Biome[][] biomes;
private final TerraBiome[][] biomes;
public ViewPoint(Biome[][] biomes) {
public ViewPoint(TerraBiome[][] biomes) {
this.biomes = biomes;
}
public Biome getBiome(int x, int z) {
public TerraBiome getBiome(int x, int z) {
return biomes[x + 1][z + 1];
}
}

View File

@@ -0,0 +1,13 @@
package com.dfsek.terra.biome.pipeline.mutator;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.pipeline.Position;
public class BorderMutator implements BiomeMutator {
@Override
public TerraBiome mutate(ViewPoint viewPoint, Position position) {
return null;
}
}

View File

@@ -2,24 +2,24 @@ package com.dfsek.terra.biome.pipeline.mutator;
import com.dfsek.terra.api.math.ProbabilityCollection;
import com.dfsek.terra.api.math.noise.samplers.NoiseSampler;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.pipeline.Position;
import java.util.Set;
public class ReplaceMutator implements BiomeMutator {
private final Set<Biome> replaceable;
private final ProbabilityCollection<Biome> replace;
private final Set<TerraBiome> replaceable;
private final ProbabilityCollection<TerraBiome> replace;
private final NoiseSampler sampler;
public ReplaceMutator(Set<Biome> replaceable, ProbabilityCollection<Biome> replace, NoiseSampler sampler) {
public ReplaceMutator(Set<TerraBiome> replaceable, ProbabilityCollection<TerraBiome> replace, NoiseSampler sampler) {
this.replaceable = replaceable;
this.replace = replace;
this.sampler = sampler;
}
@Override
public Biome mutate(ViewPoint viewPoint, Position position) {
public TerraBiome mutate(ViewPoint viewPoint, Position position) {
return replaceable.contains(viewPoint.getBiome(0, 0)) ? replace.get(sampler, position.getX(), position.getY()) : viewPoint.getBiome(0, 0);
}
}

View File

@@ -2,7 +2,7 @@ package com.dfsek.terra.biome.pipeline.mutator;
import com.dfsek.terra.api.math.MathUtil;
import com.dfsek.terra.api.math.noise.samplers.NoiseSampler;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.pipeline.Position;
import java.util.Objects;
@@ -16,11 +16,11 @@ public class SmoothMutator implements BiomeMutator {
}
@Override
public Biome mutate(ViewPoint viewPoint, Position position) {
Biome top = viewPoint.getBiome(1, 0);
Biome bottom = viewPoint.getBiome(-1, 0);
Biome left = viewPoint.getBiome(0, 1);
Biome right = viewPoint.getBiome(0, -1);
public TerraBiome mutate(ViewPoint viewPoint, Position position) {
TerraBiome top = viewPoint.getBiome(1, 0);
TerraBiome bottom = viewPoint.getBiome(-1, 0);
TerraBiome left = viewPoint.getBiome(0, 1);
TerraBiome right = viewPoint.getBiome(0, -1);
boolean vert = Objects.equals(top, bottom) && top != null;

View File

@@ -1,7 +1,7 @@
package com.dfsek.terra.biome.pipeline.source;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
public interface BiomeSource {
Biome getBiome(int x, int z);
TerraBiome getBiome(int x, int z);
}

View File

@@ -2,19 +2,19 @@ package com.dfsek.terra.biome.pipeline.source;
import com.dfsek.terra.api.math.ProbabilityCollection;
import com.dfsek.terra.api.math.noise.samplers.NoiseSampler;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
public class RandomSource implements BiomeSource {
private final ProbabilityCollection<Biome> biomes;
private final ProbabilityCollection<TerraBiome> biomes;
private final NoiseSampler sampler;
public RandomSource(ProbabilityCollection<Biome> biomes, NoiseSampler sampler) {
public RandomSource(ProbabilityCollection<TerraBiome> biomes, NoiseSampler sampler) {
this.biomes = biomes;
this.sampler = sampler;
}
@Override
public Biome getBiome(int x, int z) {
public TerraBiome getBiome(int x, int z) {
return biomes.get(sampler, x, z);
}
}

View File

@@ -6,7 +6,7 @@ import com.dfsek.terra.api.platform.TerraPlugin;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.api.util.FastRandom;
import com.dfsek.terra.api.util.GlueList;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.carving.Worm;
import com.dfsek.terra.api.world.generation.GenerationPhase;
import com.dfsek.terra.biome.UserDefinedBiome;
@@ -47,7 +47,7 @@ public class CarverCache {
List<Worm.WormPoint> points = new GlueList<>();
for(int i = 0; i < carving.getLength(); i++) {
carving.step();
Biome biome = grid.getBiome(carving.getRunning().toLocation(w), GenerationPhase.POPULATE);
TerraBiome biome = grid.getBiome(carving.getRunning().toLocation(w), GenerationPhase.POPULATE);
if(!((UserDefinedBiome) biome).getConfig().getCarvers().containsKey(carver)) { // Stop if we enter a biome this carver is not present in
return new GlueList<>();
}

View File

@@ -9,7 +9,7 @@ import com.dfsek.terra.api.LoaderRegistrar;
import com.dfsek.terra.api.platform.TerraPlugin;
import com.dfsek.terra.api.structures.loot.LootTable;
import com.dfsek.terra.api.structures.script.StructureScript;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.flora.Flora;
import com.dfsek.terra.api.world.palette.Palette;
import com.dfsek.terra.api.world.tree.Tree;
@@ -264,7 +264,7 @@ public class ConfigPack implements LoaderRegistrar {
public void register(TypeRegistry registry) {
registry
.registerLoader(Palette.class, paletteRegistry)
.registerLoader(Biome.class, biomeRegistry)
.registerLoader(TerraBiome.class, biomeRegistry)
.registerLoader(UserDefinedCarver.class, carverRegistry)
.registerLoader(Flora.class, floraRegistry)
.registerLoader(Ore.class, oreRegistry)

View File

@@ -261,10 +261,10 @@ public class ConfigPackTemplate implements ValidatedConfigTemplate {
throw new ValidationException("2 objects share the same image channels: biome-x and biome-z");
if(!MathUtil.equals(FastMath.log(baseBlend) / FastMath.log(2d), FastMath.round(FastMath.log(baseBlend) / FastMath.log(2d)))) {
throw new ValidationException("Biome base blend value \"" + baseBlend + "\" is not a power of 2.");
throw new ValidationException("TerraBiome base blend value \"" + baseBlend + "\" is not a power of 2.");
}
if(!MathUtil.equals(FastMath.log(elevationBlend) / FastMath.log(2d), FastMath.round(FastMath.log(elevationBlend) / FastMath.log(2d)))) {
throw new ValidationException("Biome elevation blend value \"" + baseBlend + "\" is not a power of 2.");
throw new ValidationException("TerraBiome elevation blend value \"" + baseBlend + "\" is not a power of 2.");
}
return true;
}

View File

@@ -1,13 +1,13 @@
package com.dfsek.terra.config.builder.biomegrid;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.grid.SingleBiomeGrid;
import com.dfsek.terra.config.base.ConfigPack;
public class SingleGridBuilder implements BiomeGridBuilder {
private final Biome biome;
private final TerraBiome biome;
public SingleGridBuilder(Biome biome) {
public SingleGridBuilder(TerraBiome biome) {
this.biome = biome;
}

View File

@@ -1,6 +1,6 @@
package com.dfsek.terra.config.builder.biomegrid;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.grid.UserDefinedGrid;
import com.dfsek.terra.config.base.ConfigPack;
@@ -8,7 +8,7 @@ public class UserDefinedGridBuilder implements BiomeGridBuilder {
private double xFreq;
private double zFreq;
private Biome[][] biomes;
private TerraBiome[][] biomes;
@Override
public UserDefinedGrid build(long seed, ConfigPack config) {
@@ -31,11 +31,11 @@ public class UserDefinedGridBuilder implements BiomeGridBuilder {
this.zFreq = zFreq;
}
public Biome[][] getBiomes() {
public TerraBiome[][] getBiomes() {
return biomes;
}
public void setBiomes(Biome[][] biomes) {
public void setBiomes(TerraBiome[][] biomes) {
this.biomes = biomes;
}
}

View File

@@ -2,7 +2,7 @@ package com.dfsek.terra.config.factories;
import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.terra.api.platform.TerraPlugin;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.config.builder.biomegrid.BiomeGridBuilder;
import com.dfsek.terra.config.builder.biomegrid.UserDefinedGridBuilder;
@@ -23,10 +23,10 @@ public class BiomeGridFactory implements TerraFactory<BiomeGridTemplate, BiomeGr
holder.setXFreq(config.getXFreq() * xSize);
holder.setZFreq(config.getZFreq() * zSize);
Biome[][] biomes = new UserDefinedBiome[xSize][zSize];
TerraBiome[][] biomes = new UserDefinedBiome[xSize][zSize];
for(int x = 0; x < xSize; x++) {
List<Biome> layer = config.getGrid().get(x);
List<TerraBiome> layer = config.getGrid().get(x);
if(!(layer.size() == zSize)) throw new LoadException("Expected " + zSize + " biomes in row " + x + ", found " + layer.size());
for(int z = 0; z < zSize; z++) {
biomes[x][z] = layer.get(z);

View File

@@ -2,7 +2,7 @@ package com.dfsek.terra.config.templates;
import com.dfsek.tectonic.annotations.Abstractable;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import java.util.List;
@@ -12,11 +12,11 @@ public class BiomeGridTemplate extends AbstractableTemplate {
private String id;
/**
* A 2D array of {@link Biome} IDs that make up this grid.
* A 2D array of {@link TerraBiome} IDs that make up this grid.
*/
@Value("grid")
@Abstractable
private List<List<Biome>> grid;
private List<List<TerraBiome>> grid;
/**
* X frequency of noise function
@@ -36,7 +36,7 @@ public class BiomeGridTemplate extends AbstractableTemplate {
return id;
}
public List<List<Biome>> getGrid() {
public List<List<TerraBiome>> getGrid() {
return grid;
}

View File

@@ -14,7 +14,7 @@ import com.dfsek.terra.api.platform.generator.ChunkGenerator;
import com.dfsek.terra.api.platform.world.BiomeGrid;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.api.profiler.ProfileFuture;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.generation.GenerationPhase;
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
import com.dfsek.terra.api.world.palette.Palette;
@@ -103,7 +103,7 @@ public class MasterChunkGenerator implements TerraChunkGenerator {
int cx = xOrig + x;
int cz = zOrig + z;
Biome b = grid.getBiome(xOrig + x, zOrig + z, GenerationPhase.PALETTE_APPLY);
TerraBiome b = grid.getBiome(xOrig + x, zOrig + z, GenerationPhase.PALETTE_APPLY);
BiomeTemplate c = ((UserDefinedBiome) b).getConfig();
int sea = c.getSeaLevel();
@@ -216,7 +216,7 @@ public class MasterChunkGenerator implements TerraChunkGenerator {
for(byte z = 0; z < 4; z++) {
int cx = xOrig + (x << 2);
int cz = zOrig + (z << 2);
Biome b = grid.getBiome(cx, cz, GenerationPhase.PALETTE_APPLY);
TerraBiome b = grid.getBiome(cx, cz, GenerationPhase.PALETTE_APPLY);
biome.setBiome(x << 2, z << 2, b.getVanillaBiome());
}

View File

@@ -8,7 +8,7 @@ import com.dfsek.terra.api.platform.world.Chunk;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.api.profiler.ProfileFuture;
import com.dfsek.terra.api.util.FastRandom;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.api.world.generation.GenerationPhase;
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
import com.dfsek.terra.biome.UserDefinedBiome;
@@ -35,7 +35,7 @@ public class OrePopulator implements TerraBlockPopulator {
Random random = new FastRandom(MathUtil.getCarverChunkSeed(chunk.getX() + cx, chunk.getZ() + cz, world.getSeed()));
int originX = ((chunk.getX() + cx) << 4);
int originZ = ((chunk.getZ() + cz) << 4);
Biome b = tw.getGrid().getBiome(originX + 8, originZ + 8, GenerationPhase.POPULATE);
TerraBiome b = tw.getGrid().getBiome(originX + 8, originZ + 8, GenerationPhase.POPULATE);
BiomeTemplate config = ((UserDefinedBiome) b).getConfig();
int finalCx = cx;
int finalCz = cz;

View File

@@ -4,14 +4,16 @@ import com.dfsek.terra.api.math.ProbabilityCollection;
import com.dfsek.terra.api.math.noise.samplers.FastNoiseLite;
import com.dfsek.terra.api.math.noise.samplers.NoiseSampler;
import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.biome.Generator;
import com.dfsek.terra.api.world.biome.TerraBiome;
import com.dfsek.terra.biome.pipeline.Position;
import com.dfsek.terra.biome.pipeline.TerraBiomeHolder;
import com.dfsek.terra.biome.pipeline.expand.FractalExpander;
import com.dfsek.terra.biome.pipeline.mutator.ReplaceMutator;
import com.dfsek.terra.biome.pipeline.mutator.SmoothMutator;
import com.dfsek.terra.biome.pipeline.source.BiomeSource;
import com.dfsek.terra.biome.pipeline.source.RandomSource;
import com.google.common.collect.Sets;
import org.junit.jupiter.api.Test;
import javax.swing.*;
@@ -21,17 +23,29 @@ import java.awt.image.BufferedImage;
public class BiomeTest {
@Test
public static void main(String... args) {
ProbabilityCollection<Biome> testBiomes = new ProbabilityCollection<>();
testBiomes.add(new TestBiome(Color.BLUE), 1);
testBiomes.add(new TestBiome(Color.GREEN), 1);
testBiomes.add(new TestBiome(Color.CYAN), 1);
testBiomes.add(new TestBiome(Color.MAGENTA), 1);
testBiomes.add(new TestBiome(Color.ORANGE), 1);
ProbabilityCollection<TerraBiome> oceanBiomes = new ProbabilityCollection<>();
ProbabilityCollection<TerraBiome> landBiomes = new ProbabilityCollection<>();
TestBiome ocean = new TestBiome(Color.BLUE);
TestBiome land = new TestBiome(Color.GREEN);
ProbabilityCollection<TerraBiome> climate = new ProbabilityCollection<>();
climate.add(ocean, 1);
climate.add(land, 3);
oceanBiomes.add(new TestBiome(Color.BLUE), 10);
oceanBiomes.add(new TestBiome(Color.CYAN), 1);
landBiomes.add(new TestBiome(Color.GREEN), 5);
landBiomes.add(new TestBiome(Color.ORANGE), 5);
landBiomes.add(new TestBiome(Color.YELLOW), 5);
landBiomes.add(new TestBiome(Color.MAGENTA), 1);
FastNoiseLite sourceSampler = new FastNoiseLite(123);
sourceSampler.setNoiseType(FastNoiseLite.NoiseType.WhiteNoise);
BiomeSource source = new RandomSource(testBiomes, sourceSampler);
BiomeSource source = new RandomSource(climate, sourceSampler);
int size = 20;
int expand = 6;
@@ -41,6 +55,10 @@ public class BiomeTest {
long s = System.nanoTime();
holder.fill(source);
holder.expand(new FractalExpander(whiteNoise(4)));
holder.mutate(new ReplaceMutator(Sets.newHashSet(ocean), oceanBiomes, whiteNoise(234)));
holder.mutate(new ReplaceMutator(Sets.newHashSet(land), landBiomes, whiteNoise(235)));
holder.expand(new FractalExpander(whiteNoise(3)));
holder.expand(new FractalExpander(whiteNoise(2)));
@@ -72,7 +90,7 @@ public class BiomeTest {
}
}
JFrame frame = new JFrame("Biome Viewer");
JFrame frame = new JFrame("TerraBiome Viewer");
frame.setResizable(false);
@@ -94,7 +112,7 @@ public class BiomeTest {
return noiseLite;
}
private final static class TestBiome implements Biome {
private final static class TestBiome implements TerraBiome {
private final Color color;
private TestBiome(Color color) {

View File

@@ -37,7 +37,7 @@ public class BiomeInfoCommand extends WorldCommand {
LangUtil.send("command.biome.invalid", new BukkitCommandSender(sender), id);
return true;
}
sender.sendMessage("Biome info for \"" + b.getID() + "\".");
sender.sendMessage("TerraBiome info for \"" + b.getID() + "\".");
sender.sendMessage("Vanilla biome: " + b.getVanillaBiome());
sender.sendMessage("Eroded by: " + b.getErode().getConfig().getID());

View File

@@ -25,7 +25,7 @@ command:
biome-found: "Bioom geleë te (%1$s, %2$s)"
unable-to-locate: "Kan bioom nie opspoor nie."
invalid-radius: "Ongeldige radius: \"%s\""
invalid: "Ongeldige Biome-ID: \"%s\""
invalid: "Ongeldige TerraBiome-ID: \"%s\""
in: "Jy is in \"%s\""
ore:
main-menu:

View File

@@ -56,7 +56,7 @@ command:
gui:
main-menu:
- "-------------Terra/image/gui-------------"
- "raw - Öffnet eine GUI mit Biome-Rohdaten"
- "raw - Öffnet eine GUI mit TerraBiome-Rohdaten"
- "step - Daten erneut rendern, um Ränder deutlicher darzustellen"
debug: "Der Debug-Modus muss aktiviert sein, um die Debug-GUI verwenden zu können! Die Debug-GUI ist NICHT PRODUKTIONSSICHER!"
render:

View File

@@ -26,7 +26,7 @@ command:
biome-found: "Located biome at (%1$s, %2$s)"
unable-to-locate: "Unable to locate biome."
invalid-radius: "Invalid radius: \"%s\""
invalid: "Invalid Biome ID: \"%s\""
invalid: "Invalid TerraBiome ID: \"%s\""
in: "You are in \"%s\""
packs:
main: "Currently installed config packs:"
@@ -61,7 +61,7 @@ command:
gui:
main-menu:
- "-------------Terra/image/gui-------------"
- "raw - Open GUI with raw Biome data"
- "raw - Open GUI with raw TerraBiome data"
- "step - Re-render data to show borders more clearly"
debug: "Debug mode must be enabled to use the debug GUI! The debug GUI is NOT PRODUCTION SAFE!"
render:

View File

@@ -25,7 +25,7 @@ command:
biome-found: "Zlokalizowano biom na (%1$s, %2$s)"
unable-to-locate: "Nie moglismy zlokalizowac biomu."
invalid-radius: "Niepoprawny zakres: \"%s\""
invalid: "Niepoprawne Biome ID: \"%s\""
invalid: "Niepoprawne TerraBiome ID: \"%s\""
in: "Jestes na \"%s\""
ore:
main-menu: