From e37d6bce63b041173e977e7273915734330c0863 Mon Sep 17 00:00:00 2001 From: dags- Date: Thu, 25 Jun 2020 19:35:57 +0100 Subject: [PATCH] - show map on presets page - interface out 'masked surfaces' --- .../surface/CachedSurface.java | 2 +- .../surface/ChunkSurfaceBuffer.java | 2 +- .../api/biome/surface/MaskedSurface.java | 18 +++++++ .../api/{chunk => biome}/surface/Surface.java | 4 +- .../surface/SurfaceContext.java | 2 +- .../surface/SurfaceManager.java | 4 +- .../surface/builder/Combiner.java | 6 +-- .../surface/builder/Delegate.java | 6 +-- .../api/chunk/column/ColumnDecorator.java | 2 +- .../com/terraforged/api/event/SetupEvent.java | 2 +- .../java/com/terraforged/biome/Bryce.java | 6 +++ .../com/terraforged/biome/StoneForest.java | 2 +- .../biome/surface/BriceSurface.java | 18 +++---- .../biome/surface/DesertSurface.java | 4 +- .../biome/surface/DunesSurface.java | 20 ++++---- .../biome/surface/ForestSurface.java | 4 +- .../biome/surface/IcebergsSurface.java | 47 +++++++++---------- .../biome/surface/SteppeSurface.java | 4 +- .../biome/surface/StoneForestSurface.java | 17 ++++--- .../biome/surface/SwampSurface.java | 4 +- .../chunk/TerraChunkGenerator.java | 2 +- .../com/terraforged/chunk/TerraContext.java | 4 +- .../terraforged/chunk/TerraSetupFactory.java | 2 +- .../chunk/column/GeologyDecorator.java | 2 +- .../chunk/generator/SurfaceGenerator.java | 4 +- .../com/terraforged/gui/SettingsScreen.java | 2 +- .../com/terraforged/gui/page/PresetsPage.java | 34 +++++++++++++- .../terraforged/gui/preview/PreviewPage.java | 4 ++ .../terraforged/util/setup/SetupHooks.java | 2 +- 29 files changed, 146 insertions(+), 84 deletions(-) rename src/main/java/com/terraforged/api/{chunk => biome}/surface/CachedSurface.java (96%) rename src/main/java/com/terraforged/api/{chunk => biome}/surface/ChunkSurfaceBuffer.java (98%) create mode 100644 src/main/java/com/terraforged/api/biome/surface/MaskedSurface.java rename src/main/java/com/terraforged/api/{chunk => biome}/surface/Surface.java (94%) rename src/main/java/com/terraforged/api/{chunk => biome}/surface/SurfaceContext.java (97%) rename src/main/java/com/terraforged/api/{chunk => biome}/surface/SurfaceManager.java (97%) rename src/main/java/com/terraforged/api/{chunk => biome}/surface/builder/Combiner.java (90%) rename src/main/java/com/terraforged/api/{chunk => biome}/surface/builder/Delegate.java (93%) diff --git a/src/main/java/com/terraforged/api/chunk/surface/CachedSurface.java b/src/main/java/com/terraforged/api/biome/surface/CachedSurface.java similarity index 96% rename from src/main/java/com/terraforged/api/chunk/surface/CachedSurface.java rename to src/main/java/com/terraforged/api/biome/surface/CachedSurface.java index 8bda7b8..12cd9d6 100644 --- a/src/main/java/com/terraforged/api/chunk/surface/CachedSurface.java +++ b/src/main/java/com/terraforged/api/biome/surface/CachedSurface.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package com.terraforged.api.chunk.surface; +package com.terraforged.api.biome.surface; import net.minecraft.world.biome.Biome; diff --git a/src/main/java/com/terraforged/api/chunk/surface/ChunkSurfaceBuffer.java b/src/main/java/com/terraforged/api/biome/surface/ChunkSurfaceBuffer.java similarity index 98% rename from src/main/java/com/terraforged/api/chunk/surface/ChunkSurfaceBuffer.java rename to src/main/java/com/terraforged/api/biome/surface/ChunkSurfaceBuffer.java index bbc3888..29d4833 100644 --- a/src/main/java/com/terraforged/api/chunk/surface/ChunkSurfaceBuffer.java +++ b/src/main/java/com/terraforged/api/biome/surface/ChunkSurfaceBuffer.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package com.terraforged.api.chunk.surface; +package com.terraforged.api.biome.surface; import com.terraforged.api.chunk.ChunkDelegate; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/terraforged/api/biome/surface/MaskedSurface.java b/src/main/java/com/terraforged/api/biome/surface/MaskedSurface.java new file mode 100644 index 0000000..700f47f --- /dev/null +++ b/src/main/java/com/terraforged/api/biome/surface/MaskedSurface.java @@ -0,0 +1,18 @@ +package com.terraforged.api.biome.surface; + +import com.terraforged.core.cell.Cell; +import com.terraforged.n2d.util.NoiseUtil; + +public interface MaskedSurface extends Surface { + + default float getMask(Cell cell) { + return cell.biomeEdge * NoiseUtil.map(cell.riverMask,0, 0.0005F, 0.0005F); + } + + @Override + default void buildSurface(int x, int z, int height, SurfaceContext ctx) { + buildSurface(x, z, height, getMask(ctx.cell), ctx); + } + + void buildSurface(int x, int z, int height, float mask, SurfaceContext ctx); +} diff --git a/src/main/java/com/terraforged/api/chunk/surface/Surface.java b/src/main/java/com/terraforged/api/biome/surface/Surface.java similarity index 94% rename from src/main/java/com/terraforged/api/chunk/surface/Surface.java rename to src/main/java/com/terraforged/api/biome/surface/Surface.java index 2fd3ede..c3efb73 100644 --- a/src/main/java/com/terraforged/api/chunk/surface/Surface.java +++ b/src/main/java/com/terraforged/api/biome/surface/Surface.java @@ -23,10 +23,10 @@ * SOFTWARE. */ -package com.terraforged.api.chunk.surface; +package com.terraforged.api.biome.surface; -import com.terraforged.api.chunk.surface.builder.Combiner; +import com.terraforged.api.biome.surface.builder.Combiner; import net.minecraft.block.BlockState; import net.minecraft.world.chunk.IChunk; diff --git a/src/main/java/com/terraforged/api/chunk/surface/SurfaceContext.java b/src/main/java/com/terraforged/api/biome/surface/SurfaceContext.java similarity index 97% rename from src/main/java/com/terraforged/api/chunk/surface/SurfaceContext.java rename to src/main/java/com/terraforged/api/biome/surface/SurfaceContext.java index 4b98116..e9e69fd 100644 --- a/src/main/java/com/terraforged/api/chunk/surface/SurfaceContext.java +++ b/src/main/java/com/terraforged/api/biome/surface/SurfaceContext.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package com.terraforged.api.chunk.surface; +package com.terraforged.api.biome.surface; import com.terraforged.api.chunk.column.DecoratorContext; import com.terraforged.world.climate.Climate; diff --git a/src/main/java/com/terraforged/api/chunk/surface/SurfaceManager.java b/src/main/java/com/terraforged/api/biome/surface/SurfaceManager.java similarity index 97% rename from src/main/java/com/terraforged/api/chunk/surface/SurfaceManager.java rename to src/main/java/com/terraforged/api/biome/surface/SurfaceManager.java index 1798853..4665908 100644 --- a/src/main/java/com/terraforged/api/chunk/surface/SurfaceManager.java +++ b/src/main/java/com/terraforged/api/biome/surface/SurfaceManager.java @@ -23,9 +23,9 @@ * SOFTWARE. */ -package com.terraforged.api.chunk.surface; +package com.terraforged.api.biome.surface; -import com.terraforged.api.chunk.surface.builder.Delegate; +import com.terraforged.api.biome.surface.builder.Delegate; import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.Biome; diff --git a/src/main/java/com/terraforged/api/chunk/surface/builder/Combiner.java b/src/main/java/com/terraforged/api/biome/surface/builder/Combiner.java similarity index 90% rename from src/main/java/com/terraforged/api/chunk/surface/builder/Combiner.java rename to src/main/java/com/terraforged/api/biome/surface/builder/Combiner.java index fdc7015..ea54e60 100644 --- a/src/main/java/com/terraforged/api/chunk/surface/builder/Combiner.java +++ b/src/main/java/com/terraforged/api/biome/surface/builder/Combiner.java @@ -23,10 +23,10 @@ * SOFTWARE. */ -package com.terraforged.api.chunk.surface.builder; +package com.terraforged.api.biome.surface.builder; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.Surface; +import com.terraforged.api.biome.surface.SurfaceContext; public class Combiner implements Surface { diff --git a/src/main/java/com/terraforged/api/chunk/surface/builder/Delegate.java b/src/main/java/com/terraforged/api/biome/surface/builder/Delegate.java similarity index 93% rename from src/main/java/com/terraforged/api/chunk/surface/builder/Delegate.java rename to src/main/java/com/terraforged/api/biome/surface/builder/Delegate.java index bfea46a..2972db4 100644 --- a/src/main/java/com/terraforged/api/chunk/surface/builder/Delegate.java +++ b/src/main/java/com/terraforged/api/biome/surface/builder/Delegate.java @@ -23,10 +23,10 @@ * SOFTWARE. */ -package com.terraforged.api.chunk.surface.builder; +package com.terraforged.api.biome.surface.builder; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.Surface; +import com.terraforged.api.biome.surface.SurfaceContext; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilder; diff --git a/src/main/java/com/terraforged/api/chunk/column/ColumnDecorator.java b/src/main/java/com/terraforged/api/chunk/column/ColumnDecorator.java index a251995..b26a718 100644 --- a/src/main/java/com/terraforged/api/chunk/column/ColumnDecorator.java +++ b/src/main/java/com/terraforged/api/chunk/column/ColumnDecorator.java @@ -25,7 +25,7 @@ package com.terraforged.api.chunk.column; -import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer; +import com.terraforged.api.biome.surface.ChunkSurfaceBuffer; import com.terraforged.n2d.Source; import com.terraforged.n2d.source.FastSource; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/terraforged/api/event/SetupEvent.java b/src/main/java/com/terraforged/api/event/SetupEvent.java index 4491fd6..f9333e8 100644 --- a/src/main/java/com/terraforged/api/event/SetupEvent.java +++ b/src/main/java/com/terraforged/api/event/SetupEvent.java @@ -27,7 +27,7 @@ package com.terraforged.api.event; import com.terraforged.api.biome.modifier.ModifierManager; import com.terraforged.api.chunk.column.DecoratorManager; -import com.terraforged.api.chunk.surface.SurfaceManager; +import com.terraforged.api.biome.surface.SurfaceManager; import com.terraforged.api.material.geology.GeologyManager; import com.terraforged.api.material.layer.LayerManager; import com.terraforged.fm.modifier.FeatureModifiers; diff --git a/src/main/java/com/terraforged/biome/Bryce.java b/src/main/java/com/terraforged/biome/Bryce.java index 775eb16..a792e88 100644 --- a/src/main/java/com/terraforged/biome/Bryce.java +++ b/src/main/java/com/terraforged/biome/Bryce.java @@ -11,6 +11,7 @@ import net.minecraft.world.gen.feature.IFeatureConfig; import net.minecraft.world.gen.feature.structure.MineshaftConfig; import net.minecraft.world.gen.feature.structure.MineshaftStructure; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; +import net.minecraftforge.common.BiomeManager; public class Bryce extends BiomeVariant { @@ -43,6 +44,11 @@ public class Bryce extends BiomeVariant { this.addSpawn(EntityClassification.MONSTER, new Biome.SpawnListEntry(EntityType.WITCH, 5, 1, 1)); } + @Override + public void registerWeights() { + BiomeManager.addBiome(BiomeManager.BiomeType.WARM, new BiomeManager.BiomeEntry(this, 2)); + } + @Override public Biome getBase() { return Biomes.BADLANDS; diff --git a/src/main/java/com/terraforged/biome/StoneForest.java b/src/main/java/com/terraforged/biome/StoneForest.java index 81267eb..edca0e2 100644 --- a/src/main/java/com/terraforged/biome/StoneForest.java +++ b/src/main/java/com/terraforged/biome/StoneForest.java @@ -57,7 +57,7 @@ public class StoneForest extends BiomeVariant { @Override public void registerWeights() { - BiomeManager.addBiome(BiomeManager.BiomeType.WARM, new BiomeManager.BiomeEntry(this, 5)); + BiomeManager.addBiome(BiomeManager.BiomeType.WARM, new BiomeManager.BiomeEntry(this, 2)); } @Override diff --git a/src/main/java/com/terraforged/biome/surface/BriceSurface.java b/src/main/java/com/terraforged/biome/surface/BriceSurface.java index 2d35dc8..99dade5 100644 --- a/src/main/java/com/terraforged/biome/surface/BriceSurface.java +++ b/src/main/java/com/terraforged/biome/surface/BriceSurface.java @@ -1,19 +1,18 @@ package com.terraforged.biome.surface; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.MaskedSurface; +import com.terraforged.api.biome.surface.SurfaceContext; import com.terraforged.core.Seed; import com.terraforged.core.util.Variance; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; -import com.terraforged.n2d.util.NoiseUtil; import com.terraforged.world.geology.Strata; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import java.util.Random; -public class BriceSurface implements Surface { +public class BriceSurface implements MaskedSurface { private final Module module; private final Strata stackStrata; @@ -38,11 +37,14 @@ public class BriceSurface implements Surface { } @Override - public void buildSurface(int x, int z, int height, SurfaceContext ctx) { - float alpha = 1 - ctx.cell.steepness; - float mask = alpha * ctx.cell.biomeEdge * NoiseUtil.map(ctx.cell.riverMask,0, 0.0005F, 0.0005F); - float value = module.getValue(x, z) * mask; + public void buildSurface(int x, int z, int height, float mask, SurfaceContext ctx) { + float strength = 1 - ctx.cell.steepness; + float value = module.getValue(x, z) * mask * strength; + int top = (int) (value * 30); + if (top == 0) { + return; + } stackStrata.downwards(x, top, z, ctx.depthBuffer.get(), (y, material) -> { if (y <= 0) { diff --git a/src/main/java/com/terraforged/biome/surface/DesertSurface.java b/src/main/java/com/terraforged/biome/surface/DesertSurface.java index 7f10c62..27eedea 100644 --- a/src/main/java/com/terraforged/biome/surface/DesertSurface.java +++ b/src/main/java/com/terraforged/biome/surface/DesertSurface.java @@ -1,7 +1,7 @@ package com.terraforged.biome.surface; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.Surface; +import com.terraforged.api.biome.surface.SurfaceContext; import com.terraforged.api.material.state.States; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; diff --git a/src/main/java/com/terraforged/biome/surface/DunesSurface.java b/src/main/java/com/terraforged/biome/surface/DunesSurface.java index f164844..ad68057 100644 --- a/src/main/java/com/terraforged/biome/surface/DunesSurface.java +++ b/src/main/java/com/terraforged/biome/surface/DunesSurface.java @@ -25,8 +25,9 @@ package com.terraforged.biome.surface; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.MaskedSurface; +import com.terraforged.api.biome.surface.Surface; +import com.terraforged.api.biome.surface.SurfaceContext; import com.terraforged.api.material.layer.LayerMaterial; import com.terraforged.biome.provider.DesertBiomes; import com.terraforged.biome.provider.TerraBiomeProvider; @@ -43,7 +44,7 @@ import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.gen.Heightmap; -public class DunesSurface implements Surface { +public class DunesSurface implements MaskedSurface { private final int maxHeight; private final Levels levels; @@ -63,8 +64,13 @@ public class DunesSurface implements Surface { } @Override - public void buildSurface(int x, int z, int surface, SurfaceContext ctx) { - float value = module.getValue(x, z) * getMask(ctx.cell); + public float getMask(Cell cell) { + return NoiseUtil.map(cell.biomeEdge, 0, 0.7F, 0.7F) * NoiseUtil.map(cell.riverMask, 0.5F, 0.95F, 0.45F); + } + + @Override + public void buildSurface(int x, int z, int surface, float mask, SurfaceContext ctx) { + float value = module.getValue(x, z) * mask; float baseHeight = ctx.chunk.getTopBlockY(Heightmap.Type.WORLD_SURFACE_WG, x & 15, z & 15); float duneHeight = baseHeight + value * maxHeight; int duneBase = (int) baseHeight; @@ -94,8 +100,4 @@ public class DunesSurface implements Surface { public static Surface create(TerraContext context, DesertBiomes desertBiomes) { return new DunesSurface(context, 25, desertBiomes); } - - private static float getMask(Cell cell) { - return cell.biomeMask(0F, 0.7F) * (NoiseUtil.map(cell.riverMask, 0.5F, 0.95F, 0.45F)); - } } diff --git a/src/main/java/com/terraforged/biome/surface/ForestSurface.java b/src/main/java/com/terraforged/biome/surface/ForestSurface.java index 041914f..dcf73bd 100644 --- a/src/main/java/com/terraforged/biome/surface/ForestSurface.java +++ b/src/main/java/com/terraforged/biome/surface/ForestSurface.java @@ -1,7 +1,7 @@ package com.terraforged.biome.surface; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.Surface; +import com.terraforged.api.biome.surface.SurfaceContext; import com.terraforged.api.material.state.States; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; diff --git a/src/main/java/com/terraforged/biome/surface/IcebergsSurface.java b/src/main/java/com/terraforged/biome/surface/IcebergsSurface.java index 05b6d87..91647f8 100644 --- a/src/main/java/com/terraforged/biome/surface/IcebergsSurface.java +++ b/src/main/java/com/terraforged/biome/surface/IcebergsSurface.java @@ -25,8 +25,8 @@ package com.terraforged.biome.surface; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.MaskedSurface; +import com.terraforged.api.biome.surface.SurfaceContext; import com.terraforged.api.material.state.States; import com.terraforged.chunk.TerraContext; import com.terraforged.core.cell.Cell; @@ -38,7 +38,7 @@ import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; -public class IcebergsSurface implements Surface { +public class IcebergsSurface implements MaskedSurface { private final Module up; private final Module down; @@ -85,13 +85,28 @@ public class IcebergsSurface implements Surface { } @Override - public void buildSurface(int x, int z, int height, SurfaceContext ctx) { - float alpha = alpha(ctx.cell); + public float getMask(Cell cell) { + if (cell.value > minDepth) { + return 0; + } + float alpha = 1F; + float delta = minDepth - cell.value; + if (delta < depthRange) { + alpha -= ((depthRange - delta) / depthRange); + } + + alpha *= NoiseUtil.map(cell.riverMask, 0.3F, 1F, 0.7F); + + return NoiseUtil.clamp(alpha, 0, 1); + } + + @Override + public void buildSurface(int x, int z, int height, float mask, SurfaceContext ctx) { int center = levels.waterLevel - 5; - int top = center + (int) (up.getValue(x, z) * levels.worldHeight * alpha); - int topDepth = (int) (bergTop.getValue(x, z) * levels.worldHeight * alpha); - int bottom = center - (int) (down.getValue(x, z) * levels.worldHeight * alpha); + int top = center + (int) (up.getValue(x, z) * levels.worldHeight * mask); + int topDepth = (int) (bergTop.getValue(x, z) * levels.worldHeight * mask); + int bottom = center - (int) (down.getValue(x, z) * levels.worldHeight * mask); // set iceberg materials BlockPos.Mutable pos = new BlockPos.Mutable(x, height, z); @@ -116,20 +131,4 @@ public class IcebergsSurface implements Surface { } return States.PACKED_ICE.get(); } - - private float alpha(Cell cell) { - if (cell.value > minDepth) { - return 0; - } - - float alpha = 1F; - float delta = minDepth - cell.value; - if (delta < depthRange) { - alpha -= ((depthRange - delta) / depthRange); - } - - alpha *= NoiseUtil.map(cell.riverMask, 0.3F, 1F, 0.7F); - - return NoiseUtil.clamp(alpha, 0, 1); - } } diff --git a/src/main/java/com/terraforged/biome/surface/SteppeSurface.java b/src/main/java/com/terraforged/biome/surface/SteppeSurface.java index 8b0a37d..d7d5c87 100644 --- a/src/main/java/com/terraforged/biome/surface/SteppeSurface.java +++ b/src/main/java/com/terraforged/biome/surface/SteppeSurface.java @@ -1,7 +1,7 @@ package com.terraforged.biome.surface; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.Surface; +import com.terraforged.api.biome.surface.SurfaceContext; import com.terraforged.api.material.state.States; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; diff --git a/src/main/java/com/terraforged/biome/surface/StoneForestSurface.java b/src/main/java/com/terraforged/biome/surface/StoneForestSurface.java index c7355b3..e4c1b66 100644 --- a/src/main/java/com/terraforged/biome/surface/StoneForestSurface.java +++ b/src/main/java/com/terraforged/biome/surface/StoneForestSurface.java @@ -1,15 +1,14 @@ package com.terraforged.biome.surface; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.MaskedSurface; +import com.terraforged.api.biome.surface.SurfaceContext; import com.terraforged.api.material.state.States; import com.terraforged.core.Seed; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; -import com.terraforged.n2d.util.NoiseUtil; import net.minecraft.block.BlockState; -public class StoneForestSurface implements Surface { +public class StoneForestSurface implements MaskedSurface { private final Module module; private final BlockState dirt; @@ -27,12 +26,12 @@ public class StoneForestSurface implements Surface { } @Override - public void buildSurface(int x, int z, int height, SurfaceContext ctx) { - float alpha = 1 - ctx.cell.steepness; - float mask = alpha * ctx.cell.biomeEdge * NoiseUtil.map(ctx.cell.riverMask,0, 0.0005F, 0.0005F); - float value = module.getValue(x, z) * mask; - int top = height + (int) (value * 50); + public void buildSurface(int x, int z, int height, float mask, SurfaceContext ctx) { + // reduce height on steeper terrain + float strength = 1 - ctx.cell.steepness; + float value = module.getValue(x, z) * mask * strength; + int top = height + (int) (value * 50); if (top > height) { for (int y = height; y < top - 1; y++) { ctx.buffer.setBlockState(ctx.pos.setPos(x, y, z), stone, false); diff --git a/src/main/java/com/terraforged/biome/surface/SwampSurface.java b/src/main/java/com/terraforged/biome/surface/SwampSurface.java index 8869bba..8b7c42a 100644 --- a/src/main/java/com/terraforged/biome/surface/SwampSurface.java +++ b/src/main/java/com/terraforged/biome/surface/SwampSurface.java @@ -1,7 +1,7 @@ package com.terraforged.biome.surface; -import com.terraforged.api.chunk.surface.Surface; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.Surface; +import com.terraforged.api.biome.surface.SurfaceContext; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig; diff --git a/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java b/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java index 02127f3..ff25c28 100644 --- a/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java +++ b/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java @@ -26,7 +26,7 @@ package com.terraforged.chunk; import com.terraforged.api.chunk.column.ColumnDecorator; -import com.terraforged.api.chunk.surface.SurfaceManager; +import com.terraforged.api.biome.surface.SurfaceManager; import com.terraforged.api.material.layer.LayerManager; import com.terraforged.biome.provider.TerraBiomeProvider; import com.terraforged.chunk.generator.BiomeGenerator; diff --git a/src/main/java/com/terraforged/chunk/TerraContext.java b/src/main/java/com/terraforged/chunk/TerraContext.java index 182ab93..fb6cbbf 100644 --- a/src/main/java/com/terraforged/chunk/TerraContext.java +++ b/src/main/java/com/terraforged/chunk/TerraContext.java @@ -27,8 +27,8 @@ package com.terraforged.chunk; 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.api.biome.surface.ChunkSurfaceBuffer; +import com.terraforged.api.biome.surface.SurfaceContext; import com.terraforged.chunk.settings.TerraSettings; import com.terraforged.config.PerfDefaults; import com.terraforged.core.concurrent.thread.ThreadPools; diff --git a/src/main/java/com/terraforged/chunk/TerraSetupFactory.java b/src/main/java/com/terraforged/chunk/TerraSetupFactory.java index 6525e29..66f59e0 100644 --- a/src/main/java/com/terraforged/chunk/TerraSetupFactory.java +++ b/src/main/java/com/terraforged/chunk/TerraSetupFactory.java @@ -2,7 +2,7 @@ package com.terraforged.chunk; import com.terraforged.Log; import com.terraforged.api.chunk.column.ColumnDecorator; -import com.terraforged.api.chunk.surface.SurfaceManager; +import com.terraforged.api.biome.surface.SurfaceManager; import com.terraforged.biome.ModBiomes; import com.terraforged.biome.surface.BriceSurface; import com.terraforged.biome.surface.DesertSurface; diff --git a/src/main/java/com/terraforged/chunk/column/GeologyDecorator.java b/src/main/java/com/terraforged/chunk/column/GeologyDecorator.java index b0eb2ea..d65a506 100644 --- a/src/main/java/com/terraforged/chunk/column/GeologyDecorator.java +++ b/src/main/java/com/terraforged/chunk/column/GeologyDecorator.java @@ -27,7 +27,7 @@ package com.terraforged.chunk.column; import com.terraforged.api.chunk.column.ColumnDecorator; import com.terraforged.api.chunk.column.DecoratorContext; -import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer; +import com.terraforged.api.biome.surface.ChunkSurfaceBuffer; import com.terraforged.material.geology.GeoManager; import net.minecraft.world.chunk.IChunk; diff --git a/src/main/java/com/terraforged/chunk/generator/SurfaceGenerator.java b/src/main/java/com/terraforged/chunk/generator/SurfaceGenerator.java index 8fe96ef..2ca1811 100644 --- a/src/main/java/com/terraforged/chunk/generator/SurfaceGenerator.java +++ b/src/main/java/com/terraforged/chunk/generator/SurfaceGenerator.java @@ -1,8 +1,8 @@ package com.terraforged.chunk.generator; import com.terraforged.api.chunk.column.ColumnDecorator; -import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer; -import com.terraforged.api.chunk.surface.SurfaceContext; +import com.terraforged.api.biome.surface.ChunkSurfaceBuffer; +import com.terraforged.api.biome.surface.SurfaceContext; import com.terraforged.chunk.TerraChunkGenerator; import com.terraforged.chunk.util.FastChunk; import com.terraforged.chunk.util.TerraContainer; diff --git a/src/main/java/com/terraforged/gui/SettingsScreen.java b/src/main/java/com/terraforged/gui/SettingsScreen.java index 7ab6507..eded999 100644 --- a/src/main/java/com/terraforged/gui/SettingsScreen.java +++ b/src/main/java/com/terraforged/gui/SettingsScreen.java @@ -61,7 +61,7 @@ public class SettingsScreen extends OverlayScreen { this.instance = new Instance(settings); this.preview = new PreviewPage(instance.settings, getSeed(parent)); this.pages = new Page[]{ - new PresetsPage(instance, preview), + new PresetsPage(instance, preview, preview.getPreviewWidget()), new WorldPage(instance, preview), new SimplePreviewPage("Climate Settings", "climate", preview, instance, s -> s.climate), new SimplePreviewPage("Terrain Settings", "terrain", preview, instance, s -> s.terrain), diff --git a/src/main/java/com/terraforged/gui/page/PresetsPage.java b/src/main/java/com/terraforged/gui/page/PresetsPage.java index fa35dde..5c98692 100644 --- a/src/main/java/com/terraforged/gui/page/PresetsPage.java +++ b/src/main/java/com/terraforged/gui/page/PresetsPage.java @@ -10,6 +10,7 @@ import com.terraforged.gui.element.TerraButton; import com.terraforged.gui.element.TerraLabel; import com.terraforged.gui.element.TerraTextInput; import com.terraforged.util.nbt.NBTHelper; +import net.minecraft.client.gui.widget.Widget; import net.minecraft.nbt.CompoundNBT; import java.util.Optional; @@ -22,13 +23,15 @@ public class PresetsPage extends BasePage { private final Instance instance; private final UpdatablePage preview; + private final Widget previewWidget; private final TerraTextInput nameInput; private final PresetManager manager = PresetManager.load(); - public PresetsPage(Instance instance, UpdatablePage preview) { + public PresetsPage(Instance instance, UpdatablePage preview, Widget widget) { CompoundNBT value = new CompoundNBT(); value.putString("name", ""); this.preview = preview; + this.previewWidget = widget; this.instance = instance; this.nameInput = new TerraTextInput("name", value); this.nameInput.setColorValidator(NAME_VALIDATOR); @@ -79,6 +82,10 @@ public class PresetsPage extends BasePage { manager.add(preset); nameInput.setText(""); + // select newly created preset & load + setSelected(preset); + load(preset); + // update the ui rebuildPresetList(); } @@ -166,6 +173,14 @@ public class PresetsPage extends BasePage { }); } }); + + right.scrollPane.addButton(previewWidget); + + // used to pad the scroll-pane out so that the preview legend scrolls on larger gui scales + TerraButton spacer = createSpacer(); + for (int i = 0; i < 7; i++) { + right.scrollPane.addButton(spacer); + } } private boolean hasSelectedPreset() { @@ -178,6 +193,16 @@ public class PresetsPage extends BasePage { update(); } + private void setSelected(Preset preset) { + ScrollPane pane = getColumn(0).scrollPane; + for (ScrollPane.Entry entry : pane.children()) { + if (entry.option.getMessage().equalsIgnoreCase(preset.getName())) { + pane.setSelected(entry); + return; + } + } + } + private Optional getSelected() { ScrollPane.Entry entry = getColumn(0).scrollPane.getSelected(); if (entry == null) { @@ -195,4 +220,11 @@ public class PresetsPage extends BasePage { left.scrollPane.addButton(new TerraLabel(preset.getName())); } } + + private static TerraButton createSpacer() { + return new TerraButton("") { + @Override + public void render(int x, int y, float tick) { } + }; + } } diff --git a/src/main/java/com/terraforged/gui/preview/PreviewPage.java b/src/main/java/com/terraforged/gui/preview/PreviewPage.java index 0c1bab5..580dc2b 100644 --- a/src/main/java/com/terraforged/gui/preview/PreviewPage.java +++ b/src/main/java/com/terraforged/gui/preview/PreviewPage.java @@ -45,6 +45,10 @@ public class PreviewPage extends UpdatablePage { this.settings = settings; } + public Preview getPreviewWidget() { + return preview; + } + public int getSeed() { return preview.getSeed(); } diff --git a/src/main/java/com/terraforged/util/setup/SetupHooks.java b/src/main/java/com/terraforged/util/setup/SetupHooks.java index 0b4c7dc..83c9a41 100644 --- a/src/main/java/com/terraforged/util/setup/SetupHooks.java +++ b/src/main/java/com/terraforged/util/setup/SetupHooks.java @@ -28,7 +28,7 @@ package com.terraforged.util.setup; import com.terraforged.api.biome.modifier.ModifierManager; import com.terraforged.api.chunk.column.ColumnDecorator; import com.terraforged.api.chunk.column.DecoratorManager; -import com.terraforged.api.chunk.surface.SurfaceManager; +import com.terraforged.api.biome.surface.SurfaceManager; import com.terraforged.api.event.SetupEvent; import com.terraforged.api.material.geology.GeologyManager; import com.terraforged.api.material.layer.LayerManager;