From d3ce349d61e9874764bf8a54cfa623615e024744 Mon Sep 17 00:00:00 2001 From: dags- Date: Fri, 6 Mar 2020 17:22:23 +0000 Subject: [PATCH] - better handling of wetland terrain - fix missing logs from tree - tweaks to biomemap --- README.md | 37 +++++--- .../{SwampPools.java => Wetlands.java} | 71 +++++++++----- .../core/world/WorldDecorators.java | 4 +- .../core/world/climate/ClimateModule.java | 2 +- .../core/world/terrain/Terrain.java | 24 +++-- .../core/world/terrain/Terrains.java | 4 + .../com/terraforged/mod/biome/Marshland.java | 89 ++++++++++++++++++ .../com/terraforged/mod/biome/ModBiomes.java | 1 + .../mod/biome/map/AbstractBiomeMap.java | 49 +++++++--- .../mod/biome/map/BasicBiomeMap.java | 2 +- .../terraforged/mod/biome/map/BiomeMap.java | 14 +++ .../mod/biome/map/BiomeMapBuilder.java | 12 +++ .../mod/biome/map/DefaultBiome.java | 12 +++ .../biome/modifier/BiomeModifierManager.java | 5 - .../mod/biome/modifier/SwampModifier.java | 57 ----------- .../mod/biome/provider/BiomeHelper.java | 4 +- .../mod/biome/provider/BiomeProvider.java | 78 ++++++++------- .../terraforged/mod/chunk/ChunkProcessor.java | 12 +++ .../mod/chunk/TerraChunkGenerator.java | 41 +++++--- .../terraforged/mod/chunk/TerraContainer.java | 16 ++-- .../com/terraforged/mod/chunk/test/Test.java | 4 +- .../mod/chunk/test/TestBiomeProvider.java | 4 - .../mod/chunk/test/TestChunkGenerator.java | 1 - .../mod/command/task/FindBiomeTask.java | 8 +- .../terraforged/mod/data/WorldGenBiomes.java | 11 +++ .../willow/large/weeping_willow_big_1.nbt | Bin 1406 -> 1414 bytes .../terraforged/tags/biomes/grassland.json | 3 +- 27 files changed, 377 insertions(+), 188 deletions(-) rename TerraForgedCore/src/main/java/com/terraforged/core/decorator/{SwampPools.java => Wetlands.java} (51%) create mode 100644 TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java create mode 100644 TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/DefaultBiome.java delete mode 100644 TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/SwampModifier.java create mode 100644 TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ChunkProcessor.java diff --git a/README.md b/README.md index 0ad26fc..b04e525 100644 --- a/README.md +++ b/README.md @@ -28,19 +28,32 @@ TerraForged is an ambitious new terrain generator mod for Minecraft (Java Editio ![TerraForged Gallery](https://terraforged.com/curse/gallery.jpg) #### FAQ: -1. "Is this compatible with mod xyz?" -_Probably! (to some degree) - TerraForged is designed to work with many of the same world-gen systems -that the majority of block & biome providing mods use. Certain biomes' terrain may not always look -exactly as their author designed but should otherwise be compatible. Feel free to report any other +1) "Is this compatible with mod xyz?" +_Probably! (to some degree) - TerraForged is designed to work with many of the same world-gen systems +that the majority of block & biome providing mods use. Certain biomes' terrain may not always look +exactly as their author designed but should otherwise be compatible. Feel free to report any other compatibility issues on the issue tracker._ -2. "How can I use this on my server?" -_When Forge supports it, you can simply set level-type=terraforged in your server.properties file. In -the meantime, you will need to create the world in single player and then copy that to your server +2) "How can I use this on my server?" +_When Forge supports it, you can simply set level-type=terraforged in your server.properties file. In +the meantime, you will need to create the world in single player and then copy that to your server directory. (In both cases, TerraForged must be installed on the client and the server)._ -3. "Will I need a super-computer to run this?!" -_No, not really - while this world generator will be a bit slower than vanilla's (on account of it -doing more work to make things look nice), it would only be apparent when first generating a chunk - -they might load in slower when moving to new parts of the world, but game performance should -otherwise be normal. A 4-core CPU should be able to handle this just fine._ +3) "Will I need a super-computer to run this?!" +_No, not really - while this world generator will be a bit slower than vanilla's (on account of it +doing more work to make things look nice), it would only be apparent when first generating a chunk +- they might load in slower when moving to new parts of the world, but game performance should +otherwise be normal. A 4-core CPU should be able to handle this just fine._ + +4) "Can this be ported Fabric/Bukkit/Spigot/Sponge?" +_If someone would like to take this task on, yes - a large part of the TerraForged codebase is already +platform independent. There are certain client-side features in the forge-mod that would not translate +onto server-only APIs, but the core experience could certainly be ported. I don't intend to work on +this directly but others are very welcome._ + +5) "Will this be back-ported to older Forge versions?" +_Not by myself, no - My aim is to keep current with Forge. I'm simply not prolific enough a modder to +write and maintain for multiple versions (hats off to those who do!). Again though, others are welcome +to back-port it, if inclined to do so._ + +[View questions on github](https://github.com/TerraForged/TerraForged/issues?q=label:question) \ No newline at end of file diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/decorator/SwampPools.java b/TerraForgedCore/src/main/java/com/terraforged/core/decorator/Wetlands.java similarity index 51% rename from TerraForgedCore/src/main/java/com/terraforged/core/decorator/SwampPools.java rename to TerraForgedCore/src/main/java/com/terraforged/core/decorator/Wetlands.java index 4e30995..07e8953 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/decorator/SwampPools.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/decorator/Wetlands.java @@ -34,52 +34,73 @@ import me.dags.noise.Module; import me.dags.noise.Source; import me.dags.noise.util.NoiseUtil; -public class SwampPools implements Decorator { +public class Wetlands implements Decorator { private final Module module; - private final Levels levels; - private final Terrains terrains; - private final float minY; - private final float maxY; - private final float blendY; - private final float blendRange; + private final float poolBase; + private final float bankHeight; - public SwampPools(Seed seed, Terrains terrains, Levels levels) { - this.levels = levels; - this.terrains = terrains; - this.minY = levels.water(-3); - this.maxY = levels.water(1); - this.blendY = levels.water(4); - this.blendRange = blendY - maxY; - this.module = Source.perlin(seed.next(), 14, 1).clamp(0.45, 0.8).map(0, 1); + private final Terrain wetlands; + + public Wetlands(Seed seed, Terrains terrain, Levels levels) { + this.wetlands = terrain.wetlands; + this.poolBase = levels.water(-3); + this.bankHeight = levels.water(2); + this.module = Source.perlin(seed.next(), 12, 1).clamp(0.35, 0.65).map(0, 1); } @Override public boolean apply(Cell cell, float x, float y) { - if (cell.tag == terrains.ocean) { + if (cell.value < poolBase) { return false; } - if (cell.moisture < 0.7 || cell.temperature < 0.3) { + float tempAlpha = getAlpha(cell.temperature, 0.3F, 0.7F); + if (tempAlpha == 0) { return false; } - if (cell.value <= minY) { + float moistAlpha = getAlpha(cell.moisture, 0.7F, 1F); + if (moistAlpha == 0) { return false; } - if (cell.value > blendY) { + float riverAlpha = getAlpha(1 - cell.riverMask, 0.85F, 0.95F); + if (riverAlpha == 0) { return false; } - float alpha = module.getValue(x, y); - if (cell.value > maxY) { - float delta = blendY - cell.value; - float alpha2 = delta / blendRange; - alpha *= alpha2; + float alpha = tempAlpha * moistAlpha * riverAlpha; + float value1 = NoiseUtil.lerp(cell.value, bankHeight, alpha); + cell.value = Math.min(cell.value, value1); + + float poolAlpha = getAlpha(alpha, 0.35F, 0.55F); + float shape = module.getValue(x, y); + float value2 = NoiseUtil.lerp(cell.value, poolBase, shape * poolAlpha); + cell.value = Math.min(cell.value, value2); + + if (poolAlpha > 0.5) { + cell.tag = wetlands; } - cell.value = NoiseUtil.lerp(cell.value, minY, alpha); return true; } + + private static float getAlpha(float value, float min, float max) { + return getAlpha(value, min, max, false); + } + + private static float getAlpha(float value, float min, float max, boolean inverse) { + if (value < min) { + return 0F; + } + if (value >= max) { + return 1F; + } + float alpha = (value - min) / (max - min); + if (inverse) { + return 1F - alpha; + } + return alpha; + } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java index 14f9c83..b8c0961 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java @@ -27,7 +27,7 @@ package com.terraforged.core.world; import com.terraforged.core.decorator.Decorator; import com.terraforged.core.decorator.DesertStacks; -import com.terraforged.core.decorator.SwampPools; +import com.terraforged.core.decorator.Wetlands; import java.util.ArrayList; import java.util.Collections; @@ -41,7 +41,7 @@ public class WorldDecorators { context = context.copy(); List list = new ArrayList<>(); list.add(new DesertStacks(context.seed, context.levels)); - list.add(new SwampPools(context.seed, context.terrain, context.levels)); + list.add(new Wetlands(context.seed, context.terrain, context.levels)); decorators = Collections.unmodifiableList(list); } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java index 384f2b6..9ccf18d 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java @@ -61,7 +61,7 @@ public class ClimateModule { int warpScale = settings.biome.biomeWarpScale; this.seed = seed.next(); - this.edgeClamp = 0.85F; + this.edgeClamp = 1F; this.edgeScale = 1 / edgeClamp; this.biomeFreq = 1F / biomeSize; this.warpStrength = settings.biome.biomeWarpStrength; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java index 94b4685..d153061 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java @@ -134,43 +134,47 @@ public class Terrain implements Tag { return new Terrain("river_banks", 4); } + public static Terrain wetlands(Settings settings) { + return new Terrain("wetlands", 5); + } + public static Terrain steppe(Settings settings) { - return new Terrain("steppe", 5, settings.terrain.steppe.weight); + return new Terrain("steppe", 6, settings.terrain.steppe.weight); } public static Terrain plains(Settings settings) { - return new Terrain("plains", 5, settings.terrain.plains.weight); + return new Terrain("plains", 7, settings.terrain.plains.weight); } public static Terrain plateau(Settings settings) { - return new Terrain("plateau", 6, settings.terrain.plateau.weight); + return new Terrain("plateau", 8, settings.terrain.plateau.weight); } public static Terrain badlands(Settings settings) { - return new Terrain("badlands", 7, settings.terrain.badlands.weight); + return new Terrain("badlands", 9, settings.terrain.badlands.weight); } public static Terrain hills(Settings settings) { - return new Terrain("hills", 8, settings.terrain.hills.weight); + return new Terrain("hills", 10, settings.terrain.hills.weight); } public static Terrain dales(Settings settings) { - return new Terrain("dales", 9, settings.terrain.dales.weight); + return new Terrain("dales", 11, settings.terrain.dales.weight); } public static Terrain torridonian(Settings settings) { - return new Terrain("torridonian_fells", 10, settings.terrain.torridonian.weight); + return new Terrain("torridonian_fells", 12, settings.terrain.torridonian.weight); } public static Terrain mountains(Settings settings) { - return new Terrain("mountains", 11, settings.terrain.mountains.weight); + return new Terrain("mountains", 13, settings.terrain.mountains.weight); } public static Terrain volcano(Settings settings) { - return new Terrain("volcano", 12, settings.terrain.volcano.weight); + return new Terrain("volcano", 14, settings.terrain.volcano.weight); } public static Terrain volcanoPipe(Settings settings) { - return new Terrain("volcano_pipe", 13, settings.terrain.volcano.weight); + return new Terrain("volcano_pipe", 15, settings.terrain.volcano.weight); } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrains.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrains.java index b3433fe..3198969 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrains.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrains.java @@ -40,6 +40,7 @@ public class Terrains { public final Terrain lake; public final Terrain river; public final Terrain riverBanks; + public final Terrain wetlands; public final Terrain badlands; public final Terrain steppe; public final Terrain plains; @@ -64,6 +65,7 @@ public class Terrains { river = mutable.river, torridonian = mutable.torridonian, riverBanks = mutable.riverbanks, + wetlands = mutable.wetlands, badlands = mutable.badlands, plateau = mutable.plateau, steppe = mutable.steppe, @@ -102,6 +104,7 @@ public class Terrains { terrain.lake = Terrain.lake(settings); terrain.river = Terrain.river(settings); terrain.riverbanks = Terrain.riverBank(settings); + terrain.wetlands = Terrain.wetlands(settings); terrain.badlands = Terrain.badlands(settings); terrain.plateau = Terrain.plateau(settings); terrain.steppe = Terrain.steppe(settings); @@ -123,6 +126,7 @@ public class Terrains { public Terrain lake = Terrain.NONE; public Terrain river = Terrain.NONE; public Terrain riverbanks = Terrain.NONE; + public Terrain wetlands = Terrain.NONE; public Terrain badlands = Terrain.NONE; public Terrain plateau = Terrain.NONE; public Terrain steppe = Terrain.NONE; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java new file mode 100644 index 0000000..8652812 --- /dev/null +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java @@ -0,0 +1,89 @@ +/* + * + * MIT License + * + * Copyright (c) 2020 TerraForged + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.terraforged.mod.biome; + +import com.terraforged.api.biome.BiomeVariant; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.Biomes; +import net.minecraft.world.biome.DefaultBiomeFeatures; +import net.minecraft.world.biome.SwampBiome; +import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +public class Marshland extends BiomeVariant { + public Marshland() { + super((new Builder()).surfaceBuilder(SurfaceBuilder.SWAMP, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(RainType.RAIN).category(Category.SWAMP).depth(0.2F).scale(0.2F).temperature(0.8F).downfall(0.4F).waterColor(6388580).waterFogColor(2302743).parent((String) null)); + this.setRegistryName("terraforged", "marshland"); + DefaultBiomeFeatures.addCarvers(this); + DefaultBiomeFeatures.addStructures(this); + DefaultBiomeFeatures.addMonsterRooms(this); + DefaultBiomeFeatures.addStoneVariants(this); + DefaultBiomeFeatures.addOres(this); + DefaultBiomeFeatures.addSedimentDisks(this); + DefaultBiomeFeatures.addDefaultFlowers(this); + DefaultBiomeFeatures.addTallGrass(this); + DefaultBiomeFeatures.addTallGrass(this); + DefaultBiomeFeatures.addTallGrass(this); + DefaultBiomeFeatures.addTallGrass(this); + DefaultBiomeFeatures.addGrass(this); + DefaultBiomeFeatures.addVeryDenseGrass(this); + DefaultBiomeFeatures.addReedsAndPumpkins(this); + DefaultBiomeFeatures.addFreezeTopLayer(this); + this.addSpawn(EntityClassification.CREATURE, new SpawnListEntry(EntityType.SHEEP, 12, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new SpawnListEntry(EntityType.PIG, 10, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new SpawnListEntry(EntityType.CHICKEN, 10, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new SpawnListEntry(EntityType.COW, 8, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new SpawnListEntry(EntityType.WOLF, 8, 4, 4)); + this.addSpawn(EntityClassification.CREATURE, new SpawnListEntry(EntityType.RABBIT, 4, 2, 3)); + this.addSpawn(EntityClassification.CREATURE, new SpawnListEntry(EntityType.FOX, 8, 2, 4)); + this.addSpawn(EntityClassification.AMBIENT, new SpawnListEntry(EntityType.BAT, 10, 8, 8)); + this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.SPIDER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.ZOMBIE, 95, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.ZOMBIE_VILLAGER, 5, 1, 1)); + this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.SKELETON, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.CREEPER, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.SLIME, 100, 4, 4)); + this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.ENDERMAN, 10, 1, 4)); + this.addSpawn(EntityClassification.MONSTER, new SpawnListEntry(EntityType.WITCH, 5, 1, 1)); + } + + public int getGrassColor(double p_225528_1_, double p_225528_3_) { + double d0 = INFO_NOISE.noiseAt(p_225528_1_ * 0.0225D, p_225528_3_ * 0.0225D, false); + return d0 < -0.1D ? 5011004 : 6975545; + } + + public int getFoliageColor() { + return 6975545; + } + + @Override + public Biome getBase() { + return Biomes.SWAMP; + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ModBiomes.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ModBiomes.java index ed926ac..793bd52 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ModBiomes.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/ModBiomes.java @@ -46,6 +46,7 @@ public class ModBiomes { public static final Biome STEPPE = register(new Steppe()); public static final Biome TAIGA_SCRUB = register(new TaigaScrub()); public static final Biome WARM_BEACH = register(new WarmBeach()); + public static final Biome MARSHLAND = register(new Marshland()); private static Biome register(BiomeVariant biome) { biomes.add(biome); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java index 3ebd34a..234ff88 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java @@ -38,39 +38,54 @@ import net.minecraft.world.biome.Biomes; import java.util.Collections; import java.util.HashSet; import java.util.Set; +import java.util.function.Function; public abstract class AbstractBiomeMap implements BiomeMap { private final Biome[][] beach; private final Biome[][] river; + private final Biome[][] wetland; private final Biome[][] ocean; private final Biome[][] deepOcean; + protected final DefaultBiome defaultLand = this::defaultBiome; + protected final DefaultBiome defaultBeach = this::defaultBeach; + protected final DefaultBiome defaultRiver = this::defaultRiver; + protected final DefaultBiome defaultWetland = this::defaultWetland; + protected final DefaultBiome defaultOcean = this::defaultOcean; + protected final DefaultBiome defaultDeepOcean = this::defaultDeepOcean; + protected AbstractBiomeMap(BiomeMapBuilder builder) { river = builder.rivers(); beach = builder.beaches(); ocean = builder.oceans(); + wetland = builder.wetlands(); deepOcean = builder.deepOceans(); } @Override public Biome getBeach(float temperature, float moisture, float shape) { - return get(beach, getCategory(temperature), shape, defaultBeach(temperature)); + return get(beach, getCategory(temperature), shape, temperature, defaultBeach); } @Override public Biome getRiver(float temperature, float moisture, float shape) { - return get(river, getCategory(temperature), shape, defaultRiver(temperature)); + return get(river, getCategory(temperature), shape, temperature, defaultRiver); + } + + @Override + public Biome getWetland(float temperature, float moisture, float shape) { + return get(wetland, getCategory(temperature), shape, temperature, defaultWetland); } @Override public Biome getOcean(float temperature, float moisture, float shape) { - return get(ocean, getCategory(temperature), shape, defaultOcean(temperature)); + return get(ocean, getCategory(temperature), shape, temperature, defaultOcean); } @Override public Biome getDeepOcean(float temperature, float moisture, float shape) { - return get(deepOcean, getCategory(temperature), shape, defaultDeepOcean(temperature)); + return get(deepOcean, getCategory(temperature), shape, temperature, defaultDeepOcean); } @Override @@ -92,7 +107,8 @@ public abstract class AbstractBiomeMap implements BiomeMap { public JsonObject toJson() { JsonObject root = new JsonObject(); root.add("rivers", collect(river)); - root.add("beaches", collect(river)); + root.add("wetland", collect(wetland)); + root.add("beaches", collect(beach)); root.add("oceans", collect(ocean)); root.add("deepOceans", collect(deepOcean)); return root; @@ -144,6 +160,13 @@ public abstract class AbstractBiomeMap implements BiomeMap { return Biomes.RIVER; } + protected Biome defaultWetland(float temperature) { + if (temperature < 0.15) { + return ModBiomes.TAIGA_SCRUB; + } + return ModBiomes.MARSHLAND; + } + protected Biome defaultOcean(float temperature) { if (temperature < 0.3) { return Biomes.FROZEN_OCEAN; @@ -164,7 +187,7 @@ public abstract class AbstractBiomeMap implements BiomeMap { return Biomes.DEEP_OCEAN; } - protected Biome defaultBiome(float temperature, float moisture) { + protected Biome defaultBiome(float temperature) { if (temperature < 0.3) { return ModBiomes.TAIGA_SCRUB; } @@ -174,22 +197,22 @@ public abstract class AbstractBiomeMap implements BiomeMap { return Biomes.PLAINS; } - protected Biome get(Biome[][] group, Biome.TempCategory category, float shape, Biome def) { - return get(group, category.ordinal() - 1, shape, def); + protected Biome get(Biome[][] group, Biome.TempCategory category, float shape, float temp, DefaultBiome def) { + return get(group, category.ordinal() - 1, shape, temp, def); } - protected Biome get(Biome[][] group, BiomeType type, float shape, Biome def) { - return get(group, type.ordinal(), shape, def); + protected Biome get(Biome[][] group, BiomeType type, float shape, float temp, DefaultBiome def) { + return get(group, type.ordinal(), shape, temp, def); } - protected Biome get(Biome[][] group, int ordinal, float shape, Biome def) { + protected Biome get(Biome[][] group, int ordinal, float shape, float temp, DefaultBiome def) { if (ordinal >= group.length) { - return def; + return def.getDefaultBiome(temp); } Biome[] biomes = group[ordinal]; if (biomes == null || biomes.length == 0) { - return def; + return def.getDefaultBiome(temp); } int index = NoiseUtil.round((biomes.length - 1) * shape); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java index 49b0a72..37f62e8 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BasicBiomeMap.java @@ -64,7 +64,7 @@ public class BasicBiomeMap extends AbstractBiomeMap { @Override public Biome getBiome(BiomeType type, float temperature, float moisture, float shape) { - return get(biomeTypes, type, shape, defaultBiome(temperature, moisture)); + return get(biomeTypes, type, shape, temperature, defaultLand); } @Override diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMap.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMap.java index db2ae58..7fa0f1a 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMap.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMap.java @@ -26,7 +26,9 @@ package com.terraforged.mod.biome.map; import com.google.gson.JsonElement; +import com.terraforged.core.cell.Cell; import com.terraforged.core.world.biome.BiomeType; +import com.terraforged.core.world.terrain.Terrain; import net.minecraft.world.biome.Biome; import java.util.List; @@ -38,12 +40,18 @@ public interface BiomeMap { Biome getRiver(float temperature, float moisture, float shape); + Biome getWetland(float temperature, float moisture, float shape); + Biome getOcean(float temperature, float moisture, float shape); Biome getDeepOcean(float temperature, float moisture, float shape); Biome getBiome(BiomeType type, float temperature, float moisture, float shape); + default Biome getBiome(Cell cell) { + return getBiome(cell.biomeType, cell.temperature, cell.moisture, cell.biome); + } + List getAllBiomes(BiomeType type); Set getBiomes(BiomeType type); @@ -56,12 +64,18 @@ public interface BiomeMap { JsonElement toJson(); + static Biome getBiome(Biome biome) { + return biome.delegate.get(); + } + interface Builder { Builder addBeach(Biome biome, int count); Builder addRiver(Biome biome, int count); + Builder addWetland(Biome biome, int count); + Builder addOcean(Biome biome, int count); Builder addBiome(BiomeType type, Biome biome, int count); diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java index 281e9b5..c4c2ee5 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/BiomeMapBuilder.java @@ -44,6 +44,7 @@ import java.util.function.Function; public class BiomeMapBuilder implements BiomeMap.Builder { private final Map> rivers = new HashMap<>(); + private final Map> wetlands = new HashMap<>(); private final Map> beaches = new HashMap<>(); private final Map> oceans = new HashMap<>(); private final Map> deepOceans = new HashMap<>(); @@ -87,6 +88,13 @@ public class BiomeMapBuilder implements BiomeMap.Builder { return this; } + @Override + public BiomeMapBuilder addWetland(Biome biome, int count) { + Biome.TempCategory category = BiomeHelper.getTempCategory(biome); + add(wetlands.computeIfAbsent(category, c -> new ArrayList<>()), biome, count); + return this; + } + @Override public BiomeMapBuilder addBiome(BiomeType type, Biome biome, int count) { add(map.computeIfAbsent(type, t -> new ArrayList<>()), biome, count); @@ -102,6 +110,10 @@ public class BiomeMapBuilder implements BiomeMap.Builder { return collectTemps(rivers); } + Biome[][] wetlands() { + return collectTemps(wetlands); + } + Biome[][] beaches() { return collectTemps(beaches); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/DefaultBiome.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/DefaultBiome.java new file mode 100644 index 0000000..857ffb4 --- /dev/null +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/DefaultBiome.java @@ -0,0 +1,12 @@ +package com.terraforged.mod.biome.map; + +import net.minecraft.world.biome.Biome; + +public interface DefaultBiome { + + Biome getBiome(float temperature); + + default Biome getDefaultBiome(float temperature) { + return getBiome(temperature).delegate.get(); + } +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java index 86a0300..5cbf385 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/BiomeModifierManager.java @@ -54,11 +54,6 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager { context.factory.getClimate(), context.levels )); - modifiers.add(new SwampModifier( - context.seed, - context.factory.getClimate(), - context.levels - )); Collections.sort(modifiers); this.biomeModifiers = modifiers; } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/SwampModifier.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/SwampModifier.java deleted file mode 100644 index 2cd031b..0000000 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/modifier/SwampModifier.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2020 TerraForged - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.terraforged.mod.biome.modifier; - -import com.terraforged.core.cell.Cell; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.climate.Climate; -import com.terraforged.core.world.heightmap.Levels; -import com.terraforged.core.world.terrain.Terrain; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.Biomes; - -// prevents swamps forming at high levels -public class SwampModifier extends AbstractMaxHeightModifier { - - public SwampModifier(Seed seed, Climate climate, Levels levels) { - super(seed, climate, 60, 1, levels.scale(10), levels.ground(4), levels.ground(12)); - } - - @Override - protected Biome getModifiedBiome(Biome in, Cell cell, int x, int z, float ox, float oz) { - return Biomes.PLAINS; - } - - @Override - public int priority() { - return 0; - } - - @Override - public boolean test(Biome biome) { - return biome.getCategory() == Biome.Category.SWAMP; - } -} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java index f683c4f..406bbaf 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeHelper.java @@ -60,7 +60,7 @@ public class BiomeHelper { put(BiomeType.DESERT, BiomePredicate.DESERT.or(BiomePredicate.MESA).not(BiomePredicate.COAST).not(BiomePredicate.MOUNTAIN).not(BiomePredicate.WETLAND)); put(BiomeType.TEMPERATE_RAINFOREST, BiomePredicate.TEMPERATE_RAINFOREST.not(BiomePredicate.COAST).not(BiomePredicate.MOUNTAIN)); put(BiomeType.TEMPERATE_FOREST, BiomePredicate.TEMPERATE_FOREST.not(BiomePredicate.COAST).not(BiomePredicate.MOUNTAIN).not(BiomePredicate.WETLAND)); - put(BiomeType.GRASSLAND, BiomePredicate.GRASSLAND.or(BiomePredicate.WETLAND).not(BiomePredicate.COAST).not(BiomePredicate.MOUNTAIN)); + put(BiomeType.GRASSLAND, BiomePredicate.GRASSLAND.not(BiomePredicate.WETLAND).not(BiomePredicate.COAST).not(BiomePredicate.MOUNTAIN)); put(BiomeType.COLD_STEPPE, BiomePredicate.COLD_STEPPE.not(BiomePredicate.COAST).not(BiomePredicate.MOUNTAIN)); put(BiomeType.STEPPE, BiomePredicate.STEPPE.not(BiomePredicate.COAST).not(BiomePredicate.MOUNTAIN)); put(BiomeType.TAIGA, BiomePredicate.TAIGA.not(BiomePredicate.TUNDRA).not(BiomePredicate.COLD_STEPPE).not(BiomePredicate.COAST).not(BiomePredicate.MOUNTAIN)); @@ -104,6 +104,8 @@ public class BiomeHelper { builder.addRiver(biome, weight); } else if (biome.getCategory() == Biome.Category.BEACH || biome == Biomes.STONE_SHORE) { builder.addBeach(biome, weight); + } else if (biome.getCategory() == Biome.Category.SWAMP) { + builder.addWetland(biome, weight); } else { Collection types = getTypes(data, biome); for (BiomeType type : types) { diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java index 7a001e5..7d46d80 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java @@ -27,6 +27,7 @@ package com.terraforged.mod.biome.provider; import com.google.common.collect.Sets; import com.terraforged.core.cell.Cell; +import com.terraforged.core.decorator.Decorator; import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.util.concurrent.ObjectPool; import com.terraforged.core.world.terrain.Terrain; @@ -40,8 +41,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.feature.structure.Structure; +import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.Set; @@ -50,6 +54,7 @@ public class BiomeProvider extends AbstractBiomeProvider { private final BiomeMap biomeMap; private final TerraContext context; private final BiomeModifierManager modifierManager; + private final Map> decorators = new HashMap<>(); public BiomeProvider(TerraContext context) { this.context = context; @@ -57,19 +62,6 @@ public class BiomeProvider extends AbstractBiomeProvider { this.modifierManager = SetupHooks.setup(new BiomeModifierManager(context, biomeMap), context.copy()); } - public BiomeModifierManager getModifierManager() { - return modifierManager; - } - - public TerraContainer createBiomeContainer(ChunkReader chunkReader) { - TerraContainer.Builder builder = TerraContainer.builder(); - chunkReader.iterate((cell, dx, dz) -> { - Biome biome = getBiome(cell, chunkReader.getBlockX() + dx, chunkReader.getBlockZ() + dz); - builder.fill(dx, dz, biome); - }); - return builder.build(chunkReader); - } - @Override public Biome getBiome(int x, int y, int z) { try (ObjectPool.Item> item = Cell.pooled()) { @@ -135,29 +127,51 @@ public class BiomeProvider extends AbstractBiomeProvider { return this.topBlocksCache; } + public BiomeModifierManager getModifierManager() { + return modifierManager; + } + + public List getDecorators(Biome biome) { + return decorators.getOrDefault(biome, Collections.emptyList()); + } + + public TerraContainer createBiomeContainer(ChunkReader chunkReader) { + TerraContainer.Builder builder = TerraContainer.builder(); + chunkReader.iterate((cell, dx, dz) -> { + Biome biome = getBiome(cell, chunkReader.getBlockX() + dx, chunkReader.getBlockZ() + dz); + builder.fill(dx, dz, biome); + }); + return builder.build(chunkReader); + } + public Biome getBiome(Cell cell, int x, int z) { - if (cell.value <= context.levels.water) { - if (cell.tag == context.terrain.river || cell.tag == context.terrain.riverBanks) { - Biome biome = getBiome(cell); - if (biome.getCategory() == Biome.Category.SWAMP) { - return biome; - } - return biomeMap.getRiver(cell.temperature, cell.moisture, cell.biome); - } else if (cell.tag == context.terrain.ocean) { - return biomeMap.getOcean(cell.temperature, cell.moisture, cell.biome); - } else if (cell.tag == context.terrain.deepOcean) { - return biomeMap.getDeepOcean(cell.temperature, cell.moisture, cell.biome); - } + if (cell.tag == context.terrain.wetlands) { + return biomeMap.getWetland(cell.temperature, cell.moisture, cell.biome); } - return modifyBiome(getBiome(cell), cell, x, z); + + if (cell.value > context.levels.water) { + return getModifierManager().modify(biomeMap.getBiome(cell), cell, x, z); + } + + if (cell.tag == context.terrain.river || cell.tag == context.terrain.riverBanks) { + Biome biome = biomeMap.getBiome(cell); + if (overridesRiver(biome)) { + return biome; + } + + return biomeMap.getRiver(cell.temperature, cell.moisture, cell.biome); + } + + if (cell.tag == context.terrain.ocean) { + return biomeMap.getOcean(cell.temperature, cell.moisture, cell.biome); + } + + return biomeMap.getDeepOcean(cell.temperature, cell.moisture, cell.biome); } - public Biome getBiome(Cell cell) { - return biomeMap.getBiome(cell.biomeType, cell.temperature, cell.moisture, cell.biome); - } - - public Biome modifyBiome(Biome biome, Cell cell, int x, int z) { - return modifierManager.modify(biome, cell, x, z); + private static boolean overridesRiver(Biome biome) { + return biome.getCategory() == Biome.Category.SWAMP + || biome.getCategory() == Biome.Category.JUNGLE; } private static class SearchContext { diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ChunkProcessor.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ChunkProcessor.java new file mode 100644 index 0000000..e9df107 --- /dev/null +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/ChunkProcessor.java @@ -0,0 +1,12 @@ +package com.terraforged.mod.chunk; + +import com.terraforged.api.chunk.column.DecoratorContext; +import com.terraforged.core.region.chunk.ChunkReader; +import net.minecraft.util.math.ChunkPos; + +public interface ChunkProcessor { + + void preProcess(ChunkPos pos, ChunkReader chunk, TerraContainer container); + + void postProcess(ChunkReader chunk, TerraContainer container, DecoratorContext context); +} diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java index 4f62713..b53912e 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java @@ -32,6 +32,7 @@ import com.terraforged.api.chunk.surface.SurfaceContext; import com.terraforged.api.chunk.surface.SurfaceManager; import com.terraforged.api.material.layer.LayerManager; import com.terraforged.core.cell.Cell; +import com.terraforged.core.decorator.Decorator; import com.terraforged.core.region.RegionCache; import com.terraforged.core.region.RegionGenerator; import com.terraforged.core.region.Size; @@ -69,7 +70,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.IWorld; import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeContainer; import net.minecraft.world.biome.BiomeManager; import net.minecraft.world.biome.Biomes; import net.minecraft.world.chunk.ChunkPrimer; @@ -86,7 +86,7 @@ import net.minecraft.world.gen.feature.template.TemplateManager; import java.util.ArrayList; import java.util.List; -public class TerraChunkGenerator extends ObfHelperChunkGenerator { +public class TerraChunkGenerator extends ObfHelperChunkGenerator implements ChunkProcessor { private final TerraContext context; private final BiomeProvider biomeProvider; @@ -125,9 +125,23 @@ public class TerraChunkGenerator extends ObfHelperChunkGenerator { + Biome biome = container.getBiome(dx, dz); + for (Decorator decorator : getBiomeProvider().getDecorators(biome)) { + if (decorator.apply(cell, pos.getXStart() + dx, pos.getZStart() + dz)) { + return; + } + } + }); } @Override @@ -142,7 +156,6 @@ public class TerraChunkGenerator extends ObfHelperChunkGenerator { + // run post processes on chunk + postProcess(container.getChunkReader(), container, context); + + // bake biome array & discard gen data + ((ChunkPrimer) chunk).func_225548_a_(container.bakeBiomes()); + } + + @Override + public final void postProcess(ChunkReader chunk, TerraContainer container, DecoratorContext context) { + chunk.iterate((cell, dx, dz) -> { int px = context.blockX + dx; int pz = context.blockZ + dz; - int py = chunk.getTopBlockY(Heightmap.Type.WORLD_SURFACE_WG, dx, dz); + int py = context.chunk.getTopBlockY(Heightmap.Type.WORLD_SURFACE_WG, dx, dz); context.cell = cell; context.biome = container.getBiome(dx, dz); for (ColumnDecorator decorator : getPostProcessors()) { - decorator.decorate(chunk, context, px, py, pz); + decorator.decorate(context.chunk, context, px, py, pz); } }); - - ((ChunkPrimer) chunk).func_225548_a_(container.bakeBiomes()); } @Override diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java index 37751f9..65d1fe3 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java @@ -37,10 +37,10 @@ import net.minecraft.world.biome.BiomeContainer; public class TerraContainer extends BiomeContainer { - private static final int ZOOM_HORIZ = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2; + private static final int BITS_WIDTH = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2; private static final int ZOOM_VERT = (int) Math.round(Math.log(256.0D) / Math.log(2.0D)) - 2; - public static final int SIZE = 1 << ZOOM_HORIZ + ZOOM_HORIZ + ZOOM_VERT; - public static final int MASK_HORIZ = (1 << ZOOM_HORIZ) - 1; + public static final int SIZE = 1 << BITS_WIDTH + BITS_WIDTH + ZOOM_VERT; + public static final int MASK_HORIZ = (1 << BITS_WIDTH) - 1; public static final int MASK_VERT = (1 << ZOOM_VERT) - 1; private final Biome[] biomes; @@ -97,10 +97,10 @@ public class TerraContainer extends BiomeContainer { } private static int indexOf(int x, int y, int z) { - int bx = x & MASK_HORIZ; - int by = MathHelper.clamp(y, 0, MASK_VERT); - int bz = z & MASK_HORIZ; - return by << ZOOM_HORIZ + ZOOM_HORIZ | bz << ZOOM_HORIZ | bx; + x &= MASK_HORIZ; + y = MathHelper.clamp(y, 0, MASK_VERT); + z &= MASK_HORIZ; + return y << BITS_WIDTH + BITS_WIDTH | z << BITS_WIDTH | x; } public static Builder builder() { @@ -119,7 +119,7 @@ public class TerraContainer extends BiomeContainer { } public void fill(int x, int z, Biome biome) { - for (int y = 0; y < 64; y++) { + for (int y = 0; y < 256; y += 4) { set(x, y, z, biome); } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/Test.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/Test.java index 9e2e018..8a0e3c0 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/Test.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/Test.java @@ -35,10 +35,10 @@ public class Test { public static boolean fixedBiome = true; public static Terrain getTerrainType(Terrains terrains) { - return terrains.steppe; + return terrains.dales; } public static Biome getBiome() { - return Biomes.DESERT; + return Biomes.PLAINS; } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java index c56de43..728d0e9 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestBiomeProvider.java @@ -27,7 +27,6 @@ package com.terraforged.mod.chunk.test; import com.terraforged.core.cell.Cell; import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.mod.biome.ModBiomes; import com.terraforged.mod.biome.provider.BiomeProvider; import com.terraforged.mod.chunk.TerraContext; import net.minecraft.world.biome.Biome; @@ -40,9 +39,6 @@ public class TestBiomeProvider extends BiomeProvider { @Override public Biome getBiome(Cell cell, int x, int z) { - if (cell.biome < 0.5F) { - return ModBiomes.TAIGA_SCRUB; - } return Test.getBiome(); } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java index f33a581..9b37e14 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/test/TestChunkGenerator.java @@ -75,7 +75,6 @@ public class TestChunkGenerator extends TerraChunkGenerator { @Override public void apply(Cell cell, float x, float y) { super.apply(cell, x, y); - populator.apply(cell, x, y); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/task/FindBiomeTask.java b/TerraForgedMod/src/main/java/com/terraforged/mod/command/task/FindBiomeTask.java index 88ed423..a430f7a 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/command/task/FindBiomeTask.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/command/task/FindBiomeTask.java @@ -26,6 +26,7 @@ package com.terraforged.mod.command.task; import com.terraforged.core.cell.Cell; +import com.terraforged.core.decorator.Decorator; import com.terraforged.core.world.WorldGenerator; import com.terraforged.core.world.terrain.Terrain; import com.terraforged.mod.biome.provider.BiomeProvider; @@ -58,9 +59,14 @@ public class FindBiomeTask extends FindTask { @Override protected boolean search(int x, int z) { generator.getHeightmap().apply(cell, x, z); + for (Decorator decorator : generator.getDecorators().getDecorators()) { + if (decorator.apply(cell, x, z)) { + break; + } + } if (biome.getCategory() != Biome.Category.BEACH && biome.getCategory() != Biome.Category.OCEAN) { - if (cell.continentEdge > 0.4 && cell.continentEdge < 0.5) { + if (cell.continentEdge > 0.4 && cell.continentEdge < 0.45) { return false; } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBiomes.java b/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBiomes.java index d618592..0f99d3a 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBiomes.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBiomes.java @@ -25,6 +25,7 @@ package com.terraforged.mod.data; +import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.terraforged.core.world.biome.BiomeType; @@ -33,7 +34,11 @@ import com.terraforged.mod.biome.provider.BiomeHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.Biome; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; import java.util.Set; public class WorldGenBiomes extends DataGen { @@ -43,6 +48,12 @@ public class WorldGenBiomes extends DataGen { for (BiomeType type : BiomeType.values()) { genBiomes(dataDir, type, map); } + + try (Writer writer = new BufferedWriter(new FileWriter(new File("biome_map.json")))) { + new GsonBuilder().setPrettyPrinting().create().toJson(map.toJson(), writer); + } catch (IOException e) { + e.printStackTrace(); + } } private static void genBiomes(File dir, BiomeType type, BiomeMap map) { diff --git a/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_1.nbt b/TerraForgedMod/src/main/resources/data/terraforged/structures/trees/willow/large/weeping_willow_big_1.nbt index 2894fa6d8067ab8eb47cbe58e3a4194e99e8757d..9ca02602f656d5e30852ac46749e164d32fbaad5 100644 GIT binary patch literal 1414 zcmV;11$p`(iwFR)ePLbz|E-(-Zrer>#A%VdFVY1H^hNslM<1f-8x(5Fv_>4;u+$*U z(^q78Lb{mS85a&f1U7z}ox9z;J)Pvzb-9aA$NS}cUP^cQDRsjy$M;M3_4~Vr<<0Z) z?fK`&}`StnnX?Z^1EvE~1{CIcjZvN@I`jT(VOP1q@mtQOo=WaMZ|GoTgu^(Sk?1$GB`~Ee>zI#ovZ(T9906x9^B_G$S3%}n# zzIk`C*WLV;yZ-6%)L-gvePZ|dU+TN@;`O|2KmC_kpPS1we!<)rCIjYRm}zH%qZ4<= z^K;ml?C8{3#bL&snH|q*XKsnk>ZvE=Voctd!SPea@6B@tOmCPX=p6PZkeo86j-BQ7 zU~+18X294vtU5*T>@ihma$*(0wDL6z^)oy9%7C%4!p?ZLngC;U#_FBKvJ9$urZd$4 z$=Dfl^)Bdq$qXQ;Oy^MNz+onVsX9@Z=jg1RS)U&tV2f$dJ5ir(I7IbPIdizEcm;@N)c^ez?V;SU! z=?wL8=4TX`02mu92}~AZRo~t|HUP%fY7%s^pi=~$!_EX@T!E}F%Y=p>PiGSRRL@bU zLvMdhfQb#yQSclc&$HmU&U12fB4AqM@|X;m)EIkmaykPB?cpnvg>~xnrUIB&F1%PX zU|OEN{?!A<`WXOY=Wql}E2kb)1V0mCTI-ATLCduEI^SXt1ie!Me46qp1U6l*&Jkyw^NHMY$)sWHX`z@T|%Ocr8YJ&}FG zGHBmmOcG*cL8k~hhn?~Idk+{JYXFSxO{2hMz@R;o`Kjab`g;$URvktsRsf9k90i>u zFh%e@31goDgZk;pcxRg)FxF254CM87O!*sHsQv{tlE_Md640?acbm}@~XMpYg zg6LQVjcYr*kXmI-5SSz|*Lf8Du-?sdvcO!&Cd{GN2S>ozH5de)DCi_XCkspw#(vlt z*557D$|>vbjEMr11*Qm|CxMxT`Kfd0_3j=pt@&a7o#|vjXA*Q~z_jYe>+d~ate-*9 z$pTXV)5<$L+pLV&PY1x*ag72Kgji9~NrFxmm;#vA{IL5C%e3}+b_QTf%>}!2U`!I2 znu}Y)Y@a=l`q}OjNZ+vx8W+=vfU)@yC=M1e_wX^o5Z?v?TS@&K6D z9`5M`fr)@=?cs{&S@7dA5il)3iq0)zw(lR1zO#Lje=ot-Q0(`d5bS^NdM=X^o4$N3%>TmZIam*W12N(eZo8 z?Oa0o7h^`ip!u;3y0gk;4fcSsXUIWdMj=)J49W##>bTf>)iSMIu=UQEB>1Ug_db)V zvAlIr8LytV@4t}x83BXpr;uFqfI;)jnDGU%Sl%b1Gc=gtboXhg&~5j*L4DPC@x%HD UG>;G6`c?CP0qRwJX-+i&02B+`YXATM literal 1406 zcmV-^1%dh>iwFR7BV1kp|E-(rZrer>g=vx88|nV)i}d=V4^i|D3N>X=BaUrYYLMpX zD>7Um9h{wWoH~FI*!Xhh%+Bo2ic(6~B?`;H= z)8!Y-!?_#I&wnppE%wuEiv9SSVn4j5*!Qm~_TB#$+k4>CSN*GxYx{*i?jPU0yAa*Y zU%Bg_9#8$H5!YAjKL1I5H(nf{m+hzjGVAN+@*2NjZVZzFb1=-bGr`e`JLCB|>`Zoa zYOLZgE=d?4oL}&HXle`#{cV=+>)cn15&VcC+Qv{vE{tBd~jH$V^njTC|t zyM|S#2%bHr>P$|o0+?34W}$y(r(PK_HdfdfuU8Xbtj<`ylUSBPJ#pYRYsDbqyS55}2wJg>{b3-kAlRYyBNR5in?V z8q3?uBVfixk4-|4O+r6=`+We6)foX}{bWI>_MvxfM1e_wL7unVh#$)!KTKz+FK2y5 zfeC=Iv68@KAy)P6onr%FY_BFkCkr}7&^hc(5b_FSe_19p{CGN(;HP?yLLYkPa{^3k zc#eYS=y;w5&vl)XqZ0ws%FAOiU{WLZ|4B>e;(*^nhvA!efdMYXVHG7VK`bGVE?+nN~l0cbfp1 zR=qr(Ea((Lr}}317RHQ#Y0VUNw_!S2&?$mW&5PXuEQ8*kGM&0l*&SeeenE6BgYw$$ zE~Hl(69gs+%yk_FKWuh0oh&fd+=Mms=HLhzy9a}y69t_l=wyK@Lhgs1Ve{QGt(vm= z&X_1LSzwCbc@mgeSf9Fv-t6uH(^?-k-mN&Zxz@UA>bb`P{z_jx6bgp$JJ!Y9!z1SUqF-h=~ z1?C!$-1#ko_A+AvV9@!)bc&!e3Ct|SI_!-1UN`^-J(sXdtES#O&4Nw=jD7wy3Ct|S zs_VmMrDa-Yf~OM!gJv9ym4#SE(3xJ47yFEZF;QR=U|M;x*}XE}Tpj?^I>SAkATSXy ztutKlJPUq2CIY7AN71<@%=Y~QGIzGm70B7km