- apparently smooth sandstone is a thing

- support mountain biomes
This commit is contained in:
dags- 2020-06-23 12:41:40 +01:00
parent fad240c246
commit c6daeb7ce1
39 changed files with 234 additions and 76 deletions

2
Engine

@ -1 +1 @@
Subproject commit 0d0aea5be29a0128d5033bdd2bcd33a3396f5528 Subproject commit a28088b543d0457cd71f6f52aa7096b01180c5b8

View File

@ -25,6 +25,7 @@
"display.terraforged.climate.biome_shape.biome_size": "Biome Size", "display.terraforged.climate.biome_shape.biome_size": "Biome Size",
"display.terraforged.climate.biome_shape.biome_warp_scale": "Biome Warp Scale", "display.terraforged.climate.biome_shape.biome_warp_scale": "Biome Warp Scale",
"display.terraforged.climate.biome_shape.biome_warp_strength": "Biome Warp Strength", "display.terraforged.climate.biome_shape.biome_warp_strength": "Biome Warp Strength",
"display.terraforged.climate.biome_shape.macro_noise_size": "Macro Noise Size",
"display.terraforged.climate.moisture": "Moisture", "display.terraforged.climate.moisture": "Moisture",
"display.terraforged.climate.moisture.bias": "Bias", "display.terraforged.climate.moisture.bias": "Bias",
"display.terraforged.climate.moisture.falloff": "Falloff", "display.terraforged.climate.moisture.falloff": "Falloff",
@ -45,13 +46,6 @@
"display.terraforged.dimensions.dimensions": "Dimensions", "display.terraforged.dimensions.dimensions": "Dimensions",
"display.terraforged.dimensions.dimensions.end": "End", "display.terraforged.dimensions.dimensions.end": "End",
"display.terraforged.dimensions.dimensions.nether": "Nether", "display.terraforged.dimensions.dimensions.nether": "Nether",
"display.terraforged.features": "Features",
"display.terraforged.features.custom_biome_features": "Custom Biome Features",
"display.terraforged.features.erosion_decorator": "Erosion Decorator",
"display.terraforged.features.natural_snow_decorator": "Natural Snow Decorator",
"display.terraforged.features.smooth_layer_decorator": "Smooth Layer Decorator",
"display.terraforged.features.strata_decorator": "Strata Decorator",
"display.terraforged.features.vanilla_water_features": "Vanilla Water Features",
"display.terraforged.filters": "Filters", "display.terraforged.filters": "Filters",
"display.terraforged.filters.erosion": "Erosion", "display.terraforged.filters.erosion": "Erosion",
"display.terraforged.filters.erosion.deposite_rate": "Deposite Rate", "display.terraforged.filters.erosion.deposite_rate": "Deposite Rate",
@ -64,6 +58,14 @@
"display.terraforged.filters.smoothing.iterations": "Iterations", "display.terraforged.filters.smoothing.iterations": "Iterations",
"display.terraforged.filters.smoothing.smoothing_radius": "Smoothing Radius", "display.terraforged.filters.smoothing.smoothing_radius": "Smoothing Radius",
"display.terraforged.filters.smoothing.smoothing_rate": "Smoothing Rate", "display.terraforged.filters.smoothing.smoothing_rate": "Smoothing Rate",
"display.terraforged.miscellaneous": "Miscellaneous",
"display.terraforged.miscellaneous.custom_biome_features": "Custom Biome Features",
"display.terraforged.miscellaneous.erosion_decorator": "Erosion Decorator",
"display.terraforged.miscellaneous.mountain_biome_usage": "Mountain Biome Usage",
"display.terraforged.miscellaneous.natural_snow_decorator": "Natural Snow Decorator",
"display.terraforged.miscellaneous.smooth_layer_decorator": "Smooth Layer Decorator",
"display.terraforged.miscellaneous.strata_decorator": "Strata Decorator",
"display.terraforged.miscellaneous.vanilla_water_features": "Vanilla Water Features",
"display.terraforged.preview": "Preview", "display.terraforged.preview": "Preview",
"display.terraforged.preview.display": "Display", "display.terraforged.preview.display": "Display",
"display.terraforged.preview.zoom": "Zoom", "display.terraforged.preview.zoom": "Zoom",
@ -189,6 +191,7 @@
"tooltip.terraforged.climate.biome_shape.biome_size": "Controls the size of individual biomes", "tooltip.terraforged.climate.biome_shape.biome_size": "Controls the size of individual biomes",
"tooltip.terraforged.climate.biome_shape.biome_warp_scale": "Controls the scale of shape distortion for biomes", "tooltip.terraforged.climate.biome_shape.biome_warp_scale": "Controls the scale of shape distortion for biomes",
"tooltip.terraforged.climate.biome_shape.biome_warp_strength": "Controls the strength of shape distortion for biomes", "tooltip.terraforged.climate.biome_shape.biome_warp_strength": "Controls the strength of shape distortion for biomes",
"tooltip.terraforged.climate.biome_shape.macro_noise_size": "Macro noise is used to group large areas of biomes into a single type (such as deserts)",
"tooltip.terraforged.climate.moisture.bias": "The bias towards either end of the range", "tooltip.terraforged.climate.moisture.bias": "The bias towards either end of the range",
"tooltip.terraforged.climate.moisture.falloff": "How quickly values transition from an extremity", "tooltip.terraforged.climate.moisture.falloff": "How quickly values transition from an extremity",
"tooltip.terraforged.climate.moisture.max": "The upper limit of the range", "tooltip.terraforged.climate.moisture.max": "The upper limit of the range",
@ -204,12 +207,6 @@
"tooltip.terraforged.dimensions.bedrock_layer.variance": "Controls the amount of height randomness of the world's base layer", "tooltip.terraforged.dimensions.bedrock_layer.variance": "Controls the amount of height randomness of the world's base layer",
"tooltip.terraforged.dimensions.dimensions.end": "Select the end generator", "tooltip.terraforged.dimensions.dimensions.end": "Select the end generator",
"tooltip.terraforged.dimensions.dimensions.nether": "Select the nether generator", "tooltip.terraforged.dimensions.dimensions.nether": "Select the nether generator",
"tooltip.terraforged.features.custom_biome_features": "Use custom biome features in place of vanilla ones (such as trees)",
"tooltip.terraforged.features.erosion_decorator": "Replace surface materials where erosion has occurred",
"tooltip.terraforged.features.natural_snow_decorator": "Removes snow from the terrain where it shouldn't naturally settle",
"tooltip.terraforged.features.smooth_layer_decorator": "Modifies layer block levels (ie snow) to fit the terrain",
"tooltip.terraforged.features.strata_decorator": "Generates strata (rock layers) instead of just stone",
"tooltip.terraforged.features.vanilla_water_features": "Controls whether vanilla lakes & springs should generate",
"tooltip.terraforged.filters.erosion.deposite_rate": "Controls how quickly material is deposited (during erosion)", "tooltip.terraforged.filters.erosion.deposite_rate": "Controls how quickly material is deposited (during erosion)",
"tooltip.terraforged.filters.erosion.droplet_lifetime": "Controls the number of iterations that a single water droplet is simulated for", "tooltip.terraforged.filters.erosion.droplet_lifetime": "Controls the number of iterations that a single water droplet is simulated for",
"tooltip.terraforged.filters.erosion.droplet_velocity": "Controls the starting velocity of the simulated water droplet", "tooltip.terraforged.filters.erosion.droplet_velocity": "Controls the starting velocity of the simulated water droplet",
@ -219,6 +216,13 @@
"tooltip.terraforged.filters.smoothing.iterations": "Controls the number of smoothing iterations", "tooltip.terraforged.filters.smoothing.iterations": "Controls the number of smoothing iterations",
"tooltip.terraforged.filters.smoothing.smoothing_radius": "Controls the smoothing radius", "tooltip.terraforged.filters.smoothing.smoothing_radius": "Controls the smoothing radius",
"tooltip.terraforged.filters.smoothing.smoothing_rate": "Controls how strongly smoothing is applied", "tooltip.terraforged.filters.smoothing.smoothing_rate": "Controls how strongly smoothing is applied",
"tooltip.terraforged.miscellaneous.custom_biome_features": "Use custom biome features in place of vanilla ones (such as trees)",
"tooltip.terraforged.miscellaneous.erosion_decorator": "Replace surface materials where erosion has occurred",
"tooltip.terraforged.miscellaneous.mountain_biome_usage": "The probability that mountainous terrain will be set to a mountain biome type.\nThis may help improve compatibility with mods that rely exclusively on mountain biomes.",
"tooltip.terraforged.miscellaneous.natural_snow_decorator": "Removes snow from the terrain where it shouldn't naturally settle",
"tooltip.terraforged.miscellaneous.smooth_layer_decorator": "Modifies layer block levels (ie snow) to fit the terrain",
"tooltip.terraforged.miscellaneous.strata_decorator": "Generates strata (rock layers) instead of just stone",
"tooltip.terraforged.miscellaneous.vanilla_water_features": "Controls whether vanilla lakes & springs should generate",
"tooltip.terraforged.rivers.primary_rivers.bank_width": "Controls the river-banks width", "tooltip.terraforged.rivers.primary_rivers.bank_width": "Controls the river-banks width",
"tooltip.terraforged.rivers.primary_rivers.bed_depth": "Controls the depth of the river", "tooltip.terraforged.rivers.primary_rivers.bed_depth": "Controls the depth of the river",
"tooltip.terraforged.rivers.primary_rivers.bed_width": "Controls the river-bed width", "tooltip.terraforged.rivers.primary_rivers.bed_width": "Controls the river-bed width",

