mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 20:46:59 +01:00
71 lines
5.0 KiB
Diff
71 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
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 aa21c3b9ac5101d0c2150baf2c259ed247e94349..884871cf33a3073549109f5c4ba738bb34a21a6e 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -1487,4 +1487,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
|
|
}
|
|
}
|
|
}
|