mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
make grass decay size based on the amount of missing aura
This commit is contained in:
parent
6c89a0162e
commit
cd2947f825
1 changed files with 21 additions and 19 deletions
|
@ -18,27 +18,29 @@ public class GrassDieEffect implements IDrainSpotEffect {
|
||||||
if (aura < 0) {
|
if (aura < 0) {
|
||||||
int amount = Math.min(300, Math.abs(aura) / 1000);
|
int amount = Math.min(300, Math.abs(aura) / 1000);
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
int dist = 25;
|
int dist = Math.min(45, Math.abs(aura) / 750);
|
||||||
for (int i = amount / 2 + world.rand.nextInt(amount / 2); i >= 0; i--) {
|
if (dist > 0) {
|
||||||
BlockPos grassPos = new BlockPos(
|
for (int i = amount / 2 + world.rand.nextInt(amount / 2); i >= 0; i--) {
|
||||||
pos.getX() + world.rand.nextGaussian() * dist,
|
BlockPos grassPos = new BlockPos(
|
||||||
pos.getY() + world.rand.nextGaussian() * dist,
|
pos.getX() + world.rand.nextGaussian() * dist,
|
||||||
pos.getZ() + 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);
|
if (grassPos.distanceSq(pos) <= dist * dist && world.isBlockLoaded(grassPos)) {
|
||||||
Block block = state.getBlock();
|
IBlockState state = world.getBlockState(grassPos);
|
||||||
|
Block block = state.getBlock();
|
||||||
|
|
||||||
IBlockState newState = null;
|
IBlockState newState = null;
|
||||||
if (block instanceof BlockLeaves) {
|
if (block instanceof BlockLeaves) {
|
||||||
newState = ModBlocks.DECAYED_LEAVES.getDefaultState();
|
newState = ModBlocks.DECAYED_LEAVES.getDefaultState();
|
||||||
} else if (block instanceof BlockGrass) {
|
} else if (block instanceof BlockGrass) {
|
||||||
newState = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT);
|
newState = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT);
|
||||||
} else if (block instanceof BlockBush) {
|
} else if (block instanceof BlockBush) {
|
||||||
newState = Blocks.AIR.getDefaultState();
|
newState = Blocks.AIR.getDefaultState();
|
||||||
|
}
|
||||||
|
if (newState != null)
|
||||||
|
world.setBlockState(grassPos, newState);
|
||||||
}
|
}
|
||||||
if (newState != null)
|
|
||||||
world.setBlockState(grassPos, newState);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue