From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 21 Aug 2021 18:53:03 -0700 Subject: [PATCH] Only capture actual tree growth diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java index e9b748a81ec223a701b56d2dc890c9eb223d8474..a0c7c6208314d981e8577ad69ef1c5193290a085 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java @@ -862,6 +862,7 @@ public interface DispenseItemBehavior { if (!fertilizeEvent.isCancelled()) { for (org.bukkit.block.BlockState blockstate : blocks) { blockstate.update(true); + worldserver.checkCapturedTreeStateForObserverNotify(blockposition, (org.bukkit.craftbukkit.block.CraftBlockState) blockstate); // Paper - notify observers even if grow failed } } } diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java index 7bb47643e748f57a51c613d0a2ee8d05e1fe1798..16f087adbf94b8fd6726ffd300b103dd709ad406 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -401,6 +401,7 @@ public final class ItemStack { } for (CraftBlockState blockstate : blocks) { world.setBlock(blockstate.getPosition(),blockstate.getHandle(), blockstate.getFlag()); // SPIGOT-7248 - manual update to avoid physics where appropriate + world.checkCapturedTreeStateForObserverNotify(blockposition, blockstate); // Paper - notify observers even if grow failed if (blockstate instanceof org.bukkit.craftbukkit.block.CapturedBlockState capturedBlockState) capturedBlockState.checkTreeBlockHack(); // Paper } entityhuman.awardStat(Stats.ITEM_USED.get(item)); // SPIGOT-7236 - award stat diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java index f67f5cef69621e0baf9b4ba157993d97e431f3d1..2db9a575ca79c46ab36c092f7748fd1654d00bf0 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -1481,4 +1481,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return null; } // Paper end - optimize redstone (Alternate Current) + // Paper start - notify observers even if grow failed + public void checkCapturedTreeStateForObserverNotify(final BlockPos pos, final CraftBlockState craftBlockState) { + if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { // notify observers if the block state is the same and the Y level equals the original y level (for mega trees) + this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlag(), 512); + } + } + // Paper end - notify observers even if grow failed } diff --git a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java b/src/main/java/net/minecraft/world/level/block/SaplingBlock.java index f43e6fe77e943239c1f1d6fa3e31235949f79546..53ac4e618fec3fe384d8a106c521f3eace0b5b35 100644 --- a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SaplingBlock.java @@ -73,6 +73,7 @@ public class SaplingBlock extends BushBlock implements BonemealableBlock { if (event == null || !event.isCancelled()) { for (BlockState blockstate : blocks) { blockstate.update(true); + world.checkCapturedTreeStateForObserverNotify(pos, (org.bukkit.craftbukkit.block.CraftBlockState) blockstate); // Paper - notify observers even if grow failed } } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index f3ac362b7b65a5273ff5fdad1d8065c5f654a53a..bb5837c74edfecec9956b635546a8ecfe1c7dfa5 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -592,6 +592,7 @@ public class CraftBlock implements Block { if (!event.isCancelled()) { for (BlockState blockstate : blocks) { blockstate.update(true); + world.checkCapturedTreeStateForObserverNotify(this.position, (org.bukkit.craftbukkit.block.CraftBlockState) blockstate); // Paper - notify observers even if grow failed } } }