From bf4ab832264757529866b33051fa549a5d3b5fe4 Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Fri, 5 Jan 2024 01:09:04 +0100 Subject: [PATCH] Fix BlockDestroyEvents effectBlock not being set (#10131) --- patches/api/BlockDestroyEvent.patch | 8 +++++--- patches/server/BlockDestroyEvent.patch | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/patches/api/BlockDestroyEvent.patch b/patches/api/BlockDestroyEvent.patch index d7a0d969e6..633e43e137 100644 --- a/patches/api/BlockDestroyEvent.patch +++ b/patches/api/BlockDestroyEvent.patch @@ -22,8 +22,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.bukkit.block.data.BlockData; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; -+import org.bukkit.event.block.BlockEvent; +import org.bukkit.event.block.BlockExpEvent; ++import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** @@ -48,9 +48,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private boolean cancelled = false; + -+ public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, boolean willDrop) { -+ super(block, 0); ++ @ApiStatus.Internal ++ public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, @NotNull BlockData effectBlock, int xp, boolean willDrop) { ++ super(block, xp); + this.newState = newState; ++ this.effectBlock = effectBlock; + this.willDrop = willDrop; + } + diff --git a/patches/server/BlockDestroyEvent.patch b/patches/server/BlockDestroyEvent.patch index ab23f87b8f..a71d339707 100644 --- a/patches/server/BlockDestroyEvent.patch +++ b/patches/server/BlockDestroyEvent.patch @@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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(), xp, drop); + if (!event.callEvent()) { + return false; + }