Skip to content

Commit

Permalink
Merge pull request #5 from ElNounch/patch-1
Browse files Browse the repository at this point in the history
Do not decay leaves if can't check every possible supports
  • Loading branch information
Dream-Master authored Nov 28, 2021
2 parents 935462a + 64f6f02 commit d07fd56
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/main/java/mods/natura/blocks/trees/NLeaves.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,28 @@ public void updateTick (World world, int x, int y, int z, Random random)

if ((meta & 4) == 0)
{
boolean nearbyTree = false;
byte range = 4;
for (int posX = x - range; posX <= x + range; posX++)
{
for (int posY = y - range; posY <= y + range; posY++)
int range = 4;
if (world.checkChunksExist(x - range, y - range, z - range, x + range, y + range, z + range)) {
// Do not decay leaves if can't check every possible support
boolean nearbyTree = false;

for (int posX = x - range; posX <= x + range; posX++)
{
for (int posZ = z - range; posZ <= z + range; posZ++)
for (int posY = y - range; posY <= y + range; posY++)
{
Block block = world.getBlock(posX, posY, posZ);
if (block != null && block.canSustainLeaves(world, posX, posY, posZ))
nearbyTree = true;
for (int posZ = z - range; posZ <= z + range; posZ++)
{
Block block = world.getBlock(posX, posY, posZ);
if (block != null && block.canSustainLeaves(world, posX, posY, posZ))
nearbyTree = true;
}
}
}
}

if (!nearbyTree)
this.removeLeaves(world, x, y, z);
if (!nearbyTree) {
this.removeLeaves(world, x, y, z);
}
}
}
}
}
Expand Down Expand Up @@ -218,4 +223,4 @@ public String[] func_150125_e ()
{
return null;
}
}
}

0 comments on commit d07fd56

Please sign in to comment.