From c6daeb7ce109b93433ebfcbeaa5233b6ee3f5bd8 Mon Sep 17 00:00:00 2001 From: dags- Date: Tue, 23 Jun 2020 12:41:40 +0100 Subject: [PATCH] - apparently smooth sandstone is a thing - support mountain biomes --- Engine | 2 +- .../assets/terraforged/lang/en_us.json | 30 ++++++------ .../api/biome/modifier/BiomeModifier.java | 2 +- .../api/material/state/States.java | 4 +- .../com/terraforged/biome/map/BiomeMap.java | 6 +++ .../biome/map/BiomeMapBuilder.java | 8 ++++ .../terraforged/biome/map/SimpleBiomeMap.java | 18 +++++++- .../biome/map/defaults/BiomeTemps.java | 7 +++ .../biome/map/defaults/DefaultBiome.java | 3 ++ .../biome/map/defaults/DefaultBiomes.java | 10 ++++ .../biome/map/set/TemperatureSet.java | 5 +- .../biome/modifier/BeachModifier.java | 18 +++----- .../biome/modifier/BiomeModifierManager.java | 5 +- .../biome/modifier/CoastModifier.java | 4 +- .../biome/modifier/DesertColorModifier.java | 2 +- .../biome/modifier/MountainModifier.java | 46 +++++++++++++++++++ .../biome/provider/BiomeHelper.java | 16 +++++++ .../biome/surface/DesertSurface.java | 2 +- .../terraforged/chunk/TerraSetupFactory.java | 16 +++---- ...ChunkPopulator.java => BaseDecorator.java} | 6 +-- .../chunk/column/ErosionDecorator.java | 6 +-- .../chunk/generator/TerrainGenerator.java | 4 +- .../chunk/settings/Miscellaneous.java | 9 ++++ .../chunk/settings/TerraSettings.java | 2 +- .../java/com/terraforged/chunk/test/Test.java | 10 ++-- .../terraforged/chunk/test/TestHeightMap.java | 19 +++++--- .../com/terraforged/config/ConfigManager.java | 2 +- .../com/terraforged/config/PerfDefaults.java | 5 +- .../java/com/terraforged/data/DataGen.java | 2 +- .../feature/sapling/SaplingListener.java | 2 +- .../com/terraforged/gui/SettingsScreen.java | 2 +- .../com/terraforged/gui/page/PresetsPage.java | 7 +++ .../com/terraforged/gui/preview/Preview.java | 2 +- .../gui/preview/PreviewSettings.java | 2 +- .../features/shrubs/plains_bush.json | 5 +- .../features/shrubs/taiga_scrub_bush.json | 5 ++ .../features/trees/oak_plains.json | 4 +- .../terraforged/features/trees/spruce.json | 2 +- .../features/trees/spruce_tundra.json | 10 +++- 39 files changed, 234 insertions(+), 76 deletions(-) create mode 100644 src/main/java/com/terraforged/biome/map/defaults/BiomeTemps.java create mode 100644 src/main/java/com/terraforged/biome/modifier/MountainModifier.java rename src/main/java/com/terraforged/chunk/column/{ChunkPopulator.java => BaseDecorator.java} (92%) diff --git a/Engine b/Engine index 0d0aea5..a28088b 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit 0d0aea5be29a0128d5033bdd2bcd33a3396f5528 +Subproject commit a28088b543d0457cd71f6f52aa7096b01180c5b8 diff --git a/generated/resources/assets/terraforged/lang/en_us.json b/generated/resources/assets/terraforged/lang/en_us.json index f23509e..1ebfb70 100644 --- a/generated/resources/assets/terraforged/lang/en_us.json +++ b/generated/resources/assets/terraforged/lang/en_us.json @@ -25,6 +25,7 @@ "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_strength": "Biome Warp Strength", + "display.terraforged.climate.biome_shape.macro_noise_size": "Macro Noise Size", "display.terraforged.climate.moisture": "Moisture", "display.terraforged.climate.moisture.bias": "Bias", "display.terraforged.climate.moisture.falloff": "Falloff", @@ -45,13 +46,6 @@ "display.terraforged.dimensions.dimensions": "Dimensions", "display.terraforged.dimensions.dimensions.end": "End", "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.erosion": "Erosion", "display.terraforged.filters.erosion.deposite_rate": "Deposite Rate", @@ -64,6 +58,14 @@ "display.terraforged.filters.smoothing.iterations": "Iterations", "display.terraforged.filters.smoothing.smoothing_radius": "Smoothing Radius", "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.display": "Display", "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_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.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.falloff": "How quickly values transition from an extremity", "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.dimensions.end": "Select the end 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.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", @@ -219,6 +216,13 @@ "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_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.bed_depth": "Controls the depth of the river", "tooltip.terraforged.rivers.primary_rivers.bed_width": "Controls the river-bed width", diff --git a/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java b/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java index 18e3a9a..adb2460 100644 --- a/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java +++ b/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java @@ -32,7 +32,7 @@ public interface BiomeModifier extends Comparable { int priority(); - boolean test(Biome biome); + boolean test(Biome biome, Cell cell); Biome modify(Biome in, Cell cell, int x, int z); diff --git a/src/main/java/com/terraforged/api/material/state/States.java b/src/main/java/com/terraforged/api/material/state/States.java index c3e2e85..4399e80 100644 --- a/src/main/java/com/terraforged/api/material/state/States.java +++ b/src/main/java/com/terraforged/api/material/state/States.java @@ -35,9 +35,9 @@ public class States { public static final StateSupplier GRAVEL = DefaultState.of("minecraft:gravel").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 RED_SANDSTONE = DefaultState.of("minecraft:red_sandstone").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 STONE = DefaultState.of("minecraft:stone").cache(); public static final StateSupplier WATER = DefaultState.of("minecraft:water").cache(); diff --git a/src/main/java/com/terraforged/biome/map/BiomeMap.java b/src/main/java/com/terraforged/biome/map/BiomeMap.java index 482fdd9..69f9a17 100644 --- a/src/main/java/com/terraforged/biome/map/BiomeMap.java +++ b/src/main/java/com/terraforged/biome/map/BiomeMap.java @@ -31,6 +31,7 @@ import com.terraforged.world.biome.BiomeType; import com.terraforged.world.heightmap.Levels; import net.minecraft.world.biome.Biome; +import javax.annotation.Nullable; import java.util.List; public interface BiomeMap { @@ -51,6 +52,9 @@ public interface BiomeMap { Biome getLand(Cell cell); + @Nullable + Biome getMountain(Cell cell); + Biome provideBiome(Cell cell, Levels levels); List getAllBiomes(BiomeType type); @@ -71,6 +75,8 @@ public interface BiomeMap { Builder addWetland(Biome biome, int count); + Builder addMountain(Biome biome, int count); + Builder addLand(BiomeType type, Biome biome, int count); BiomeMap build(); diff --git a/src/main/java/com/terraforged/biome/map/BiomeMapBuilder.java b/src/main/java/com/terraforged/biome/map/BiomeMapBuilder.java index 61d6f6f..bb78f44 100644 --- a/src/main/java/com/terraforged/biome/map/BiomeMapBuilder.java +++ b/src/main/java/com/terraforged/biome/map/BiomeMapBuilder.java @@ -45,6 +45,7 @@ public class BiomeMapBuilder implements BiomeMap.Builder { protected final Map> beaches = new HashMap<>(); protected final Map> oceans = new HashMap<>(); protected final Map> deepOceans = new HashMap<>(); + protected final Map> mountains = new HashMap<>(); protected final Map> map = new EnumMap<>(BiomeType.class); private final Function constructor; @@ -99,6 +100,13 @@ public class BiomeMapBuilder implements BiomeMap.Builder { 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 public BiomeMapBuilder addLand(BiomeType type, Biome biome, int count) { add(map.computeIfAbsent(type, t -> new ArrayList<>()), biome, count); diff --git a/src/main/java/com/terraforged/biome/map/SimpleBiomeMap.java b/src/main/java/com/terraforged/biome/map/SimpleBiomeMap.java index 30a6b3c..311754b 100644 --- a/src/main/java/com/terraforged/biome/map/SimpleBiomeMap.java +++ b/src/main/java/com/terraforged/biome/map/SimpleBiomeMap.java @@ -28,6 +28,7 @@ public class SimpleBiomeMap implements BiomeMap { private final BiomeSet lake; private final BiomeSet wetland; private final BiomeSet land; + private final BiomeSet mountains; private final BiomeSet[] terrainBiomes; public SimpleBiomeMap(BiomeMapBuilder builder) { @@ -38,6 +39,7 @@ public class SimpleBiomeMap implements BiomeMap { river = new RiverSet(builder.rivers, DefaultBiomes::defaultRiver, this); lake = new TemperatureSet(builder.lakes, DefaultBiomes::defaultLake); wetland = new TemperatureSet(builder.wetlands, DefaultBiomes::defaultWetland); + mountains = new TemperatureSet(builder.mountains, DefaultBiomes::defaultMountain); land = new BiomeTypeSet(builder.map, DefaultBiomes::defaultBiome); terrainBiomes = new BiomeSet[TerrainType.values().length]; terrainBiomes[TerrainType.SHALLOW_OCEAN.ordinal()] = shallowOcean; @@ -102,6 +104,11 @@ public class SimpleBiomeMap implements BiomeMap { return wetland.getBiome(cell); } + @Override + public Biome getMountain(Cell cell) { + return mountains.getBiome(cell); + } + @Override public Biome getLand(Cell cell) { return land.getBiome(cell); @@ -109,6 +116,9 @@ public class SimpleBiomeMap implements BiomeMap { @Override public List getAllBiomes(BiomeType type) { + if (type == BiomeType.ALPINE) { + return Collections.emptyList(); + } int size = land.getSize(type.ordinal()); if (size == 0) { return Collections.emptyList(); @@ -126,7 +136,13 @@ public class SimpleBiomeMap implements BiomeMap { root.add("RIVER", river.toJson()); root.add("LAKE", lake.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; } } diff --git a/src/main/java/com/terraforged/biome/map/defaults/BiomeTemps.java b/src/main/java/com/terraforged/biome/map/defaults/BiomeTemps.java new file mode 100644 index 0000000..581b529 --- /dev/null +++ b/src/main/java/com/terraforged/biome/map/defaults/BiomeTemps.java @@ -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; +} diff --git a/src/main/java/com/terraforged/biome/map/defaults/DefaultBiome.java b/src/main/java/com/terraforged/biome/map/defaults/DefaultBiome.java index 4472694..cbc9081 100644 --- a/src/main/java/com/terraforged/biome/map/defaults/DefaultBiome.java +++ b/src/main/java/com/terraforged/biome/map/defaults/DefaultBiome.java @@ -1,9 +1,12 @@ package com.terraforged.biome.map.defaults; import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.OceanBiome; public interface DefaultBiome { + Biome NONE = new OceanBiome().setRegistryName("terraforged", "none"); + Biome getBiome(float temperature); default Biome getDefaultBiome(float temperature) { diff --git a/src/main/java/com/terraforged/biome/map/defaults/DefaultBiomes.java b/src/main/java/com/terraforged/biome/map/defaults/DefaultBiomes.java index d73b8df..1cef1cc 100644 --- a/src/main/java/com/terraforged/biome/map/defaults/DefaultBiomes.java +++ b/src/main/java/com/terraforged/biome/map/defaults/DefaultBiomes.java @@ -57,6 +57,16 @@ public class DefaultBiomes { 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) { if (temperature < 0.3) { return ModBiomes.TAIGA_SCRUB; diff --git a/src/main/java/com/terraforged/biome/map/set/TemperatureSet.java b/src/main/java/com/terraforged/biome/map/set/TemperatureSet.java index be8ff48..285fc26 100644 --- a/src/main/java/com/terraforged/biome/map/set/TemperatureSet.java +++ b/src/main/java/com/terraforged/biome/map/set/TemperatureSet.java @@ -3,6 +3,7 @@ package com.terraforged.biome.map.set; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.terraforged.biome.map.defaults.BiomeTemps; import com.terraforged.biome.map.defaults.DefaultBiome; import com.terraforged.core.cell.Cell; import net.minecraft.world.biome.Biome; @@ -20,10 +21,10 @@ public class TemperatureSet extends BiomeSet { @Override public int getIndex(Cell cell) { - if (cell.temperature < 0.25) { + if (cell.temperature < BiomeTemps.COLD) { return 0; } - if (cell.temperature > 0.75) { + if (cell.temperature > BiomeTemps.HOT) { return 2; } return 1; diff --git a/src/main/java/com/terraforged/biome/modifier/BeachModifier.java b/src/main/java/com/terraforged/biome/modifier/BeachModifier.java index 6d869fc..38a797a 100644 --- a/src/main/java/com/terraforged/biome/modifier/BeachModifier.java +++ b/src/main/java/com/terraforged/biome/modifier/BeachModifier.java @@ -7,7 +7,7 @@ import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; import com.terraforged.world.GeneratorContext; 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.Biomes; @@ -16,11 +16,9 @@ public class BeachModifier implements BiomeModifier { private final float height; private final Module noise; private final BiomeMap biomes; - private final Terrains terrains; public BeachModifier(BiomeMap biomeMap, GeneratorContext context) { this.biomes = biomeMap; - this.terrains = context.terrain; this.height = context.levels.water(6); this.noise = Source.perlin(context.seed.next(), 10, 1).scale(context.levels.scale(5)); } @@ -31,19 +29,17 @@ public class BeachModifier implements BiomeModifier { } @Override - public boolean test(Biome biome) { - return true; + public boolean test(Biome biome, Cell cell) { + return cell.terrain.getType() == TerrainType.BEACH && cell.biomeType != BiomeType.DESERT; } @Override 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 (in == Biomes.MUSHROOM_FIELDS) { - return Biomes.MUSHROOM_FIELD_SHORE; - } - return biomes.getBeach(cell); + if (cell.value + noise.getValue(x, z) < height) { + if (in == Biomes.MUSHROOM_FIELDS) { + return Biomes.MUSHROOM_FIELD_SHORE; } + return biomes.getBeach(cell); } return in; } diff --git a/src/main/java/com/terraforged/biome/modifier/BiomeModifierManager.java b/src/main/java/com/terraforged/biome/modifier/BiomeModifierManager.java index dc5219e..5e039fb 100644 --- a/src/main/java/com/terraforged/biome/modifier/BiomeModifierManager.java +++ b/src/main/java/com/terraforged/biome/modifier/BiomeModifierManager.java @@ -50,6 +50,7 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager { modifiers.add(new CoastModifier(biomes, context)); modifiers.add(new DesertColorModifier(desertBiomes)); modifiers.add(new BeachModifier(biomes, context)); + modifiers.add(new MountainModifier(context, biomes)); Collections.sort(modifiers); this.biomeModifiers = modifiers; } @@ -74,14 +75,14 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager { } @Override - public boolean test(Biome biome) { + public boolean test(Biome biome, Cell cell) { return true; } @Override public Biome modify(Biome biome, Cell cell, int x, int z) { for (BiomeModifier modifier : biomeModifiers) { - if (modifier.test(biome)) { + if (modifier.test(biome, cell)) { biome = modifier.modify(biome, cell, x, z); if (modifier.exitEarly()) { return biome; diff --git a/src/main/java/com/terraforged/biome/modifier/CoastModifier.java b/src/main/java/com/terraforged/biome/modifier/CoastModifier.java index ba95d13..f3a117f 100644 --- a/src/main/java/com/terraforged/biome/modifier/CoastModifier.java +++ b/src/main/java/com/terraforged/biome/modifier/CoastModifier.java @@ -50,8 +50,8 @@ public class CoastModifier implements BiomeModifier { } @Override - public boolean test(Biome biome) { - return true; + public boolean test(Biome biome, Cell cell) { + return cell.terrain.isCoast(); } @Override diff --git a/src/main/java/com/terraforged/biome/modifier/DesertColorModifier.java b/src/main/java/com/terraforged/biome/modifier/DesertColorModifier.java index bd15d0e..046e12d 100644 --- a/src/main/java/com/terraforged/biome/modifier/DesertColorModifier.java +++ b/src/main/java/com/terraforged/biome/modifier/DesertColorModifier.java @@ -49,7 +49,7 @@ public class DesertColorModifier implements BiomeModifier { } @Override - public boolean test(Biome biome) { + public boolean test(Biome biome, Cell cell) { return biome.getCategory() == Biome.Category.DESERT || biome.getCategory() == Biome.Category.MESA || biomes.isDesert(biome); diff --git a/src/main/java/com/terraforged/biome/modifier/MountainModifier.java b/src/main/java/com/terraforged/biome/modifier/MountainModifier.java new file mode 100644 index 0000000..c7d1e2c --- /dev/null +++ b/src/main/java/com/terraforged/biome/modifier/MountainModifier.java @@ -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; + } +} diff --git a/src/main/java/com/terraforged/biome/provider/BiomeHelper.java b/src/main/java/com/terraforged/biome/provider/BiomeHelper.java index ec63de3..3b547c3 100644 --- a/src/main/java/com/terraforged/biome/provider/BiomeHelper.java +++ b/src/main/java/com/terraforged/biome/provider/BiomeHelper.java @@ -89,9 +89,15 @@ public class BiomeHelper { builder.addLake(biome, weight); } else if (BiomePredicate.WETLAND.test(data)) { builder.addWetland(biome, weight); + } else if (BiomePredicate.MOUNTAIN.test(data)) { + builder.addMountain(biome, weight); } else { Collection types = getTypes(data, biome); for (BiomeType type : types) { + // shouldn't happen + if (type == BiomeType.ALPINE) { + continue; + } builder.addLand(type, biome, weight); } } @@ -129,6 +135,16 @@ public class BiomeHelper { 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) { ResourceLocation name = biome.getRegistryName(); if (name == null) { diff --git a/src/main/java/com/terraforged/biome/surface/DesertSurface.java b/src/main/java/com/terraforged/biome/surface/DesertSurface.java index 71afef4..7f10c62 100644 --- a/src/main/java/com/terraforged/biome/surface/DesertSurface.java +++ b/src/main/java/com/terraforged/biome/surface/DesertSurface.java @@ -14,7 +14,7 @@ public class DesertSurface implements Surface { private final float min; private final float level; 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 mid = Blocks.ORANGE_TERRACOTTA.delegate.get().getDefaultState(); private final BlockState high = Blocks.BROWN_TERRACOTTA.delegate.get().getDefaultState(); diff --git a/src/main/java/com/terraforged/chunk/TerraSetupFactory.java b/src/main/java/com/terraforged/chunk/TerraSetupFactory.java index 27cbd03..43700cb 100644 --- a/src/main/java/com/terraforged/chunk/TerraSetupFactory.java +++ b/src/main/java/com/terraforged/chunk/TerraSetupFactory.java @@ -46,11 +46,11 @@ public class TerraSetupFactory { public static List createBaseDecorators(GeoManager geoManager, TerraContext context) { List processors = new ArrayList<>(); - if (context.terraSettings.features.strataDecorator) { + if (context.terraSettings.miscellaneous.strataDecorator) { Log.info(" - Geology decorator enabled"); processors.add(new GeologyDecorator(geoManager)); } - if (context.terraSettings.features.erosionDecorator) { + if (context.terraSettings.miscellaneous.erosionDecorator) { Log.info(" - Erosion decorator enabled"); processors.add(new ErosionDecorator(context)); } @@ -60,11 +60,11 @@ public class TerraSetupFactory { public static List createFeatureDecorators(TerraContext context) { List processors = new ArrayList<>(); - if (context.terraSettings.features.naturalSnowDecorator) { + if (context.terraSettings.miscellaneous.naturalSnowDecorator) { Log.info(" - Natural snow decorator enabled"); processors.add(new SnowEroder(context)); } - if (context.terraSettings.features.smoothLayerDecorator) { + if (context.terraSettings.miscellaneous.smoothLayerDecorator) { Log.info(" - Smooth layer decorator enabled"); processors.add(new LayerDecorator(context.materials.getLayerManager())); } @@ -76,20 +76,20 @@ public class TerraSetupFactory { } 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 modifiers.getPredicates().add(Matchers.stoneBlobs(), FeaturePredicate.DENY); } - if (!context.terraSettings.features.vanillaWaterFeatures) { + if (!context.terraSettings.miscellaneous.vanillaWaterFeatures) { // block lakes and springs if not enabled modifiers.getPredicates().add(FeatureMatcher.of(Feature.LAKE), 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 modifiers.getPredicates().add(BiomeMatcher.of(Biome.Category.RIVER), Matchers.tree(), FeaturePredicate.DENY); diff --git a/src/main/java/com/terraforged/chunk/column/ChunkPopulator.java b/src/main/java/com/terraforged/chunk/column/BaseDecorator.java similarity index 92% rename from src/main/java/com/terraforged/chunk/column/ChunkPopulator.java rename to src/main/java/com/terraforged/chunk/column/BaseDecorator.java index 9377ec8..7124157 100644 --- a/src/main/java/com/terraforged/chunk/column/ChunkPopulator.java +++ b/src/main/java/com/terraforged/chunk/column/BaseDecorator.java @@ -30,13 +30,13 @@ import com.terraforged.api.chunk.column.DecoratorContext; import com.terraforged.api.material.state.States; 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 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 lavaEnd = Math.max(5, context.levels.waterY - 10); fillDown(context, chunk, x, z, lavaStart, lavaEnd, States.LAVA.get()); diff --git a/src/main/java/com/terraforged/chunk/column/ErosionDecorator.java b/src/main/java/com/terraforged/chunk/column/ErosionDecorator.java index af48a03..02a8f19 100644 --- a/src/main/java/com/terraforged/chunk/column/ErosionDecorator.java +++ b/src/main/java/com/terraforged/chunk/column/ErosionDecorator.java @@ -75,7 +75,7 @@ public class ErosionDecorator implements ColumnDecorator { @Override 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; } @@ -179,10 +179,10 @@ public class ErosionDecorator implements ColumnDecorator { } if (state.getMaterial() == Material.SAND) { if (state.getBlock() == Blocks.SAND) { - return States.SANDSTONE.get(); + return States.SMOOTH_SANDSTONE.get(); } if (state.getBlock() == Blocks.RED_SAND) { - return States.RED_SANDSTONE.get(); + return States.SMOOTH_RED_SANDSTONE.get(); } } return States.COARSE_DIRT.get(); diff --git a/src/main/java/com/terraforged/chunk/generator/TerrainGenerator.java b/src/main/java/com/terraforged/chunk/generator/TerrainGenerator.java index 4e0cc52..691580b 100644 --- a/src/main/java/com/terraforged/chunk/generator/TerrainGenerator.java +++ b/src/main/java/com/terraforged/chunk/generator/TerrainGenerator.java @@ -2,7 +2,7 @@ package com.terraforged.chunk.generator; import com.terraforged.api.chunk.column.DecoratorContext; 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.TerraContainer; import com.terraforged.core.tile.chunk.ChunkReader; @@ -40,7 +40,7 @@ public class TerrainGenerator implements Generator.Terrain { int py = ctx.levels.scale(cell.value); ctx.cell = cell; 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); } diff --git a/src/main/java/com/terraforged/chunk/settings/Miscellaneous.java b/src/main/java/com/terraforged/chunk/settings/Miscellaneous.java index 12b4d6b..9124822 100644 --- a/src/main/java/com/terraforged/chunk/settings/Miscellaneous.java +++ b/src/main/java/com/terraforged/chunk/settings/Miscellaneous.java @@ -25,7 +25,9 @@ package com.terraforged.chunk.settings; +import com.terraforged.biome.modifier.MountainModifier; import com.terraforged.core.serialization.annotation.Comment; +import com.terraforged.core.serialization.annotation.Range; import com.terraforged.core.serialization.annotation.Serializable; @Serializable @@ -48,4 +50,11 @@ public class Miscellaneous { @Comment("Controls whether vanilla lakes & springs should generate") 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; } diff --git a/src/main/java/com/terraforged/chunk/settings/TerraSettings.java b/src/main/java/com/terraforged/chunk/settings/TerraSettings.java index 7f487dc..ce5173f 100644 --- a/src/main/java/com/terraforged/chunk/settings/TerraSettings.java +++ b/src/main/java/com/terraforged/chunk/settings/TerraSettings.java @@ -31,7 +31,7 @@ import com.terraforged.core.settings.Settings; @Serializable public class TerraSettings extends Settings { - public Miscellaneous features = new Miscellaneous(); + public Miscellaneous miscellaneous = new Miscellaneous(); public StructureSettings structures = new StructureSettings(); diff --git a/src/main/java/com/terraforged/chunk/test/Test.java b/src/main/java/com/terraforged/chunk/test/Test.java index 07ee78d..e85a013 100644 --- a/src/main/java/com/terraforged/chunk/test/Test.java +++ b/src/main/java/com/terraforged/chunk/test/Test.java @@ -25,20 +25,24 @@ package com.terraforged.chunk.test; +import com.terraforged.biome.ModBiomes; import com.terraforged.world.terrain.Terrain; import com.terraforged.world.terrain.Terrains; import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.Biomes; public class Test { public static boolean fixedBiome = false; + public static int getTerrainVariant() { + return 0; + } + public static Terrain getTerrainType(Terrains terrains) { - return terrains.badlands; + return terrains.mountains; } public static Biome getBiome() { - return Biomes.BADLANDS; + return ModBiomes.TAIGA_SCRUB; } } diff --git a/src/main/java/com/terraforged/chunk/test/TestHeightMap.java b/src/main/java/com/terraforged/chunk/test/TestHeightMap.java index 0fdb2d3..b8e20a6 100644 --- a/src/main/java/com/terraforged/chunk/test/TestHeightMap.java +++ b/src/main/java/com/terraforged/chunk/test/TestHeightMap.java @@ -1,6 +1,7 @@ package com.terraforged.chunk.test; import com.terraforged.core.cell.Cell; +import com.terraforged.core.cell.Populator; import com.terraforged.world.GeneratorContext; import com.terraforged.world.heightmap.Heightmap; import com.terraforged.world.terrain.Terrains; @@ -12,16 +13,20 @@ public class TestHeightMap extends Heightmap { public TestHeightMap(GeneratorContext context) { super(context); terrains = context.terrain; + System.out.println("TESTETETEST"); } @Override - public void apply(Cell cell, float x, float y) { - super.apply(cell, x, y); - getPopulator(Test.getTerrainType(terrains)).apply(cell, x, y); - } + public void applyBase(Cell cell, float x, float y) { + continentGenerator.apply(cell, x, y); + regionModule.apply(cell, x, y); - @Override - public void tag(Cell cell, float x, float y) { - getPopulator(Test.getTerrainType(terrains)).tag(cell, x, y); + Populator populator = getPopulator(Test.getTerrainType(terrains), Test.getTerrainVariant()); + if (populator == this) { + return; + } + + populator.apply(cell, x, y); + applyClimate(cell, x, y); } } diff --git a/src/main/java/com/terraforged/config/ConfigManager.java b/src/main/java/com/terraforged/config/ConfigManager.java index 9bf013e..bfe786b 100644 --- a/src/main/java/com/terraforged/config/ConfigManager.java +++ b/src/main/java/com/terraforged/config/ConfigManager.java @@ -48,7 +48,7 @@ public class ConfigManager { set( cfg, "batching", - true, + PerfDefaults.BATCHING, "Batching breaks heightmap tiles up into smaller pieces that can be generated concurrently.", "This can help improve generation speed by utilizing more threads.", "It is more effective when a higher thread count (+6) is available." diff --git a/src/main/java/com/terraforged/config/PerfDefaults.java b/src/main/java/com/terraforged/config/PerfDefaults.java index dfe9309..e41770c 100644 --- a/src/main/java/com/terraforged/config/PerfDefaults.java +++ b/src/main/java/com/terraforged/config/PerfDefaults.java @@ -6,6 +6,7 @@ import com.terraforged.core.concurrent.thread.ThreadPools; public class PerfDefaults { + public static final boolean BATCHING = false; public static final int TILE_SIZE = 3; public static final int BATCH_COUNT = 6; public static final int THREAD_COUNT = ThreadPools.defaultPoolSize(); @@ -16,7 +17,7 @@ public class PerfDefaults { private static boolean isUsingDefaultPerfSettings(CommentedConfig config) { boolean yes = true; - yes &= config.getOrElse("batching", true); + yes &= config.getOrElse("batching", BATCHING); yes &= config.getInt("thread_count") == THREAD_COUNT; yes &= config.getInt("batch_count") == BATCH_COUNT; yes &= config.getInt("tile_size") == TILE_SIZE; @@ -29,7 +30,7 @@ public class PerfDefaults { Log.info("Performance Settings [default={}]", defaults); Log.info(" - Thread Count: {}", config.getInt("thread_count")); 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")); return config; } diff --git a/src/main/java/com/terraforged/data/DataGen.java b/src/main/java/com/terraforged/data/DataGen.java index a802719..6bfe648 100644 --- a/src/main/java/com/terraforged/data/DataGen.java +++ b/src/main/java/com/terraforged/data/DataGen.java @@ -55,7 +55,7 @@ public class DataGen { } 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) { diff --git a/src/main/java/com/terraforged/feature/sapling/SaplingListener.java b/src/main/java/com/terraforged/feature/sapling/SaplingListener.java index 17972b9..6a777b2 100644 --- a/src/main/java/com/terraforged/feature/sapling/SaplingListener.java +++ b/src/main/java/com/terraforged/feature/sapling/SaplingListener.java @@ -125,7 +125,7 @@ public class SaplingListener { ChunkGenerator generator = serverWorld.getChunkProvider().generator; if (generator instanceof TerraChunkGenerator) { TerraContext context = ((TerraChunkGenerator) generator).getContext(); - if (context.terraSettings.features.customBiomeFeatures) { + if (context.terraSettings.miscellaneous.customBiomeFeatures) { return Optional.of(((TerraChunkGenerator) generator).getBlockDataManager()); } } diff --git a/src/main/java/com/terraforged/gui/SettingsScreen.java b/src/main/java/com/terraforged/gui/SettingsScreen.java index b08b496..7ab6507 100644 --- a/src/main/java/com/terraforged/gui/SettingsScreen.java +++ b/src/main/java/com/terraforged/gui/SettingsScreen.java @@ -68,7 +68,7 @@ public class SettingsScreen extends OverlayScreen { new SimplePreviewPage("River Settings", "rivers", preview, instance, s -> s.rivers), new SimplePreviewPage("Filter Settings", "filters", preview, instance, s -> s.filters), 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) }; } diff --git a/src/main/java/com/terraforged/gui/page/PresetsPage.java b/src/main/java/com/terraforged/gui/page/PresetsPage.java index 6665dec..4ea66e4 100644 --- a/src/main/java/com/terraforged/gui/page/PresetsPage.java +++ b/src/main/java/com/terraforged/gui/page/PresetsPage.java @@ -56,6 +56,13 @@ public class PresetsPage extends BasePage { right.scrollPane.addButton(nameInput); 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 public void onClick(double x, double y) { super.onClick(x, y); diff --git a/src/main/java/com/terraforged/gui/preview/Preview.java b/src/main/java/com/terraforged/gui/preview/Preview.java index da54382..65097c6 100644 --- a/src/main/java/com/terraforged/gui/preview/Preview.java +++ b/src/main/java/com/terraforged/gui/preview/Preview.java @@ -146,7 +146,7 @@ public class Preview extends Button { return; } - RenderMode renderer = previewSettings.mode; + RenderMode renderer = previewSettings.display; Levels levels = new Levels(settings.world); int stroke = 2; diff --git a/src/main/java/com/terraforged/gui/preview/PreviewSettings.java b/src/main/java/com/terraforged/gui/preview/PreviewSettings.java index 2a87a3c..087309a 100644 --- a/src/main/java/com/terraforged/gui/preview/PreviewSettings.java +++ b/src/main/java/com/terraforged/gui/preview/PreviewSettings.java @@ -37,5 +37,5 @@ public class PreviewSettings { public int zoom = 100 - 32; @Comment("Controls the rendering mode on the preview map") - public RenderMode mode = RenderMode.BIOME_TYPE; + public RenderMode display = RenderMode.BIOME_TYPE; } diff --git a/src/main/resources/data/terraforged/features/shrubs/plains_bush.json b/src/main/resources/data/terraforged/features/shrubs/plains_bush.json index 89a178c..4195d80 100644 --- a/src/main/resources/data/terraforged/features/shrubs/plains_bush.json +++ b/src/main/resources/data/terraforged/features/shrubs/plains_bush.json @@ -1,6 +1,9 @@ { "biomes": [ - "minecraft:plains" + "minecraft:plains", + "minecraft:sunflower_plains", + "minecraft:mountains", + "minecraft:mountain_edge" ], "stage": "VEGETAL_DECORATION", "prepend": { diff --git a/src/main/resources/data/terraforged/features/shrubs/taiga_scrub_bush.json b/src/main/resources/data/terraforged/features/shrubs/taiga_scrub_bush.json index ebae157..714d969 100644 --- a/src/main/resources/data/terraforged/features/shrubs/taiga_scrub_bush.json +++ b/src/main/resources/data/terraforged/features/shrubs/taiga_scrub_bush.json @@ -3,6 +3,11 @@ "minecraft:snowy_tundra", "minecraft:taiga", "minecraft:taiga_hills", + "minecraft:wooded_mountains", + "minecraft:taiga_mountains", + "minecraft:snowy_taiga_mountains", + "minecraft:gravelly_mountains", + "minecraft:modified_gravelly_mountains", "terraforged:taiga_scrub", "terraforged:snowy_taiga_scrub" ], diff --git a/src/main/resources/data/terraforged/features/trees/oak_plains.json b/src/main/resources/data/terraforged/features/trees/oak_plains.json index 480f917..88409d4 100644 --- a/src/main/resources/data/terraforged/features/trees/oak_plains.json +++ b/src/main/resources/data/terraforged/features/trees/oak_plains.json @@ -2,7 +2,9 @@ "biomes": [ "minecraft:river", "minecraft:plains", - "minecraft:sunflower_plains" + "minecraft:sunflower_plains", + "minecraft:mountains", + "minecraft:mountain_edge" ], "match": [ [ diff --git a/src/main/resources/data/terraforged/features/trees/spruce.json b/src/main/resources/data/terraforged/features/trees/spruce.json index 8654c26..0804aef 100644 --- a/src/main/resources/data/terraforged/features/trees/spruce.json +++ b/src/main/resources/data/terraforged/features/trees/spruce.json @@ -2,7 +2,7 @@ "biomes": [ "minecraft:snowy_taiga", "minecraft:snowy_taiga_hills", - "minecraft:snowy_taiga_mountains" + "minecraft:taiga_mountains" ], "match": [ [ diff --git a/src/main/resources/data/terraforged/features/trees/spruce_tundra.json b/src/main/resources/data/terraforged/features/trees/spruce_tundra.json index 5b61be8..aca1587 100644 --- a/src/main/resources/data/terraforged/features/trees/spruce_tundra.json +++ b/src/main/resources/data/terraforged/features/trees/spruce_tundra.json @@ -1,13 +1,21 @@ { "biomes": [ "minecraft:snowy_tundra", - "minecraft:wooded_mountains" + "minecraft:snowy_taiga_mountains", + "minecraft:wooded_mountains", + "minecraft:gravelly_mountains", + "minecraft:modified_gravelly_mountains" ], "match": [ [ "minecraft:normal_tree", "minecraft:spruce_log", "minecraft:spruce_leaves" + ], + [ + "minecraft:fancy_tree", + "minecraft:spruce_log", + "minecraft:spruce_leaves" ] ], "replace": {