Skip to content

Commit

Permalink
Fix BlockDestroyEvents effectBlock not being set
Browse files Browse the repository at this point in the history
  • Loading branch information
Warriorrrr committed Jan 4, 2024
1 parent a93acc4 commit ac2d537
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions patches/api/0168-BlockDestroyEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ This can replace many uses of BlockPhysicsEvent

diff --git a/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..5465f0dc890ad8825b910c2a77fd9c0868115ebe
index 0000000000000000000000000000000000000000..871e4482859ca0e346236e351845a145a3b4864e
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java
@@ -0,0 +1,121 @@
@@ -0,0 +1,122 @@
+package com.destroystokyo.paper.event.block;
+
+import org.bukkit.block.Block;
Expand Down Expand Up @@ -48,9 +48,10 @@ index 0000000000000000000000000000000000000000..5465f0dc890ad8825b910c2a77fd9c08
+
+ private boolean cancelled = false;
+
+ public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, boolean willDrop) {
+ public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, @NotNull BlockData effectBlock, boolean willDrop) {
+ super(block, 0);
+ this.newState = newState;
+ this.effectBlock = effectBlock;
+ this.willDrop = willDrop;
+ }
+
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0288-BlockDestroyEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ floating in the air.
This can replace many uses of BlockPhysicsEvent

diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index b4f7e73fa673006ad0f8ea5a8de5a825aa75e41c..3ee67624e163a8c42cc8dab70aa05021baa2574b 100644
index b4f7e73fa673006ad0f8ea5a8de5a825aa75e41c..e6a5fec2d201db885ca792bec25b140345a45d42 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -31,6 +31,7 @@ import net.minecraft.nbt.CompoundTag;
Expand All @@ -33,7 +33,7 @@ index b4f7e73fa673006ad0f8ea5a8de5a825aa75e41c..3ee67624e163a8c42cc8dab70aa05021
+ BlockState effectType = iblockdata;
+ int xp = iblockdata.getBlock().getExpDrop(iblockdata, (ServerLevel) this, pos, ItemStack.EMPTY, true);
+ if (com.destroystokyo.paper.event.block.BlockDestroyEvent.getHandlerList().getRegisteredListeners().length > 0) {
+ com.destroystokyo.paper.event.block.BlockDestroyEvent event = new com.destroystokyo.paper.event.block.BlockDestroyEvent(MCUtil.toBukkitBlock(this, pos), fluid.createLegacyBlock().createCraftBlockData(), drop);
+ com.destroystokyo.paper.event.block.BlockDestroyEvent event = new com.destroystokyo.paper.event.block.BlockDestroyEvent(MCUtil.toBukkitBlock(this, pos), fluid.createLegacyBlock().createCraftBlockData(), effectType.createCraftBlockData(), drop);
+ if (!event.callEvent()) {
+ return false;
+ }
Expand Down

0 comments on commit ac2d537

Please sign in to comment.