From 0ca12bd0d145eb42f75748e4f0b1616597a3ec99 Mon Sep 17 00:00:00 2001 From: dags- Date: Mon, 8 Jun 2020 13:39:25 +0100 Subject: [PATCH] - fix forest surface placing over water --- Engine | 2 +- .../terraforged/biome/surface/ForestSurface.java | 7 +++++-- .../terraforged/feature/feature/FreezeLayer.java | 16 ++++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Engine b/Engine index 433db36..82bcd43 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit 433db368f37a8f0a538d017610ce5cb11487d7fe +Subproject commit 82bcd434921697fb51fd272d65ed6f10ec79ab22 diff --git a/src/main/java/com/terraforged/biome/surface/ForestSurface.java b/src/main/java/com/terraforged/biome/surface/ForestSurface.java index f3faa5c..7addf05 100644 --- a/src/main/java/com/terraforged/biome/surface/ForestSurface.java +++ b/src/main/java/com/terraforged/biome/surface/ForestSurface.java @@ -8,6 +8,7 @@ import me.dags.noise.Module; import me.dags.noise.Source; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.world.gen.Heightmap; public class ForestSurface implements Surface { @@ -19,8 +20,10 @@ public class ForestSurface implements Surface { @Override public void buildSurface(int x, int z, int height, SurfaceContext ctx) { - BlockState state = getMaterial(x, z); - ctx.buffer.setBlockState(ctx.pos.setPos(x, height, z), state, false); + if (ctx.buffer.getTopBlockY(Heightmap.Type.OCEAN_FLOOR_WG, x, z) == height) { + BlockState state = getMaterial(x, z); + ctx.buffer.setBlockState(ctx.pos.setPos(x, height, z), state, false); + } } private BlockState getMaterial(int x, int z) { diff --git a/src/main/java/com/terraforged/feature/feature/FreezeLayer.java b/src/main/java/com/terraforged/feature/feature/FreezeLayer.java index 17d9272..2db1f6d 100644 --- a/src/main/java/com/terraforged/feature/feature/FreezeLayer.java +++ b/src/main/java/com/terraforged/feature/feature/FreezeLayer.java @@ -52,7 +52,7 @@ public class FreezeLayer extends Feature { return true; } - private boolean freeze(IWorld world, Biome biome, BlockPos top, BlockPos below, boolean force) { + private boolean freeze(IWorld world, Biome biome, BlockPos.Mutable top, BlockPos below, boolean force) { boolean hasFrozen = false; if (biome.doesWaterFreeze(world, below, false)) { world.setBlockState(below, Blocks.ICE.getDefaultState(), 2); @@ -62,9 +62,17 @@ public class FreezeLayer extends Feature { if (force || biome.doesSnowGenerate(world, top)) { hasFrozen = true; world.setBlockState(top, Blocks.SNOW.getDefaultState(), 2); - BlockState blockstate = world.getBlockState(below); - if (blockstate.has(SnowyDirtBlock.SNOWY)) { - world.setBlockState(below, blockstate.with(SnowyDirtBlock.SNOWY, true), 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); + } + + // remove floating blocks above + top.move(Direction.UP, 1); + if (!world.isAirBlock(top)) { + world.setBlockState(top, Blocks.AIR.getDefaultState(), 2); } } return hasFrozen;