Skip to content

Commit

Permalink
Acacia and Dark Oak Bug Fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmaynard committed Nov 11, 2018
1 parent f652582 commit a0fcacb
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/main/java/com/aaronmaynard/timber/TListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,25 @@ public TListener() {
* @param z variable position in the current world
*/
private void fell(World w, int x, int y, int z) {

if (!w.getBlockAt(x, y, z).breakNaturally()) {
plugin.getLogger().warning("Could not break wood block at (" + x + ", " + y + ", " + z + ")!");
return;
}
// Checks blocks on current y plane
// for (int j = 0; j < logs.length; j++) {
for (int i = 0; i < dx.length; i++) {
if (w.getBlockAt(x + dx[i], y, z + dz[i]).getType() == Material.LOG) {
if (w.getBlockAt(x + dx[i], y, z + dz[i]).getType() == Material.LOG || w.getBlockAt(x + dx[i], y, z + dz[i]).getType() == Material.LOG_2) {
fell(w, x + dx[i], y, z + dz[i]);
}
}

// Checks block above
if (w.getBlockAt(x, y + 1, z).getType() == Material.LOG) {
if (w.getBlockAt(x, y + 1, z).getType() == Material.LOG || w.getBlockAt(x, y + 1, z).getType() == Material.LOG_2) {
fell(w, x, y + 1, z);
}
// Checks block below
if (w.getBlockAt(x, y - 1, z).getType() == Material.LOG) {
if (w.getBlockAt(x, y - 1, z).getType() == Material.LOG || w.getBlockAt(x, y - 1, z).getType() == Material.LOG_2) {
fell(w, x, y - 1, z);
}
// }
Expand Down Expand Up @@ -110,10 +111,9 @@ public void onBlockBreak(BlockBreakEvent e) {
World w = loc.getWorld();

// for (int j = 0; j < logs.length; j++) {
if (block.getType() != Material.LOG) {
if (block.getType() != Material.LOG && block.getType() != Material.LOG_2) {
return; // must be wood
}

// }

if (axeOnly) {
Expand All @@ -131,8 +131,7 @@ public void onBlockBreak(BlockBreakEvent e) {

// for (int j = 0; j < logs.length; j++) {
for (int i = 0; i < dx.length; i++) {
if (w.getBlockAt(loc.getBlockX() + dx[i], loc.getBlockY(), loc.getBlockZ() + dz[i])
.getType() == Material.LOG) {
if (w.getBlockAt(loc.getBlockX() + dx[i], loc.getBlockY(), loc.getBlockZ() + dz[i]).getType() == Material.LOG || w.getBlockAt(loc.getBlockX() + dx[i], loc.getBlockY(), loc.getBlockZ() + dz[i]).getType() == Material.LOG_2) {
return; // disable cutting of thick trees
}
}
Expand All @@ -144,14 +143,13 @@ public void onBlockBreak(BlockBreakEvent e) {
for (int dy = 1; !okay && dy < 9; dy++) {
// for (int k = 0; k < leaves.length; k++) {
for (int i = 0; !okay && i < dx.length; i++) {
okay |= w.getBlockAt(loc.getBlockX() + dx[i], loc.getBlockY() + dy, loc.getBlockZ() + dz[i])
.getType() == Material.LEAVES; // must have leaves somewhere nearby
okay |= (w.getBlockAt(loc.getBlockX() + dx[i], loc.getBlockY() + dy, loc.getBlockZ() + dz[i]).getType() == Material.LEAVES || w.getBlockAt(loc.getBlockX() + dx[i], loc.getBlockY() + dy, loc.getBlockZ() + dz[i]).getType() == Material.LEAVES_2); // must have leaves somewhere nearby
}
// }
}
if (!okay)
return;

if (trunkOnly) {
if (w.getBlockAt(loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()).getType() != Material.DIRT) {
return; // A log was detected below
Expand Down

0 comments on commit a0fcacb

Please sign in to comment.