From e0d85f842b1b96b2b1c055e66d65b65d2f14c306 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Sat, 2 Jan 2021 11:18:32 -0500 Subject: [PATCH] Fix exception thrown when plants fake grow at max world height. --- .../com/gmail/nossr50/listeners/BlockListener.java | 12 +++++++++--- .../nossr50/util/blockmeta/BitSetChunkStore.java | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index a2a4c2a76..a6d8e7900 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -253,12 +253,18 @@ public class BlockListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockGrow(BlockGrowEvent event) { + Block block = event.getBlock(); + World world = block.getWorld(); + /* WORLD BLACKLIST CHECK */ - if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) + if(WorldBlacklist.isWorldBlacklisted(world)) return; - BlockState blockState = event.getBlock().getState(); - mcMMO.getPlaceStore().setFalse(blockState); + // Minecraft is dumb, the events still throw when a plant "grows" higher than the max block height. Even though no new block is created + if (block.getY() >= world.getMaxHeight()) + return; + + mcMMO.getPlaceStore().setFalse(block); } /** diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/BitSetChunkStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/BitSetChunkStore.java index dce7ab174..a1fe92e4b 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/BitSetChunkStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/BitSetChunkStore.java @@ -82,7 +82,7 @@ public class BitSetChunkStore implements ChunkStore, Serializable { private int coordToIndex(int x, int y, int z) { if (x < 0 || x >= 16 || y < 0 || y >= worldHeight || z < 0 || z >= 16) - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException(String.format("x: %d y: %d z: %d World Height: %d", x, y, z, worldHeight)); return (z * 16 + x) + (256 * y); }