47 lines
3.0 KiB
Diff
47 lines
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cryptite <cryptite@gmail.com>
|
|
Date: Mon, 28 Feb 2022 08:54:52 -0600
|
|
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 6764f174d0685c02d5e81aa38228d02a77bf9632..0bd21a1eeb33ffb7e3299d864e8160627d6f88d9 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -692,6 +692,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 301dfb74fec49b7f6f0452e4c49c8f1df43c0180..6b63bc56bfa757a17f9a6f98b31861a7f350be80 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) {
|