From d6df3dd168c8f64b8c939784e3ed9284aff6268e Mon Sep 17 00:00:00 2001 From: dags- Date: Sat, 13 Jun 2020 18:17:31 +0100 Subject: [PATCH] - update n2d package - smarter snow placement - tweaks to default settings --- Engine | 2 +- .../modifier/AbstractMaxHeightModifier.java | 2 +- .../terraforged/biome/map/SimpleBiomeMap.java | 2 +- .../terraforged/biome/map/set/BiomeSet.java | 2 +- .../modifier/AbstractMaxHeightModifier.java | 2 +- .../biome/modifier/BeachModifier.java | 4 +- .../biome/provider/BiomeHelper.java | 2 +- .../biome/surface/BriceSurface.java | 2 +- .../biome/surface/DunesSurface.java | 4 +- .../biome/surface/ForestSurface.java | 2 +- .../biome/surface/IcebergsSurface.java | 2 +- .../terraforged/feature/TerrainHelper.java | 2 +- .../feature/feature/FreezeLayer.java | 44 ++++++++++++++----- .../com/terraforged/gui/preview/Preview.java | 2 +- .../terraforged/gui/preview/RenderMode.java | 2 +- .../material/geology/GeoGenerator.java | 2 +- .../material/geology/GeoManager.java | 4 +- .../terraforged/util/setup/SetupDebug.java | 2 +- 18 files changed, 52 insertions(+), 32 deletions(-) diff --git a/Engine b/Engine index 86578fa..148a59d 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit 86578fa35c0c296487d1aac675b55d4eb994cde7 +Subproject commit 148a59d8ec0f555e61b6e13526aedd3bc193d427 diff --git a/src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java b/src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java index 5642e0f..c5cd9fc 100644 --- a/src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java +++ b/src/main/java/com/terraforged/api/biome/modifier/AbstractMaxHeightModifier.java @@ -27,9 +27,9 @@ package com.terraforged.api.biome.modifier; import com.terraforged.core.Seed; import com.terraforged.core.cell.Cell; -import com.terraforged.world.climate.Climate; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; +import com.terraforged.world.climate.Climate; import net.minecraft.world.biome.Biome; public abstract class AbstractMaxHeightModifier extends AbstractOffsetModifier { diff --git a/src/main/java/com/terraforged/biome/map/SimpleBiomeMap.java b/src/main/java/com/terraforged/biome/map/SimpleBiomeMap.java index 5bc437e..30a6b3c 100644 --- a/src/main/java/com/terraforged/biome/map/SimpleBiomeMap.java +++ b/src/main/java/com/terraforged/biome/map/SimpleBiomeMap.java @@ -8,10 +8,10 @@ import com.terraforged.biome.map.set.BiomeTypeSet; import com.terraforged.biome.map.set.RiverSet; import com.terraforged.biome.map.set.TemperatureSet; import com.terraforged.core.cell.Cell; +import com.terraforged.n2d.util.NoiseUtil; import com.terraforged.world.biome.BiomeType; import com.terraforged.world.heightmap.Levels; import com.terraforged.world.terrain.TerrainType; -import com.terraforged.n2d.util.NoiseUtil; import net.minecraft.world.biome.Biome; import java.util.Arrays; diff --git a/src/main/java/com/terraforged/biome/map/set/BiomeSet.java b/src/main/java/com/terraforged/biome/map/set/BiomeSet.java index ee41ccc..8f9716e 100644 --- a/src/main/java/com/terraforged/biome/map/set/BiomeSet.java +++ b/src/main/java/com/terraforged/biome/map/set/BiomeSet.java @@ -4,8 +4,8 @@ import com.google.gson.JsonElement; import com.terraforged.biome.map.defaults.DefaultBiome; import com.terraforged.biome.provider.BiomeHelper; import com.terraforged.core.cell.Cell; -import com.terraforged.util.ListUtils; import com.terraforged.n2d.util.NoiseUtil; +import com.terraforged.util.ListUtils; import net.minecraft.world.biome.Biome; import java.util.Collections; diff --git a/src/main/java/com/terraforged/biome/modifier/AbstractMaxHeightModifier.java b/src/main/java/com/terraforged/biome/modifier/AbstractMaxHeightModifier.java index 10d0880..34ffeb1 100644 --- a/src/main/java/com/terraforged/biome/modifier/AbstractMaxHeightModifier.java +++ b/src/main/java/com/terraforged/biome/modifier/AbstractMaxHeightModifier.java @@ -27,9 +27,9 @@ package com.terraforged.biome.modifier; import com.terraforged.core.Seed; import com.terraforged.core.cell.Cell; -import com.terraforged.world.climate.Climate; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; +import com.terraforged.world.climate.Climate; import net.minecraft.world.biome.Biome; public abstract class AbstractMaxHeightModifier extends AbstractOffsetModifier { diff --git a/src/main/java/com/terraforged/biome/modifier/BeachModifier.java b/src/main/java/com/terraforged/biome/modifier/BeachModifier.java index 325ff06..6d869fc 100644 --- a/src/main/java/com/terraforged/biome/modifier/BeachModifier.java +++ b/src/main/java/com/terraforged/biome/modifier/BeachModifier.java @@ -3,11 +3,11 @@ package com.terraforged.biome.modifier; import com.terraforged.api.biome.modifier.BiomeModifier; import com.terraforged.biome.map.BiomeMap; 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.biome.BiomeType; import com.terraforged.world.terrain.Terrains; -import com.terraforged.n2d.Module; -import com.terraforged.n2d.Source; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; diff --git a/src/main/java/com/terraforged/biome/provider/BiomeHelper.java b/src/main/java/com/terraforged/biome/provider/BiomeHelper.java index fa43e6d..ec63de3 100644 --- a/src/main/java/com/terraforged/biome/provider/BiomeHelper.java +++ b/src/main/java/com/terraforged/biome/provider/BiomeHelper.java @@ -29,9 +29,9 @@ import com.terraforged.biome.ModBiomes; import com.terraforged.biome.map.BiomeMap; import com.terraforged.biome.map.BiomeMapBuilder; import com.terraforged.biome.map.BiomePredicate; +import com.terraforged.n2d.util.Vec2f; import com.terraforged.world.biome.BiomeData; import com.terraforged.world.biome.BiomeType; -import com.terraforged.n2d.util.Vec2f; import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; diff --git a/src/main/java/com/terraforged/biome/surface/BriceSurface.java b/src/main/java/com/terraforged/biome/surface/BriceSurface.java index 53e4fd0..2d35dc8 100644 --- a/src/main/java/com/terraforged/biome/surface/BriceSurface.java +++ b/src/main/java/com/terraforged/biome/surface/BriceSurface.java @@ -4,10 +4,10 @@ import com.terraforged.api.chunk.surface.Surface; import com.terraforged.api.chunk.surface.SurfaceContext; import com.terraforged.core.Seed; import com.terraforged.core.util.Variance; -import com.terraforged.world.geology.Strata; 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; diff --git a/src/main/java/com/terraforged/biome/surface/DunesSurface.java b/src/main/java/com/terraforged/biome/surface/DunesSurface.java index 1c99d57..efd68e0 100644 --- a/src/main/java/com/terraforged/biome/surface/DunesSurface.java +++ b/src/main/java/com/terraforged/biome/surface/DunesSurface.java @@ -32,12 +32,12 @@ import com.terraforged.biome.provider.BiomeProvider; import com.terraforged.biome.provider.DesertBiomes; import com.terraforged.chunk.TerraContext; import com.terraforged.core.cell.Cell; -import com.terraforged.world.heightmap.Levels; -import com.terraforged.world.terrain.Terrains; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; import com.terraforged.n2d.func.CellFunc; import com.terraforged.n2d.util.NoiseUtil; +import com.terraforged.world.heightmap.Levels; +import com.terraforged.world.terrain.Terrains; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/com/terraforged/biome/surface/ForestSurface.java b/src/main/java/com/terraforged/biome/surface/ForestSurface.java index 81ee423..041914f 100644 --- a/src/main/java/com/terraforged/biome/surface/ForestSurface.java +++ b/src/main/java/com/terraforged/biome/surface/ForestSurface.java @@ -3,9 +3,9 @@ package com.terraforged.biome.surface; import com.terraforged.api.chunk.surface.Surface; import com.terraforged.api.chunk.surface.SurfaceContext; import com.terraforged.api.material.state.States; -import com.terraforged.world.GeneratorContext; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; +import com.terraforged.world.GeneratorContext; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.world.gen.Heightmap; diff --git a/src/main/java/com/terraforged/biome/surface/IcebergsSurface.java b/src/main/java/com/terraforged/biome/surface/IcebergsSurface.java index df0527c..05b6d87 100644 --- a/src/main/java/com/terraforged/biome/surface/IcebergsSurface.java +++ b/src/main/java/com/terraforged/biome/surface/IcebergsSurface.java @@ -30,10 +30,10 @@ import com.terraforged.api.chunk.surface.SurfaceContext; import com.terraforged.api.material.state.States; import com.terraforged.chunk.TerraContext; import com.terraforged.core.cell.Cell; -import com.terraforged.world.heightmap.Levels; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; import com.terraforged.n2d.util.NoiseUtil; +import com.terraforged.world.heightmap.Levels; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; diff --git a/src/main/java/com/terraforged/feature/TerrainHelper.java b/src/main/java/com/terraforged/feature/TerrainHelper.java index eb098f9..632cb75 100644 --- a/src/main/java/com/terraforged/feature/TerrainHelper.java +++ b/src/main/java/com/terraforged/feature/TerrainHelper.java @@ -26,11 +26,11 @@ package com.terraforged.feature; import com.google.common.collect.ImmutableSet; +import com.terraforged.n2d.util.NoiseUtil; import it.unimi.dsi.fastutil.longs.LongIterator; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; import it.unimi.dsi.fastutil.objects.ObjectListIterator; -import com.terraforged.n2d.util.NoiseUtil; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; diff --git a/src/main/java/com/terraforged/feature/feature/FreezeLayer.java b/src/main/java/com/terraforged/feature/feature/FreezeLayer.java index 2db1f6d..946f988 100644 --- a/src/main/java/com/terraforged/feature/feature/FreezeLayer.java +++ b/src/main/java/com/terraforged/feature/feature/FreezeLayer.java @@ -3,6 +3,7 @@ package com.terraforged.feature.feature; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.SnowyDirtBlock; +import net.minecraft.tags.BlockTags; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; @@ -39,12 +40,12 @@ public class FreezeLayer extends Feature { pos2.setPos(pos1).move(Direction.DOWN, 1); Biome biome = world.getBiome(pos1); - boolean freezesHere = freeze(world, biome, pos1, pos2, false); + boolean freezesHere = freeze(world, biome, pos1, pos2, false, false); if (y1 != y2) { pos1.setPos(x, y2, z); pos2.setPos(pos1).move(Direction.DOWN, 1); - freeze(world, biome, pos1, pos2, freezesHere); + freeze(world, biome, pos1, pos2, freezesHere, true); } } } @@ -52,7 +53,7 @@ public class FreezeLayer extends Feature { return true; } - private boolean freeze(IWorld world, Biome biome, BlockPos.Mutable top, BlockPos below, boolean force) { + private boolean freeze(IWorld world, Biome biome, BlockPos.Mutable top, BlockPos below, boolean force, boolean ground) { boolean hasFrozen = false; if (biome.doesWaterFreeze(world, below, false)) { world.setBlockState(below, Blocks.ICE.getDefaultState(), 2); @@ -61,20 +62,39 @@ public class FreezeLayer extends Feature { if (force || biome.doesSnowGenerate(world, top)) { hasFrozen = true; - world.setBlockState(top, Blocks.SNOW.getDefaultState(), 2); - - // mark block below as snowy if supported BlockState stateUnder = world.getBlockState(below); - if (stateUnder.has(SnowyDirtBlock.SNOWY)) { - world.setBlockState(below, stateUnder.with(SnowyDirtBlock.SNOWY, true), 2); + + if (stateUnder.getBlock() == Blocks.AIR) { + return false; } - // remove floating blocks above - top.move(Direction.UP, 1); - if (!world.isAirBlock(top)) { - world.setBlockState(top, Blocks.AIR.getDefaultState(), 2); + if (ground) { + if (BlockTags.LOGS.contains(stateUnder.getBlock())) { + return false; + } + + BlockState above = world.getBlockState(top.up()); + if (BlockTags.LOGS.contains(above.getBlock()) || BlockTags.LEAVES.contains(above.getBlock())) { + return false; + } + + setSnow(world, top, below, stateUnder); + + if (above.getBlock() != Blocks.AIR) { + world.setBlockState(top, Blocks.AIR.getDefaultState(), 2); + } + } else { + setSnow(world, top, below, stateUnder); } } return hasFrozen; } + + private void setSnow(IWorld world, BlockPos pos1, BlockPos pos2, BlockState below) { + world.setBlockState(pos1, Blocks.SNOW.getDefaultState(), 2); + + if (below.has(SnowyDirtBlock.SNOWY)) { + world.setBlockState(pos2, below.with(SnowyDirtBlock.SNOWY, true), 2); + } + } } diff --git a/src/main/java/com/terraforged/gui/preview/Preview.java b/src/main/java/com/terraforged/gui/preview/Preview.java index e3d891b..45447ab 100644 --- a/src/main/java/com/terraforged/gui/preview/Preview.java +++ b/src/main/java/com/terraforged/gui/preview/Preview.java @@ -34,12 +34,12 @@ import com.terraforged.core.region.Region; import com.terraforged.core.region.Size; import com.terraforged.core.region.gen.RegionGenerator; import com.terraforged.core.settings.Settings; +import com.terraforged.n2d.util.NoiseUtil; import com.terraforged.util.nbt.NBTHelper; import com.terraforged.world.GeneratorContext; import com.terraforged.world.continent.MutableVeci; import com.terraforged.world.heightmap.Levels; import com.terraforged.world.terrain.Terrains; -import com.terraforged.n2d.util.NoiseUtil; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.FontRenderer; diff --git a/src/main/java/com/terraforged/gui/preview/RenderMode.java b/src/main/java/com/terraforged/gui/preview/RenderMode.java index dcb19cf..daafab3 100644 --- a/src/main/java/com/terraforged/gui/preview/RenderMode.java +++ b/src/main/java/com/terraforged/gui/preview/RenderMode.java @@ -26,8 +26,8 @@ package com.terraforged.gui.preview; import com.terraforged.core.cell.Cell; -import com.terraforged.world.heightmap.Levels; import com.terraforged.n2d.util.NoiseUtil; +import com.terraforged.world.heightmap.Levels; import java.awt.*; diff --git a/src/main/java/com/terraforged/material/geology/GeoGenerator.java b/src/main/java/com/terraforged/material/geology/GeoGenerator.java index 4c6f2e3..d094abb 100644 --- a/src/main/java/com/terraforged/material/geology/GeoGenerator.java +++ b/src/main/java/com/terraforged/material/geology/GeoGenerator.java @@ -28,8 +28,8 @@ package com.terraforged.material.geology; import com.terraforged.api.material.geology.StrataConfig; import com.terraforged.api.material.geology.StrataGenerator; import com.terraforged.material.Materials; -import com.terraforged.world.geology.Strata; import com.terraforged.n2d.Source; +import com.terraforged.world.geology.Strata; import net.minecraft.block.Block; import net.minecraft.block.BlockState; diff --git a/src/main/java/com/terraforged/material/geology/GeoManager.java b/src/main/java/com/terraforged/material/geology/GeoManager.java index 0a8d59f..1288d5a 100644 --- a/src/main/java/com/terraforged/material/geology/GeoManager.java +++ b/src/main/java/com/terraforged/material/geology/GeoManager.java @@ -30,10 +30,10 @@ import com.terraforged.api.material.geology.StrataConfig; import com.terraforged.chunk.TerraContext; import com.terraforged.core.Seed; import com.terraforged.material.Materials; -import com.terraforged.world.geology.Geology; -import com.terraforged.world.geology.Strata; import com.terraforged.n2d.Module; import com.terraforged.n2d.Source; +import com.terraforged.world.geology.Geology; +import com.terraforged.world.geology.Strata; import net.minecraft.block.BlockState; import net.minecraft.world.biome.Biome; diff --git a/src/main/java/com/terraforged/util/setup/SetupDebug.java b/src/main/java/com/terraforged/util/setup/SetupDebug.java index 44b991a..ae09030 100644 --- a/src/main/java/com/terraforged/util/setup/SetupDebug.java +++ b/src/main/java/com/terraforged/util/setup/SetupDebug.java @@ -28,9 +28,9 @@ package com.terraforged.util.setup; import com.terraforged.Log; import com.terraforged.api.event.SetupEvent; import com.terraforged.core.Seed; -import com.terraforged.world.geology.Strata; import com.terraforged.n2d.Source; import com.terraforged.n2d.source.Builder; +import com.terraforged.world.geology.Strata; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.world.biome.Biomes;