From f0d4108477b79e91401f73bfb4560a2905545f09 Mon Sep 17 00:00:00 2001 From: dags- Date: Sat, 20 Jun 2020 17:41:02 +0100 Subject: [PATCH] mo deserts --- .../java/com/terraforged/TerraForgedMod.java | 2 +- src/main/java/com/terraforged/TerraWorld.java | 4 +-- .../api/biome/modifier/BiomeModifier.java | 4 +++ .../biome/modifier/BiomeModifierManager.java | 6 +++-- .../biome/modifier/DesertColorModifier.java | 27 ++++++++----------- .../biome/provider/DesertBiomes.java | 5 ++++ .../biome/surface/DesertSurface.java | 25 ++++++++++++----- .../biome/surface/DunesSurface.java | 2 +- .../chunk/TerraChunkGenerator.java | 2 +- .../com/terraforged/chunk/TerraContext.java | 2 +- .../chunk/util/TerraContainer.java | 9 +------ .../com/terraforged/command/TerraCommand.java | 2 +- .../com/terraforged/data/LangGenerator.java | 2 +- .../com/terraforged/gui/SettingsScreen.java | 4 +-- .../com/terraforged/gui/page/SimplePage.java | 2 +- .../terraforged/gui/page/UpdatablePage.java | 2 +- .../com/terraforged/gui/page/WorldPage.java | 2 +- .../com/terraforged/gui/preview/Preview.java | 6 ++--- .../terraforged/gui/preview/PreviewPage.java | 2 +- .../com/terraforged/gui/preview2/Preview.java | 4 +-- .../terraforged/gui/preview2/PreviewPage.java | 2 +- 21 files changed, 63 insertions(+), 53 deletions(-) diff --git a/src/main/java/com/terraforged/TerraForgedMod.java b/src/main/java/com/terraforged/TerraForgedMod.java index 8c5fede..864a610 100644 --- a/src/main/java/com/terraforged/TerraForgedMod.java +++ b/src/main/java/com/terraforged/TerraForgedMod.java @@ -26,6 +26,7 @@ package com.terraforged; import com.terraforged.api.material.WGTags; +import com.terraforged.chunk.settings.SettingsHelper; import com.terraforged.command.TerraCommand; import com.terraforged.config.ConfigManager; import com.terraforged.data.DataGen; @@ -35,7 +36,6 @@ import com.terraforged.feature.feature.BushFeature; import com.terraforged.feature.feature.DiskFeature; import com.terraforged.feature.feature.FreezeLayer; import com.terraforged.fm.template.TemplateManager; -import com.terraforged.chunk.settings.SettingsHelper; import com.terraforged.util.DataPackFinder; import com.terraforged.util.Environment; import net.minecraft.world.biome.Biomes; diff --git a/src/main/java/com/terraforged/TerraWorld.java b/src/main/java/com/terraforged/TerraWorld.java index 957bb00..2807b0f 100644 --- a/src/main/java/com/terraforged/TerraWorld.java +++ b/src/main/java/com/terraforged/TerraWorld.java @@ -30,11 +30,11 @@ import com.terraforged.chunk.ChunkGeneratorFactory; import com.terraforged.chunk.TerraChunkGenerator; import com.terraforged.chunk.TerraContext; import com.terraforged.chunk.TerraGenSettings; -import com.terraforged.chunk.test.TestChunkGenerator; -import com.terraforged.gui.SettingsScreen; import com.terraforged.chunk.settings.DimesionSettings; import com.terraforged.chunk.settings.SettingsHelper; import com.terraforged.chunk.settings.TerraSettings; +import com.terraforged.chunk.test.TestChunkGenerator; +import com.terraforged.gui.SettingsScreen; import com.terraforged.util.Environment; import com.terraforged.util.nbt.NBTHelper; import com.terraforged.world.terrain.Terrains; 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 9e31607..18e3a9a 100644 --- a/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java +++ b/src/main/java/com/terraforged/api/biome/modifier/BiomeModifier.java @@ -36,6 +36,10 @@ public interface BiomeModifier extends Comparable { Biome modify(Biome in, Cell cell, int x, int z); + default boolean exitEarly() { + return false; + } + @Override default int compareTo(BiomeModifier other) { // reverse order diff --git a/src/main/java/com/terraforged/biome/modifier/BiomeModifierManager.java b/src/main/java/com/terraforged/biome/modifier/BiomeModifierManager.java index 5d2b7e6..dc5219e 100644 --- a/src/main/java/com/terraforged/biome/modifier/BiomeModifierManager.java +++ b/src/main/java/com/terraforged/biome/modifier/BiomeModifierManager.java @@ -48,8 +48,7 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager { desertBiomes = new DesertBiomes(context.materials, biomes.getAllBiomes(BiomeType.DESERT)); List modifiers = new ArrayList<>(); modifiers.add(new CoastModifier(biomes, context)); - modifiers.add(new DesertColorModifier(context, desertBiomes)); - modifiers.add(new SandBiomeModifier(context)); + modifiers.add(new DesertColorModifier(desertBiomes)); modifiers.add(new BeachModifier(biomes, context)); Collections.sort(modifiers); this.biomeModifiers = modifiers; @@ -84,6 +83,9 @@ public class BiomeModifierManager implements BiomeModifier, ModifierManager { for (BiomeModifier modifier : biomeModifiers) { if (modifier.test(biome)) { biome = modifier.modify(biome, cell, x, z); + if (modifier.exitEarly()) { + return biome; + } } } return biome; diff --git a/src/main/java/com/terraforged/biome/modifier/DesertColorModifier.java b/src/main/java/com/terraforged/biome/modifier/DesertColorModifier.java index 8b30087..bd15d0e 100644 --- a/src/main/java/com/terraforged/biome/modifier/DesertColorModifier.java +++ b/src/main/java/com/terraforged/biome/modifier/DesertColorModifier.java @@ -28,23 +28,19 @@ package com.terraforged.biome.modifier; import com.terraforged.api.biome.modifier.BiomeModifier; import com.terraforged.biome.provider.DesertBiomes; import com.terraforged.core.cell.Cell; -import com.terraforged.n2d.Module; -import com.terraforged.n2d.Source; -import com.terraforged.world.GeneratorContext; -import com.terraforged.world.climate.Climate; import net.minecraft.world.biome.Biome; public class DesertColorModifier implements BiomeModifier { - private final Module noise; - private final Climate climate; private final DesertBiomes biomes; - public DesertColorModifier(GeneratorContext context, DesertBiomes biomes) { - int scale = context.settings.terrain.general.terrainRegionSize; + public DesertColorModifier(DesertBiomes biomes) { this.biomes = biomes; - this.climate = context.factory.getClimate(); - this.noise = Source.cell(context.seed.next(), scale * 3).warp(context.seed.next(), scale / 2, 1, scale / 4F); + } + + @Override + public boolean exitEarly() { + return true; } @Override @@ -54,20 +50,19 @@ public class DesertColorModifier implements BiomeModifier { @Override public boolean test(Biome biome) { - return biome.getCategory() == Biome.Category.DESERT; + return biome.getCategory() == Biome.Category.DESERT + || biome.getCategory() == Biome.Category.MESA + || biomes.isDesert(biome); } @Override public Biome modify(Biome in, Cell cell, int x, int z) { - float px = x + climate.getOffsetX(x, z, 12); - float pz = z + climate.getOffsetZ(x, z, 12); - float type = noise.getValue(px, pz); if (biomes.isRedDesert(in)) { - if (type <= 0.5F) { + if (cell.macroNoise <= 0.5F) { return biomes.getWhiteDesert(cell.biome); } } else { - if (type > 0.5F) { + if (cell.macroNoise > 0.5F) { return biomes.getRedDesert(cell.biome); } } diff --git a/src/main/java/com/terraforged/biome/provider/DesertBiomes.java b/src/main/java/com/terraforged/biome/provider/DesertBiomes.java index 835fde0..a12d074 100644 --- a/src/main/java/com/terraforged/biome/provider/DesertBiomes.java +++ b/src/main/java/com/terraforged/biome/provider/DesertBiomes.java @@ -50,6 +50,7 @@ public class DesertBiomes { private final Set reds; private final Set whites; + private final Set deserts; private final List redSand; private final List whiteSand; private final LayerManager layerManager; @@ -76,6 +77,7 @@ public class DesertBiomes { this.layerManager = materials.getLayerManager(); this.whiteSand = new ArrayList<>(white); this.redSand = new ArrayList<>(red); + this.deserts = new HashSet<>(deserts); this.whites = new HashSet<>(white); this.reds = new HashSet<>(red); this.whiteSand.sort(Comparator.comparing(BiomeHelper::getId)); @@ -83,6 +85,9 @@ public class DesertBiomes { this.maxRedIndex = red.size() - 1; this.maxWhiteIndex = white.size() - 1; } + public boolean isDesert(Biome biome) { + return deserts.contains(biome); + } public boolean isRedDesert(Biome biome) { return reds.contains(biome); diff --git a/src/main/java/com/terraforged/biome/surface/DesertSurface.java b/src/main/java/com/terraforged/biome/surface/DesertSurface.java index 69681f6..71afef4 100644 --- a/src/main/java/com/terraforged/biome/surface/DesertSurface.java +++ b/src/main/java/com/terraforged/biome/surface/DesertSurface.java @@ -11,17 +11,21 @@ import net.minecraft.block.Blocks; 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 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(); public DesertSurface(GeneratorContext context) { + min = context.levels.ground(10); + level = context.levels.ground(40); - noise = Source.perlin(context.seed.next(), 10, 1) - .scale(context.levels.scale(10)); + noise = Source.perlin(context.seed.next(), 8, 1) + .scale(context.levels.scale(16)); } @Override @@ -30,15 +34,22 @@ public class DesertSurface implements Surface { return; } - if (ctx.cell.steepness > 0.3 || ctx.cell.value + noise.getValue(x, z) > level) { - BlockState state = States.SANDSTONE.get(); + if (ctx.cell.value < min) { + return; + } - if (ctx.cell.value > level) { - if (ctx.cell.steepness > 0.85) { + float value = ctx.cell.value + noise.getValue(x, z); + if (ctx.cell.steepness > 0.3 || value > level) { + BlockState state = sandstone; + + if (value > level) { + if (ctx.cell.steepness > 0.975) { + state = low; + } else if (ctx.cell.steepness > 0.85) { state = high; } else if (ctx.cell.steepness > 0.75) { state = mid; - } else if (ctx.cell.steepness > 0.625) { + } else if (ctx.cell.steepness > 0.65) { state = low; } } diff --git a/src/main/java/com/terraforged/biome/surface/DunesSurface.java b/src/main/java/com/terraforged/biome/surface/DunesSurface.java index 6487470..f164844 100644 --- a/src/main/java/com/terraforged/biome/surface/DunesSurface.java +++ b/src/main/java/com/terraforged/biome/surface/DunesSurface.java @@ -28,8 +28,8 @@ package com.terraforged.biome.surface; import com.terraforged.api.chunk.surface.Surface; import com.terraforged.api.chunk.surface.SurfaceContext; import com.terraforged.api.material.layer.LayerMaterial; -import com.terraforged.biome.provider.TerraBiomeProvider; import com.terraforged.biome.provider.DesertBiomes; +import com.terraforged.biome.provider.TerraBiomeProvider; import com.terraforged.chunk.TerraContext; import com.terraforged.core.cell.Cell; import com.terraforged.n2d.Module; diff --git a/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java b/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java index fc171c1..02127f3 100644 --- a/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java +++ b/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java @@ -38,8 +38,8 @@ import com.terraforged.chunk.generator.SurfaceGenerator; import com.terraforged.chunk.generator.TerrainCarver; import com.terraforged.chunk.generator.TerrainGenerator; import com.terraforged.core.cell.Cell; -import com.terraforged.core.tile.Tile; import com.terraforged.core.tile.Size; +import com.terraforged.core.tile.Tile; import com.terraforged.core.tile.chunk.ChunkReader; import com.terraforged.core.tile.gen.TileCache; import com.terraforged.feature.BlockDataManager; diff --git a/src/main/java/com/terraforged/chunk/TerraContext.java b/src/main/java/com/terraforged/chunk/TerraContext.java index f6f4d42..d2fa621 100644 --- a/src/main/java/com/terraforged/chunk/TerraContext.java +++ b/src/main/java/com/terraforged/chunk/TerraContext.java @@ -29,12 +29,12 @@ import com.electronwill.nightconfig.core.CommentedConfig; import com.terraforged.api.chunk.column.DecoratorContext; import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer; import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.config.PerfDefaults; import com.terraforged.core.concurrent.thread.ThreadPools; import com.terraforged.core.tile.gen.TileCache; import com.terraforged.core.tile.gen.TileGenerator; import com.terraforged.material.Materials; -import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.world.GeneratorContext; import com.terraforged.world.WorldGeneratorFactory; import com.terraforged.world.heightmap.Heightmap; diff --git a/src/main/java/com/terraforged/chunk/util/TerraContainer.java b/src/main/java/com/terraforged/chunk/util/TerraContainer.java index 242ed09..297abf9 100644 --- a/src/main/java/com/terraforged/chunk/util/TerraContainer.java +++ b/src/main/java/com/terraforged/chunk/util/TerraContainer.java @@ -68,14 +68,7 @@ public class TerraContainer extends BiomeContainer { return (TerraContainer) biomes; } - TerraContainer container; - if (biomes == null) { - // create new container based on the provided ChunkReader - container = TerraContainer.create(reader, biomeProvider); - } else { - // converts an existing non-tf biome container into one that TerraForged can use - container = TerraContainer.convert(chunk.getPos(), biomes, biomeProvider); - } + TerraContainer container = TerraContainer.create(reader, biomeProvider); // replace/set the primer's biomes ((ChunkPrimer) chunk).func_225548_a_(container); diff --git a/src/main/java/com/terraforged/command/TerraCommand.java b/src/main/java/com/terraforged/command/TerraCommand.java index aeb419b..47987c7 100644 --- a/src/main/java/com/terraforged/command/TerraCommand.java +++ b/src/main/java/com/terraforged/command/TerraCommand.java @@ -35,6 +35,7 @@ import com.terraforged.Log; import com.terraforged.biome.provider.TerraBiomeProvider; import com.terraforged.chunk.TerraChunkGenerator; import com.terraforged.chunk.TerraContext; +import com.terraforged.chunk.settings.SettingsHelper; import com.terraforged.command.arg.BiomeArgType; import com.terraforged.command.arg.TerrainArgType; import com.terraforged.command.search.BiomeSearchTask; @@ -44,7 +45,6 @@ import com.terraforged.command.search.TerrainSearchTask; import com.terraforged.core.cell.Cell; import com.terraforged.core.concurrent.Resource; import com.terraforged.data.DataGen; -import com.terraforged.chunk.settings.SettingsHelper; import com.terraforged.world.WorldGenerator; import com.terraforged.world.terrain.Terrain; import com.terraforged.world.terrain.Terrains; diff --git a/src/main/java/com/terraforged/data/LangGenerator.java b/src/main/java/com/terraforged/data/LangGenerator.java index 99130de..5fe97ad 100644 --- a/src/main/java/com/terraforged/data/LangGenerator.java +++ b/src/main/java/com/terraforged/data/LangGenerator.java @@ -1,8 +1,8 @@ package com.terraforged.data; +import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.core.util.NameUtil; import com.terraforged.gui.preview2.PreviewSettings; -import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.util.nbt.NBTHelper; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.INBT; diff --git a/src/main/java/com/terraforged/gui/SettingsScreen.java b/src/main/java/com/terraforged/gui/SettingsScreen.java index 01bb69c..772d1d0 100644 --- a/src/main/java/com/terraforged/gui/SettingsScreen.java +++ b/src/main/java/com/terraforged/gui/SettingsScreen.java @@ -25,6 +25,8 @@ package com.terraforged.gui; +import com.terraforged.chunk.settings.SettingsHelper; +import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.gui.element.TerraLabel; import com.terraforged.gui.page.Page; import com.terraforged.gui.page.PresetsPage; @@ -32,8 +34,6 @@ import com.terraforged.gui.page.SimplePage; import com.terraforged.gui.page.SimplePreviewPage; import com.terraforged.gui.page.WorldPage; import com.terraforged.gui.preview2.PreviewPage; -import com.terraforged.chunk.settings.SettingsHelper; -import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.util.nbt.NBTHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.IGuiEventListener; diff --git a/src/main/java/com/terraforged/gui/page/SimplePage.java b/src/main/java/com/terraforged/gui/page/SimplePage.java index ea8f7d8..3f976d7 100644 --- a/src/main/java/com/terraforged/gui/page/SimplePage.java +++ b/src/main/java/com/terraforged/gui/page/SimplePage.java @@ -1,7 +1,7 @@ package com.terraforged.gui.page; -import com.terraforged.gui.OverlayScreen; import com.terraforged.chunk.settings.TerraSettings; +import com.terraforged.gui.OverlayScreen; import com.terraforged.util.nbt.NBTHelper; import net.minecraft.nbt.CompoundNBT; diff --git a/src/main/java/com/terraforged/gui/page/UpdatablePage.java b/src/main/java/com/terraforged/gui/page/UpdatablePage.java index 6b02abd..8b612b7 100644 --- a/src/main/java/com/terraforged/gui/page/UpdatablePage.java +++ b/src/main/java/com/terraforged/gui/page/UpdatablePage.java @@ -1,7 +1,7 @@ package com.terraforged.gui.page; -import com.terraforged.gui.OverlayScreen; import com.terraforged.chunk.settings.TerraSettings; +import com.terraforged.gui.OverlayScreen; import java.util.function.Consumer; diff --git a/src/main/java/com/terraforged/gui/page/WorldPage.java b/src/main/java/com/terraforged/gui/page/WorldPage.java index 7f1fd81..bba7edb 100644 --- a/src/main/java/com/terraforged/gui/page/WorldPage.java +++ b/src/main/java/com/terraforged/gui/page/WorldPage.java @@ -26,9 +26,9 @@ package com.terraforged.gui.page; import com.terraforged.TerraWorld; +import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.gui.OverlayScreen; import com.terraforged.gui.element.TerraTextInput; -import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.util.nbt.NBTHelper; import net.minecraft.client.gui.widget.Widget; import net.minecraft.nbt.CompoundNBT; diff --git a/src/main/java/com/terraforged/gui/preview/Preview.java b/src/main/java/com/terraforged/gui/preview/Preview.java index 9a24c78..da54382 100644 --- a/src/main/java/com/terraforged/gui/preview/Preview.java +++ b/src/main/java/com/terraforged/gui/preview/Preview.java @@ -30,10 +30,10 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.terraforged.core.cell.Cell; import com.terraforged.core.concurrent.cache.CacheEntry; import com.terraforged.core.concurrent.thread.ThreadPools; -import com.terraforged.core.tile.Tile; -import com.terraforged.core.tile.Size; -import com.terraforged.core.tile.gen.TileGenerator; import com.terraforged.core.settings.Settings; +import com.terraforged.core.tile.Size; +import com.terraforged.core.tile.Tile; +import com.terraforged.core.tile.gen.TileGenerator; import com.terraforged.n2d.util.NoiseUtil; import com.terraforged.util.nbt.NBTHelper; import com.terraforged.world.GeneratorContext; diff --git a/src/main/java/com/terraforged/gui/preview/PreviewPage.java b/src/main/java/com/terraforged/gui/preview/PreviewPage.java index 31276aa..0c1bab5 100644 --- a/src/main/java/com/terraforged/gui/preview/PreviewPage.java +++ b/src/main/java/com/terraforged/gui/preview/PreviewPage.java @@ -25,10 +25,10 @@ package com.terraforged.gui.preview; +import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.gui.OverlayScreen; import com.terraforged.gui.element.TerraButton; import com.terraforged.gui.page.UpdatablePage; -import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.util.nbt.NBTHelper; import net.minecraft.nbt.CompoundNBT; diff --git a/src/main/java/com/terraforged/gui/preview2/Preview.java b/src/main/java/com/terraforged/gui/preview2/Preview.java index 0c99623..a9b9d23 100644 --- a/src/main/java/com/terraforged/gui/preview2/Preview.java +++ b/src/main/java/com/terraforged/gui/preview2/Preview.java @@ -1,13 +1,13 @@ package com.terraforged.gui.preview2; import com.mojang.blaze3d.systems.RenderSystem; +import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.core.concurrent.thread.ThreadPool; import com.terraforged.core.concurrent.thread.ThreadPools; -import com.terraforged.core.tile.gen.TileGenerator; import com.terraforged.core.render.RenderAPI; import com.terraforged.core.render.RenderSettings; import com.terraforged.core.render.RenderWorld; -import com.terraforged.chunk.settings.TerraSettings; +import com.terraforged.core.tile.gen.TileGenerator; import com.terraforged.world.GeneratorContext; import com.terraforged.world.continent.MutableVeci; import com.terraforged.world.continent.SpawnType; diff --git a/src/main/java/com/terraforged/gui/preview2/PreviewPage.java b/src/main/java/com/terraforged/gui/preview2/PreviewPage.java index 7f2bcc0..4f466bd 100644 --- a/src/main/java/com/terraforged/gui/preview2/PreviewPage.java +++ b/src/main/java/com/terraforged/gui/preview2/PreviewPage.java @@ -1,9 +1,9 @@ package com.terraforged.gui.preview2; +import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.gui.OverlayScreen; import com.terraforged.gui.element.TerraButton; import com.terraforged.gui.page.UpdatablePage; -import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.util.nbt.NBTHelper; import net.minecraft.nbt.CompoundNBT;