From cd2947f8252901546f3b360ce7eb89fb21496122 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 25 Oct 2018 22:31:21 +0200 Subject: [PATCH] make grass decay size based on the amount of missing aura --- .../aura/chunk/effect/GrassDieEffect.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java index 0557f96b..7c0f33d2 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java @@ -18,27 +18,29 @@ public class GrassDieEffect implements IDrainSpotEffect { if (aura < 0) { int amount = Math.min(300, Math.abs(aura) / 1000); if (amount > 0) { - int dist = 25; - for (int i = amount / 2 + world.rand.nextInt(amount / 2); i >= 0; i--) { - BlockPos grassPos = new BlockPos( - pos.getX() + world.rand.nextGaussian() * dist, - pos.getY() + world.rand.nextGaussian() * dist, - pos.getZ() + world.rand.nextGaussian() * dist - ); - if (grassPos.distanceSq(pos) <= dist * dist && world.isBlockLoaded(grassPos)) { - IBlockState state = world.getBlockState(grassPos); - Block block = state.getBlock(); + int dist = Math.min(45, Math.abs(aura) / 750); + if (dist > 0) { + for (int i = amount / 2 + world.rand.nextInt(amount / 2); i >= 0; i--) { + BlockPos grassPos = new BlockPos( + pos.getX() + world.rand.nextGaussian() * dist, + pos.getY() + world.rand.nextGaussian() * dist, + pos.getZ() + world.rand.nextGaussian() * dist + ); + if (grassPos.distanceSq(pos) <= dist * dist && world.isBlockLoaded(grassPos)) { + IBlockState state = world.getBlockState(grassPos); + Block block = state.getBlock(); - IBlockState newState = null; - if (block instanceof BlockLeaves) { - newState = ModBlocks.DECAYED_LEAVES.getDefaultState(); - } else if (block instanceof BlockGrass) { - newState = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); - } else if (block instanceof BlockBush) { - newState = Blocks.AIR.getDefaultState(); + IBlockState newState = null; + if (block instanceof BlockLeaves) { + newState = ModBlocks.DECAYED_LEAVES.getDefaultState(); + } else if (block instanceof BlockGrass) { + newState = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); + } else if (block instanceof BlockBush) { + newState = Blocks.AIR.getDefaultState(); + } + if (newState != null) + world.setBlockState(grassPos, newState); } - if (newState != null) - world.setBlockState(grassPos, newState); } } }