Files
OldSliceMC/patches/server/0009-Add-BlockDestroyedByNeighborEvent.patch
2021-11-30 12:54:40 -06:00

47 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sun, 26 Sep 2021 09:00:50 -0500
Subject: [PATCH] Add BlockDestroyedByNeighborEvent
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 71fca6c915f90a771e6139b985ebc51c7923778c..96a7ae08649294062f856c67e49a793feb63ca37 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -738,6 +738,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if (iblockdata.isAir()) {
return false;
} else {
+ // Paper start
+ PendingBlockEvent blockEvent = pendingPlayerBlockEvents.get(pos);
+ if (blockEvent != null && blockEvent.sourceBlock != null) {
+ io.papermc.paper.event.block.BlockDestroyedByNeighborEvent event =
+ new io.papermc.paper.event.block.BlockDestroyedByNeighborEvent(org.bukkit.craftbukkit.block.CraftBlock.at(this, pos),
+ (org.bukkit.entity.Player) blockEvent.player.getBukkitEntity(),
+ org.bukkit.craftbukkit.block.CraftBlock.at(this, blockEvent.sourceBlock));
+ event.callEvent();
+ }
+ // Paper end
+
FluidState fluid = this.getFluidState(pos);
// Paper start - while the above setAir method is named same and looks very similar
// they are NOT used with same intent and the above should not fire this event. The above method is more of a BlockSetToAirEvent,
diff --git a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
index b1b6072ffff0e1cc2e9e1a585ad882bc70697d92..f2eb493d99c2eb826d8b85adbc3dc6799c575f31 100644
--- a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
@@ -106,8 +106,11 @@ public class DoublePlantBlock extends BushBlock {
Level.PendingBlockEvent blockEvent = world.pendingPlayerBlockEvents.remove(pos);
if (blockEvent != null) {
- //Would fire a future BlockDestroyedByNeighborEvent here, but must have this conditional block
- //because it's important to remove from pendingPlayerBlockEvents
+ io.papermc.paper.event.block.BlockDestroyedByNeighborEvent event =
+ new io.papermc.paper.event.block.BlockDestroyedByNeighborEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition1),
+ (org.bukkit.entity.Player) blockEvent.player.getBukkitEntity(),
+ org.bukkit.craftbukkit.block.CraftBlock.at(world, pos));
+ if (!event.callEvent()) return;
}
if (iblockdata1.is(state.getBlock()) && iblockdata1.getValue(DoublePlantBlock.HALF) == DoubleBlockHalf.LOWER) {