From 25a99b12e8b18d13f1e69d40f810f9c2d8f2b9c0 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/0168-BlockDestroyEvent.patch | 12 +++++++----- patches/server/0288-BlockDestroyEvent.patch | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/patches/api/0168-BlockDestroyEvent.patch b/patches/api/0168-BlockDestroyEvent.patch index 5046b085e6..4ea4bb334f 100644 --- a/patches/api/0168-BlockDestroyEvent.patch +++ b/patches/api/0168-BlockDestroyEvent.patch @@ -12,18 +12,18 @@ 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..278f26bed374fe79ff3cd135a76f019bd21906e4 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java -@@ -0,0 +1,121 @@ +@@ -0,0 +1,123 @@ +package com.destroystokyo.paper.event.block; + +import org.bukkit.block.Block; +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..5465f0dc890ad8825b910c2a77fd9c08 + + 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/0288-BlockDestroyEvent.patch b/patches/server/0288-BlockDestroyEvent.patch index 65f26283b4..8d684e74d0 100644 --- a/patches/server/0288-BlockDestroyEvent.patch +++ b/patches/server/0288-BlockDestroyEvent.patch @@ -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..41b8b7890919e2a7a349d701123422e3d27ddc37 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; @@ -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(), xp, drop); + if (!event.callEvent()) { + return false; + }