View File

@ -32,7 +32,7 @@ public interface BiomeModifier extends Comparable<BiomeModifier> {
int priority(); int priority();
boolean test(Biome biome); boolean test(Biome biome, Cell cell);
Biome modify(Biome in, Cell cell, int x, int z); Biome modify(Biome in, Cell cell, int x, int z);

View File

@ -35,9 +35,9 @@ public class States {
public static final StateSupplier GRAVEL = DefaultState.of("minecraft:gravel").cache(); public static final StateSupplier GRAVEL = DefaultState.of("minecraft:gravel").cache();
public static final StateSupplier LAVA = DefaultState.of("minecraft:lava").cache(); public static final StateSupplier LAVA = DefaultState.of("minecraft:lava").cache();
public static final StateSupplier PACKED_ICE = DefaultState.of("minecraft:packed_ice").cache(); public static final StateSupplier PACKED_ICE = DefaultState.of("minecraft:packed_ice").cache();
public static final StateSupplier RED_SANDSTONE = DefaultState.of("minecraft:red_sandstone").cache();
public static final StateSupplier SAND = DefaultState.of("minecraft:sand").cache(); public static final StateSupplier SAND = DefaultState.of("minecraft:sand").cache();
public static final StateSupplier SANDSTONE = DefaultState.of("minecraft:sandstone").cache(); public static final StateSupplier SMOOTH_SANDSTONE = DefaultState.of("minecraft:smooth_sandstone").cache();
public static final StateSupplier SMOOTH_RED_SANDSTONE = DefaultState.of("minecraft:smooth_red_sandstone").cache();
public static final StateSupplier SNOW_BLOCK = DefaultState.of("minecraft:snow_block").cache(); public static final StateSupplier SNOW_BLOCK = DefaultState.of("minecraft:snow_block").cache();
public static final StateSupplier STONE = DefaultState.of("minecraft:stone").cache(); public static final StateSupplier STONE = DefaultState.of("minecraft:stone").cache();
public static final StateSupplier WATER = DefaultState.of("minecraft:water").cache(); public static final StateSupplier WATER = DefaultState.of("minecraft:water").cache();

View File

@ -31,6 +31,7 @@ import com.terraforged.world.biome.BiomeType;
import com.terraforged.world.heightmap.Levels; import com.terraforged.world.heightmap.Levels;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public interface BiomeMap { public interface BiomeMap {
@ -51,6 +52,9 @@ public interface BiomeMap {
Biome getLand(Cell cell); Biome getLand(Cell cell);
@Nullable
Biome getMountain(Cell cell);
Biome provideBiome(Cell cell, Levels levels); Biome provideBiome(Cell cell, Levels levels);
List<Biome> getAllBiomes(BiomeType type); List<Biome> getAllBiomes(BiomeType type);
@ -71,6 +75,8 @@ public interface BiomeMap {
Builder addWetland(Biome biome, int count); Builder addWetland(Biome biome, int count);
Builder addMountain(Biome biome, int count);
Builder addLand(BiomeType type, Biome biome, int count); Builder addLand(BiomeType type, Biome biome, int count);
BiomeMap build(); BiomeMap build();

View File

@ -45,6 +45,7 @@ public class BiomeMapBuilder implements BiomeMap.Builder {
protected final Map<Biome.TempCategory, List<Biome>> beaches = new HashMap<>(); protected final Map<Biome.TempCategory, List<Biome>> beaches = new HashMap<>();
protected final Map<Biome.TempCategory, List<Biome>> oceans = new HashMap<>(); protected final Map<Biome.TempCategory, List<Biome>> oceans = new HashMap<>();
protected final Map<Biome.TempCategory, List<Biome>> deepOceans = new HashMap<>(); protected final Map<Biome.TempCategory, List<Biome>> deepOceans = new HashMap<>();
protected final Map<Biome.TempCategory, List<Biome>> mountains = new HashMap<>();
protected final Map<BiomeType, List<Biome>> map = new EnumMap<>(BiomeType.class); protected final Map<BiomeType, List<Biome>> map = new EnumMap<>(BiomeType.class);
private final Function<BiomeMapBuilder, BiomeMap> constructor; private final Function<BiomeMapBuilder, BiomeMap> constructor;
@ -99,6 +100,13 @@ public class BiomeMapBuilder implements BiomeMap.Builder {
return this; return this;
} }
@Override
public BiomeMapBuilder addMountain(Biome biome, int count) {
Biome.TempCategory category = BiomeHelper.getMountainCategory(biome);
add(mountains.computeIfAbsent(category, c -> new ArrayList<>()), biome, count);
return this;
}
@Override @Override
public BiomeMapBuilder addLand(BiomeType type, Biome biome, int count) { public BiomeMapBuilder addLand(BiomeType type, Biome biome, int count) {
add(map.computeIfAbsent(type, t -> new ArrayList<>()), biome, count); add(map.computeIfAbsent(type, t -> new ArrayList<>()), biome, count);

View File

@ -28,6 +28,7 @@ public class SimpleBiomeMap implements BiomeMap {
private final BiomeSet lake; private final BiomeSet lake;
private final BiomeSet wetland; private final BiomeSet wetland;
private final BiomeSet land; private final BiomeSet land;
private final BiomeSet mountains;
private final BiomeSet[] terrainBiomes; private final BiomeSet[] terrainBiomes;
public SimpleBiomeMap(BiomeMapBuilder builder) { public SimpleBiomeMap(BiomeMapBuilder builder) {
@ -38,6 +39,7 @@ public class SimpleBiomeMap implements BiomeMap {
river = new RiverSet(builder.rivers, DefaultBiomes::defaultRiver, this); river = new RiverSet(builder.rivers, DefaultBiomes::defaultRiver, this);
lake = new TemperatureSet(builder.lakes, DefaultBiomes::defaultLake); lake = new TemperatureSet(builder.lakes, DefaultBiomes::defaultLake);
wetland = new TemperatureSet(builder.wetlands, DefaultBiomes::defaultWetland); wetland = new TemperatureSet(builder.wetlands, DefaultBiomes::defaultWetland);
mountains = new TemperatureSet(builder.mountains, DefaultBiomes::defaultMountain);
land = new BiomeTypeSet(builder.map, DefaultBiomes::defaultBiome); land = new BiomeTypeSet(builder.map, DefaultBiomes::defaultBiome);
terrainBiomes = new BiomeSet[TerrainType.values().length]; terrainBiomes = new BiomeSet[TerrainType.values().length];
terrainBiomes[TerrainType.SHALLOW_OCEAN.ordinal()] = shallowOcean; terrainBiomes[TerrainType.SHALLOW_OCEAN.ordinal()] = shallowOcean;
@ -102,6 +104,11 @@ public class SimpleBiomeMap implements BiomeMap {
return wetland.getBiome(cell); return wetland.getBiome(cell);
} }
@Override
public Biome getMountain(Cell cell) {
return mountains.getBiome(cell);
}
@Override @Override
public Biome getLand(Cell cell) { public Biome getLand(Cell cell) {
return land.getBiome(cell); return land.getBiome(cell);
@ -109,6 +116,9 @@ public class SimpleBiomeMap implements BiomeMap {
@Override @Override
public List<Biome> getAllBiomes(BiomeType type) { public List<Biome> getAllBiomes(BiomeType type) {
if (type == BiomeType.ALPINE) {
return Collections.emptyList();
}
int size = land.getSize(type.ordinal()); int size = land.getSize(type.ordinal());
if (size == 0) { if (size == 0) {
return Collections.emptyList(); return Collections.emptyList();
@ -126,7 +136,13 @@ public class SimpleBiomeMap implements BiomeMap {
root.add("RIVER", river.toJson()); root.add("RIVER", river.toJson());
root.add("LAKE", lake.toJson()); root.add("LAKE", lake.toJson());
root.add("WETLAND", wetland.toJson()); root.add("WETLAND", wetland.toJson());
root.add("LAND", land.toJson()); root.add("LAND", landToJson());
return root;
}
private JsonElement landToJson() {
JsonObject root = land.toJson().getAsJsonObject();
root.add(BiomeType.ALPINE.name(), mountains.toJson());
return root; return root;
} }
} }

View File

@ -0,0 +1,7 @@
package com.terraforged.biome.map.defaults;
public class BiomeTemps {
public static final float COLD = 0.25F;
public static final float HOT = 0.75F;
}

View File

@ -1,9 +1,12 @@
package com.terraforged.biome.map.defaults; package com.terraforged.biome.map.defaults;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.OceanBiome;
public interface DefaultBiome { public interface DefaultBiome {
Biome NONE = new OceanBiome().setRegistryName("terraforged", "none");
Biome getBiome(float temperature); Biome getBiome(float temperature);
default Biome getDefaultBiome(float temperature) { default Biome getDefaultBiome(float temperature) {

View File

@ -57,6 +57,16 @@ public class DefaultBiomes {
return Biomes.DEEP_OCEAN; return Biomes.DEEP_OCEAN;
} }
public static Biome defaultMountain(float temperature) {
if (temperature < 0.25) {
return Biomes.SNOWY_MOUNTAINS;
}
if (temperature > 0.75) {
return DefaultBiome.NONE;
}
return Biomes.MOUNTAINS;
}
public static Biome defaultBiome(float temperature) { public static Biome defaultBiome(float temperature) {
if (temperature < 0.3) { if (temperature < 0.3) {
return ModBiomes.TAIGA_SCRUB; return ModBiomes.TAIGA_SCRUB;

View File

@ -3,6 +3,7 @@ package com.terraforged.biome.map.set;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.terraforged.biome.map.defaults.BiomeTemps;
import com.terraforged.biome.map.defaults.DefaultBiome; import com.terraforged.biome.map.defaults.DefaultBiome;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
@ -20,10 +21,10 @@ public class TemperatureSet extends BiomeSet {
@Override @Override
public int getIndex(Cell cell) { public int getIndex(Cell cell) {
if (cell.temperature < 0.25) { if (cell.temperature < BiomeTemps.COLD) {
return 0; return 0;
} }
if (cell.temperature > 0.75) { if (cell.temperature > BiomeTemps.HOT) {
return 2; return 2;
} }
return 1; return 1;

View File

@ -7,7 +7,7 @@ import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source; import com.terraforged.n2d.Source;
import com.terraforged.world.GeneratorContext; import com.terraforged.world.GeneratorContext;
import com.terraforged.world.biome.BiomeType; import com.terraforged.world.biome.BiomeType;
import com.terraforged.world.terrain.Terrains; import com.terraforged.world.terrain.TerrainType;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes; import net.minecraft.world.biome.Biomes;
@ -16,11 +16,9 @@ public class BeachModifier implements BiomeModifier {
private final float height; private final float height;
private final Module noise; private final Module noise;
private final BiomeMap biomes; private final BiomeMap biomes;
private final Terrains terrains;
public BeachModifier(BiomeMap biomeMap, GeneratorContext context) { public BeachModifier(BiomeMap biomeMap, GeneratorContext context) {
this.biomes = biomeMap; this.biomes = biomeMap;
this.terrains = context.terrain;
this.height = context.levels.water(6); this.height = context.levels.water(6);
this.noise = Source.perlin(context.seed.next(), 10, 1).scale(context.levels.scale(5)); this.noise = Source.perlin(context.seed.next(), 10, 1).scale(context.levels.scale(5));
} }
@ -31,19 +29,17 @@ public class BeachModifier implements BiomeModifier {
} }
@Override @Override
public boolean test(Biome biome) { public boolean test(Biome biome, Cell cell) {
return true; return cell.terrain.getType() == TerrainType.BEACH && cell.biomeType != BiomeType.DESERT;
} }
@Override @Override
public Biome modify(Biome in, Cell cell, int x, int z) { public Biome modify(Biome in, Cell cell, int x, int z) {
if (cell.terrain == terrains.beach && cell.biomeType != BiomeType.DESERT) { if (cell.value + noise.getValue(x, z) < height) {
if (cell.value + noise.getValue(x, z) < height) { if (in == Biomes.MUSHROOM_FIELDS) {
if (in == Biomes.MUSHROOM_FIELDS) { return Biomes.MUSHROOM_FIELD_SHORE;
return Biomes.MUSHROOM_FIELD_SHORE;
}
return biomes.getBeach(cell);
} }
return biomes.getBeach(cell);
} }
return in; return in;
} }

View File

@ -50,6 +50,7 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager {
modifiers.add(new CoastModifier(biomes, context)); modifiers.add(new CoastModifier(biomes, context));
modifiers.add(new DesertColorModifier(desertBiomes)); modifiers.add(new DesertColorModifier(desertBiomes));
modifiers.add(new BeachModifier(biomes, context)); modifiers.add(new BeachModifier(biomes, context));
modifiers.add(new MountainModifier(context, biomes));
Collections.sort(modifiers); Collections.sort(modifiers);
this.biomeModifiers = modifiers; this.biomeModifiers = modifiers;
} }
@ -74,14 +75,14 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager {
} }
@Override @Override
public boolean test(Biome biome) { public boolean test(Biome biome, Cell cell) {
return true; return true;
} }
@Override @Override
public Biome modify(Biome biome, Cell cell, int x, int z) { public Biome modify(Biome biome, Cell cell, int x, int z) {
for (BiomeModifier modifier : biomeModifiers) { for (BiomeModifier modifier : biomeModifiers) {
if (modifier.test(biome)) { if (modifier.test(biome, cell)) {
biome = modifier.modify(biome, cell, x, z); biome = modifier.modify(biome, cell, x, z);
if (modifier.exitEarly()) { if (modifier.exitEarly()) {
return biome; return biome;

View File

@ -50,8 +50,8 @@ public class CoastModifier implements BiomeModifier {
} }
@Override @Override
public boolean test(Biome biome) { public boolean test(Biome biome, Cell cell) {
return true; return cell.terrain.isCoast();
} }
@Override @Override

View File

@ -49,7 +49,7 @@ public class DesertColorModifier implements BiomeModifier {
} }
@Override @Override
public boolean test(Biome biome) { public boolean test(Biome biome, Cell cell) {
return biome.getCategory() == Biome.Category.DESERT return biome.getCategory() == Biome.Category.DESERT
|| biome.getCategory() == Biome.Category.MESA || biome.getCategory() == Biome.Category.MESA
|| biomes.isDesert(biome); || biomes.isDesert(biome);

View File

@ -0,0 +1,46 @@
package com.terraforged.biome.modifier;
import com.terraforged.api.biome.modifier.BiomeModifier;
import com.terraforged.biome.map.BiomeMap;
import com.terraforged.biome.map.defaults.DefaultBiome;
import com.terraforged.chunk.TerraContext;
import com.terraforged.core.cell.Cell;
import net.minecraft.world.biome.Biome;
public class MountainModifier implements BiomeModifier {
// the probability that mountain terrain will get upgraded to a mountain biome
public static final float MOUNTAIN_CHANCE = 0.4F;
private final float chance;
private final BiomeMap biomes;
public MountainModifier(TerraContext context, BiomeMap biomes) {
this.biomes = biomes;
this.chance = context.terraSettings.miscellaneous.mountainBiomeUsage;
}
@Override
public int priority() {
return 0;
}
@Override
public boolean exitEarly() {
return true;
}
@Override
public boolean test(Biome biome, Cell cell) {
return cell.terrain.isMountain() && cell.macroNoise < chance;
}
@Override
public Biome modify(Biome in, Cell cell, int x, int z) {
Biome mountain = biomes.getMountain(cell);
if (mountain != DefaultBiome.NONE) {
return mountain;
}
return in;
}
}

View File

@ -89,9 +89,15 @@ public class BiomeHelper {
builder.addLake(biome, weight); builder.addLake(biome, weight);
} else if (BiomePredicate.WETLAND.test(data)) { } else if (BiomePredicate.WETLAND.test(data)) {
builder.addWetland(biome, weight); builder.addWetland(biome, weight);
} else if (BiomePredicate.MOUNTAIN.test(data)) {
builder.addMountain(biome, weight);
} else { } else {
Collection<BiomeType> types = getTypes(data, biome); Collection<BiomeType> types = getTypes(data, biome);
for (BiomeType type : types) { for (BiomeType type : types) {
// shouldn't happen
if (type == BiomeType.ALPINE) {
continue;
}
builder.addLand(type, biome, weight); builder.addLand(type, biome, weight);
} }
} }
@ -129,6 +135,16 @@ public class BiomeHelper {
return biome.getTempCategory(); return biome.getTempCategory();
} }
public static Biome.TempCategory getMountainCategory(Biome biome) {
if (biome.getDefaultTemperature() < 0.2) {
return Biome.TempCategory.COLD;
}
if (biome.getDefaultTemperature() > 0.4) {
return Biome.TempCategory.WARM;
}
return Biome.TempCategory.MEDIUM;
}
public static String getId(Biome biome) { public static String getId(Biome biome) {
ResourceLocation name = biome.getRegistryName(); ResourceLocation name = biome.getRegistryName();
if (name == null) { if (name == null) {

View File

@ -14,7 +14,7 @@ public class DesertSurface implements Surface {
private final float min; private final float min;
private final float level; private final float level;
private final Module noise; private final Module noise;
private final BlockState sandstone = States.SANDSTONE.get(); private final BlockState sandstone = States.SMOOTH_SANDSTONE.get();
private final BlockState low = Blocks.TERRACOTTA.delegate.get().getDefaultState(); private final BlockState low = Blocks.TERRACOTTA.delegate.get().getDefaultState();
private final BlockState mid = Blocks.ORANGE_TERRACOTTA.delegate.get().getDefaultState(); private final BlockState mid = Blocks.ORANGE_TERRACOTTA.delegate.get().getDefaultState();
private final BlockState high = Blocks.BROWN_TERRACOTTA.delegate.get().getDefaultState(); private final BlockState high = Blocks.BROWN_TERRACOTTA.delegate.get().getDefaultState();

View File

@ -46,11 +46,11 @@ public class TerraSetupFactory {
public static List<ColumnDecorator> createBaseDecorators(GeoManager geoManager, TerraContext context) { public static List<ColumnDecorator> createBaseDecorators(GeoManager geoManager, TerraContext context) {
List<ColumnDecorator> processors = new ArrayList<>(); List<ColumnDecorator> processors = new ArrayList<>();
if (context.terraSettings.features.strataDecorator) { if (context.terraSettings.miscellaneous.strataDecorator) {
Log.info(" - Geology decorator enabled"); Log.info(" - Geology decorator enabled");
processors.add(new GeologyDecorator(geoManager)); processors.add(new GeologyDecorator(geoManager));
} }
if (context.terraSettings.features.erosionDecorator) { if (context.terraSettings.miscellaneous.erosionDecorator) {
Log.info(" - Erosion decorator enabled"); Log.info(" - Erosion decorator enabled");
processors.add(new ErosionDecorator(context)); processors.add(new ErosionDecorator(context));
} }
@ -60,11 +60,11 @@ public class TerraSetupFactory {
public static List<ColumnDecorator> createFeatureDecorators(TerraContext context) { public static List<ColumnDecorator> createFeatureDecorators(TerraContext context) {
List<ColumnDecorator> processors = new ArrayList<>(); List<ColumnDecorator> processors = new ArrayList<>();
if (context.terraSettings.features.naturalSnowDecorator) { if (context.terraSettings.miscellaneous.naturalSnowDecorator) {
Log.info(" - Natural snow decorator enabled"); Log.info(" - Natural snow decorator enabled");
processors.add(new SnowEroder(context)); processors.add(new SnowEroder(context));
} }
if (context.terraSettings.features.smoothLayerDecorator) { if (context.terraSettings.miscellaneous.smoothLayerDecorator) {
Log.info(" - Smooth layer decorator enabled"); Log.info(" - Smooth layer decorator enabled");
processors.add(new LayerDecorator(context.materials.getLayerManager())); processors.add(new LayerDecorator(context.materials.getLayerManager()));
} }
@ -76,20 +76,20 @@ public class TerraSetupFactory {
} }
public static FeatureManager createFeatureManager(DataManager data, TerraContext context) { public static FeatureManager createFeatureManager(DataManager data, TerraContext context) {
FeatureModifiers modifiers = FeatureManager.modifiers(data, context.terraSettings.features.customBiomeFeatures); FeatureModifiers modifiers = FeatureManager.modifiers(data, context.terraSettings.miscellaneous.customBiomeFeatures);
if (context.terraSettings.features.strataDecorator) { if (context.terraSettings.miscellaneous.strataDecorator) {
// block stone blobs if strata enabled // block stone blobs if strata enabled
modifiers.getPredicates().add(Matchers.stoneBlobs(), FeaturePredicate.DENY); modifiers.getPredicates().add(Matchers.stoneBlobs(), FeaturePredicate.DENY);
} }
if (!context.terraSettings.features.vanillaWaterFeatures) { if (!context.terraSettings.miscellaneous.vanillaWaterFeatures) {
// block lakes and springs if not enabled // block lakes and springs if not enabled
modifiers.getPredicates().add(FeatureMatcher.of(Feature.LAKE), FeaturePredicate.DENY); modifiers.getPredicates().add(FeatureMatcher.of(Feature.LAKE), FeaturePredicate.DENY);
modifiers.getPredicates().add(FeatureMatcher.of(Feature.SPRING_FEATURE), FeaturePredicate.DENY); modifiers.getPredicates().add(FeatureMatcher.of(Feature.SPRING_FEATURE), FeaturePredicate.DENY);
} }
if (context.terraSettings.features.customBiomeFeatures) { if (context.terraSettings.miscellaneous.customBiomeFeatures) {
// remove default trees from river biomes since forests can go up to the edge of rivers // remove default trees from river biomes since forests can go up to the edge of rivers
modifiers.getPredicates().add(BiomeMatcher.of(Biome.Category.RIVER), Matchers.tree(), FeaturePredicate.DENY); modifiers.getPredicates().add(BiomeMatcher.of(Biome.Category.RIVER), Matchers.tree(), FeaturePredicate.DENY);

View File

@ -30,13 +30,13 @@ import com.terraforged.api.chunk.column.DecoratorContext;
import com.terraforged.api.material.state.States; import com.terraforged.api.material.state.States;
import net.minecraft.world.chunk.IChunk; import net.minecraft.world.chunk.IChunk;
public class ChunkPopulator implements ColumnDecorator { public class BaseDecorator implements ColumnDecorator {
public static final ChunkPopulator INSTANCE = new ChunkPopulator(); public static final BaseDecorator INSTANCE = new BaseDecorator();
@Override @Override
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) { public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
if (context.cell.terrain == context.terrains.volcanoPipe && context.cell.riverMask > 0.25F) { if (context.cell.terrain == context.terrains.volcanoPipe && context.cell.riverMask > 0.5F) {
int lavaStart = Math.max(context.levels.waterY + 10, y - 30); int lavaStart = Math.max(context.levels.waterY + 10, y - 30);
int lavaEnd = Math.max(5, context.levels.waterY - 10); int lavaEnd = Math.max(5, context.levels.waterY - 10);
fillDown(context, chunk, x, z, lavaStart, lavaEnd, States.LAVA.get()); fillDown(context, chunk, x, z, lavaStart, lavaEnd, States.LAVA.get());

View File

@ -75,7 +75,7 @@ public class ErosionDecorator implements ColumnDecorator {
@Override @Override
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) { public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
if (context.cell.value < minY || context.cell.terrain == terrain.river || context.cell.terrain == terrain.riverBanks) { if (context.cell.value < minY || context.cell.terrain.isRiver() || context.cell.terrain.isWetland()) {
return; return;
} }
@ -179,10 +179,10 @@ public class ErosionDecorator implements ColumnDecorator {
} }
if (state.getMaterial() == Material.SAND) { if (state.getMaterial() == Material.SAND) {
if (state.getBlock() == Blocks.SAND) { if (state.getBlock() == Blocks.SAND) {
return States.SANDSTONE.get(); return States.SMOOTH_SANDSTONE.get();
} }
if (state.getBlock() == Blocks.RED_SAND) { if (state.getBlock() == Blocks.RED_SAND) {
return States.RED_SANDSTONE.get(); return States.SMOOTH_RED_SANDSTONE.get();
} }
} }
return States.COARSE_DIRT.get(); return States.COARSE_DIRT.get();

View File

@ -2,7 +2,7 @@ package com.terraforged.chunk.generator;
import com.terraforged.api.chunk.column.DecoratorContext; import com.terraforged.api.chunk.column.DecoratorContext;
import com.terraforged.chunk.TerraChunkGenerator; import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.chunk.column.ChunkPopulator; import com.terraforged.chunk.column.BaseDecorator;
import com.terraforged.chunk.util.FastChunk; import com.terraforged.chunk.util.FastChunk;
import com.terraforged.chunk.util.TerraContainer; import com.terraforged.chunk.util.TerraContainer;
import com.terraforged.core.tile.chunk.ChunkReader; import com.terraforged.core.tile.chunk.ChunkReader;
@ -40,7 +40,7 @@ public class TerrainGenerator implements Generator.Terrain {
int py = ctx.levels.scale(cell.value); int py = ctx.levels.scale(cell.value);
ctx.cell = cell; ctx.cell = cell;
ctx.biome = container.getNoiseBiome(dx, world.getSeaLevel(), dz); ctx.biome = container.getNoiseBiome(dx, world.getSeaLevel(), dz);
ChunkPopulator.INSTANCE.decorate(ctx.chunk, ctx, px, py, pz); BaseDecorator.INSTANCE.decorate(ctx.chunk, ctx, px, py, pz);
}); });
terrainHelper.flatten(world, chunk); terrainHelper.flatten(world, chunk);
} }

View File

@ -25,7 +25,9 @@
package com.terraforged.chunk.settings; package com.terraforged.chunk.settings;
import com.terraforged.biome.modifier.MountainModifier;
import com.terraforged.core.serialization.annotation.Comment; import com.terraforged.core.serialization.annotation.Comment;
import com.terraforged.core.serialization.annotation.Range;
import com.terraforged.core.serialization.annotation.Serializable; import com.terraforged.core.serialization.annotation.Serializable;
@Serializable @Serializable
@ -48,4 +50,11 @@ public class Miscellaneous {
@Comment("Controls whether vanilla lakes & springs should generate") @Comment("Controls whether vanilla lakes & springs should generate")
public boolean vanillaWaterFeatures = false; public boolean vanillaWaterFeatures = false;
@Comment({
"The probability that mountainous terrain will be set to a mountain biome type.",
"This may help improve compatibility with mods that rely exclusively on mountain biomes."
})
@Range(min = 0F, max = 1F)
public float mountainBiomeUsage = MountainModifier.MOUNTAIN_CHANCE;
} }

View File

@ -31,7 +31,7 @@ import com.terraforged.core.settings.Settings;
@Serializable @Serializable
public class TerraSettings extends Settings { public class TerraSettings extends Settings {
public Miscellaneous features = new Miscellaneous(); public Miscellaneous miscellaneous = new Miscellaneous();
public StructureSettings structures = new StructureSettings(); public StructureSettings structures = new StructureSettings();

View File

@ -25,20 +25,24 @@
package com.terraforged.chunk.test; package com.terraforged.chunk.test;
import com.terraforged.biome.ModBiomes;
import com.terraforged.world.terrain.Terrain; import com.terraforged.world.terrain.Terrain;
import com.terraforged.world.terrain.Terrains; import com.terraforged.world.terrain.Terrains;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
public class Test { public class Test {
public static boolean fixedBiome = false; public static boolean fixedBiome = false;
public static int getTerrainVariant() {
return 0;
}
public static Terrain getTerrainType(Terrains terrains) { public static Terrain getTerrainType(Terrains terrains) {
return terrains.badlands; return terrains.mountains;
} }
public static Biome getBiome() { public static Biome getBiome() {
return Biomes.BADLANDS; return ModBiomes.TAIGA_SCRUB;
} }
} }

View File

@ -1,6 +1,7 @@
package com.terraforged.chunk.test; package com.terraforged.chunk.test;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.cell.Populator;
import com.terraforged.world.GeneratorContext; import com.terraforged.world.GeneratorContext;
import com.terraforged.world.heightmap.Heightmap; import com.terraforged.world.heightmap.Heightmap;
import com.terraforged.world.terrain.Terrains; import com.terraforged.world.terrain.Terrains;
@ -12,16 +13,20 @@ public class TestHeightMap extends Heightmap {
public TestHeightMap(GeneratorContext context) { public TestHeightMap(GeneratorContext context) {
super(context); super(context);
terrains = context.terrain; terrains = context.terrain;
System.out.println("TESTETETEST");
} }
@Override @Override
public void apply(Cell cell, float x, float y) { public void applyBase(Cell cell, float x, float y) {
super.apply(cell, x, y); continentGenerator.apply(cell, x, y);
getPopulator(Test.getTerrainType(terrains)).apply(cell, x, y); regionModule.apply(cell, x, y);
}
@Override Populator populator = getPopulator(Test.getTerrainType(terrains), Test.getTerrainVariant());
public void tag(Cell cell, float x, float y) { if (populator == this) {
getPopulator(Test.getTerrainType(terrains)).tag(cell, x, y); return;
}
populator.apply(cell, x, y);
applyClimate(cell, x, y);
} }
} }

View File

@ -48,7 +48,7 @@ public class ConfigManager {
set( set(
cfg, cfg,
"batching", "batching",
true, PerfDefaults.BATCHING,
"Batching breaks heightmap tiles up into smaller pieces that can be generated concurrently.", "Batching breaks heightmap tiles up into smaller pieces that can be generated concurrently.",
"This can help improve generation speed by utilizing more threads.", "This can help improve generation speed by utilizing more threads.",
"It is more effective when a higher thread count (+6) is available." "It is more effective when a higher thread count (+6) is available."

View File

@ -6,6 +6,7 @@ import com.terraforged.core.concurrent.thread.ThreadPools;
public class PerfDefaults { public class PerfDefaults {
public static final boolean BATCHING = false;
public static final int TILE_SIZE = 3; public static final int TILE_SIZE = 3;
public static final int BATCH_COUNT = 6; public static final int BATCH_COUNT = 6;
public static final int THREAD_COUNT = ThreadPools.defaultPoolSize(); public static final int THREAD_COUNT = ThreadPools.defaultPoolSize();
@ -16,7 +17,7 @@ public class PerfDefaults {
private static boolean isUsingDefaultPerfSettings(CommentedConfig config) { private static boolean isUsingDefaultPerfSettings(CommentedConfig config) {
boolean yes = true; boolean yes = true;
yes &= config.getOrElse("batching", true); yes &= config.getOrElse("batching", BATCHING);
yes &= config.getInt("thread_count") == THREAD_COUNT; yes &= config.getInt("thread_count") == THREAD_COUNT;
yes &= config.getInt("batch_count") == BATCH_COUNT; yes &= config.getInt("batch_count") == BATCH_COUNT;
yes &= config.getInt("tile_size") == TILE_SIZE; yes &= config.getInt("tile_size") == TILE_SIZE;
@ -29,7 +30,7 @@ public class PerfDefaults {
Log.info("Performance Settings [default={}]", defaults); Log.info("Performance Settings [default={}]", defaults);
Log.info(" - Thread Count: {}", config.getInt("thread_count")); Log.info(" - Thread Count: {}", config.getInt("thread_count"));
Log.info(" - Tile Size: {}", config.getInt("tile_size")); Log.info(" - Tile Size: {}", config.getInt("tile_size"));
Log.info(" - Batching: {}", config.getOrElse("batching", true)); Log.info(" - Batching: {}", config.getOrElse("batching", BATCHING));
Log.info(" - Batch Count: {}", config.getInt("batch_count")); Log.info(" - Batch Count: {}", config.getInt("batch_count"));
return config; return config;
} }

View File

@ -55,7 +55,7 @@ public class DataGen {
} }
protected static void write(JsonElement json, Writer writer) { protected static void write(JsonElement json, Writer writer) {
new GsonBuilder().setPrettyPrinting().create().toJson(json, writer); new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(json, writer);
} }
protected static String getJsonPath(String type, ResourceLocation location) { protected static String getJsonPath(String type, ResourceLocation location) {

View File

@ -125,7 +125,7 @@ public class SaplingListener {
ChunkGenerator<?> generator = serverWorld.getChunkProvider().generator; ChunkGenerator<?> generator = serverWorld.getChunkProvider().generator;
if (generator instanceof TerraChunkGenerator) { if (generator instanceof TerraChunkGenerator) {
TerraContext context = ((TerraChunkGenerator) generator).getContext(); TerraContext context = ((TerraChunkGenerator) generator).getContext();
if (context.terraSettings.features.customBiomeFeatures) { if (context.terraSettings.miscellaneous.customBiomeFeatures) {
return Optional.of(((TerraChunkGenerator) generator).getBlockDataManager()); return Optional.of(((TerraChunkGenerator) generator).getBlockDataManager());
} }
} }

View File

@ -68,7 +68,7 @@ public class SettingsScreen extends OverlayScreen {
new SimplePreviewPage("River Settings", "rivers", preview, instance, s -> s.rivers), new SimplePreviewPage("River Settings", "rivers", preview, instance, s -> s.rivers),
new SimplePreviewPage("Filter Settings", "filters", preview, instance, s -> s.filters), new SimplePreviewPage("Filter Settings", "filters", preview, instance, s -> s.filters),
new SimplePage("Structure Settings", "structures", instance, s -> s.structures), new SimplePage("Structure Settings", "structures", instance, s -> s.structures),
new SimplePage("Feature Settings", "features", instance, s -> s.features) new SimplePage("Feature Settings", "miscellaneous", instance, s -> s.miscellaneous)
}; };
} }

View File

@ -56,6 +56,13 @@ public class PresetsPage extends BasePage {
right.scrollPane.addButton(nameInput); right.scrollPane.addButton(nameInput);
right.scrollPane.addButton(new TerraButton("Create") { right.scrollPane.addButton(new TerraButton("Create") {
@Override
public void render(int x, int z, float ticks) {
super.active = !nameInput.getValue().isEmpty();
super.render(x, z, ticks);
}
@Override @Override
public void onClick(double x, double y) { public void onClick(double x, double y) {
super.onClick(x, y); super.onClick(x, y);

View File

@ -146,7 +146,7 @@ public class Preview extends Button {
return; return;
} }
RenderMode renderer = previewSettings.mode; RenderMode renderer = previewSettings.display;
Levels levels = new Levels(settings.world); Levels levels = new Levels(settings.world);
int stroke = 2; int stroke = 2;

View File

@ -37,5 +37,5 @@ public class PreviewSettings {
public int zoom = 100 - 32; public int zoom = 100 - 32;
@Comment("Controls the rendering mode on the preview map") @Comment("Controls the rendering mode on the preview map")
public RenderMode mode = RenderMode.BIOME_TYPE; public RenderMode display = RenderMode.BIOME_TYPE;
} }

View File

@ -1,6 +1,9 @@
{ {
"biomes": [ "biomes": [
"minecraft:plains" "minecraft:plains",
"minecraft:sunflower_plains",
"minecraft:mountains",
"minecraft:mountain_edge"
], ],
"stage": "VEGETAL_DECORATION", "stage": "VEGETAL_DECORATION",
"prepend": { "prepend": {

View File

@ -3,6 +3,11 @@
"minecraft:snowy_tundra", "minecraft:snowy_tundra",
"minecraft:taiga", "minecraft:taiga",
"minecraft:taiga_hills", "minecraft:taiga_hills",
"minecraft:wooded_mountains",
"minecraft:taiga_mountains",
"minecraft:snowy_taiga_mountains",
"minecraft:gravelly_mountains",
"minecraft:modified_gravelly_mountains",
"terraforged:taiga_scrub", "terraforged:taiga_scrub",
"terraforged:snowy_taiga_scrub" "terraforged:snowy_taiga_scrub"
], ],

View File

@ -2,7 +2,9 @@
"biomes": [ "biomes": [
"minecraft:river", "minecraft:river",
"minecraft:plains", "minecraft:plains",
"minecraft:sunflower_plains" "minecraft:sunflower_plains",
"minecraft:mountains",
"minecraft:mountain_edge"
], ],
"match": [ "match": [
[ [

View File

@ -2,7 +2,7 @@
"biomes": [ "biomes": [
"minecraft:snowy_taiga", "minecraft:snowy_taiga",
"minecraft:snowy_taiga_hills", "minecraft:snowy_taiga_hills",
"minecraft:snowy_taiga_mountains" "minecraft:taiga_mountains"
], ],
"match": [ "match": [
[ [

View File

@ -1,13 +1,21 @@
{ {
"biomes": [ "biomes": [
"minecraft:snowy_tundra", "minecraft:snowy_tundra",
"minecraft:wooded_mountains" "minecraft:snowy_taiga_mountains",
"minecraft:wooded_mountains",
"minecraft:gravelly_mountains",
"minecraft:modified_gravelly_mountains"
], ],
"match": [ "match": [
[ [
"minecraft:normal_tree", "minecraft:normal_tree",
"minecraft:spruce_log", "minecraft:spruce_log",
"minecraft:spruce_leaves" "minecraft:spruce_leaves"
],
[
"minecraft:fancy_tree",
"minecraft:spruce_log",
"minecraft:spruce_leaves"
] ]
], ],
"replace": { "replace": {