diff options
Diffstat (limited to 'patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch')
-rw-r--r-- | patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch | 63 |
1 files changed, 17 insertions, 46 deletions
diff --git a/patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch b/patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch index de7e84ef8b..f81be68815 100644 --- a/patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch +++ b/patches/api/0394-Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch @@ -6,64 +6,35 @@ Subject: [PATCH] Add exploded block state to BlockExplodeEvent and diff --git a/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java -index 641c71ab66bd2499b35cf3c1d533fd105d096e10..7dcbb75170296c1dd1d784a032bf369602328b29 100644 +index 8309b030c2120f1496d244f3ebc1094def41c869..b8bc5718dc1325f0b9d413851c486d91603c3ab4 100644 --- a/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java -@@ -10,18 +10,31 @@ import org.jetbrains.annotations.NotNull; - * Called when a block explodes interacting with blocks. The - * event isn't called if the {@link org.bukkit.GameRule#MOB_GRIEFING} - * is disabled as no block interaction will occur. -+ * <p> -+ * The {@link Block} returned by this event is not necessarily -+ * the block that caused the explosion, just the block at the location where -+ * the explosion originated. See {@link #getExplodedBlockState()} +@@ -13,9 +13,6 @@ import org.jetbrains.annotations.NotNull; + * Note that due to the nature of explosions, {@link #getBlock()} will always be + * an air block. {@link #getExplodedBlockState()} should be used to get + * information about the block state that exploded. +- * <p> +- * The event isn't called if the {@link org.bukkit.GameRule#MOB_GRIEFING} +- * is disabled as no block interaction will occur. */ public class BlockExplodeEvent extends BlockEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); - private boolean cancel; - private final List<Block> blocks; - private float yield; -+ private final org.bukkit.block.BlockState explodedBlockState; // Paper - -+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield) { -+ // Paper start -+ this(what, blocks, yield, null); -+ } -+ @org.jetbrains.annotations.ApiStatus.Internal -+ public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield, @org.jetbrains.annotations.Nullable org.bukkit.block.BlockState explodedBlockState) { -+ // Paper end - super(what); - this.blocks = blocks; - this.yield = yield; +@@ -32,6 +29,15 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { this.cancel = false; -+ this.explodedBlockState = explodedBlockState; // Paper - } - - @Override -@@ -34,6 +47,22 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { - this.cancel = cancel; } + // Paper start -+ /** -+ * Get a capture of the block that directly caused -+ * the explosion, like a bed or respawn anchor. This -+ * block state is not placed so {@link org.bukkit.block.BlockState#isPlaced} -+ * will be false. -+ * <p> -+ * Can be null if no block directly caused the explosion. -+ * -+ * @return the exploded block state or null if not applicable -+ */ -+ public @org.jetbrains.annotations.Nullable org.bukkit.block.BlockState getExplodedBlockState() { -+ return this.explodedBlockState; ++ @io.papermc.paper.annotation.DoNotUse ++ @Deprecated(forRemoval = true) ++ public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield, @org.jetbrains.annotations.Nullable org.bukkit.block.BlockState explodedBlockState) { ++ this(what, explodedBlockState != null ? explodedBlockState : what.getState(), blocks, yield); + } + // Paper end + - /** - * Returns the list of blocks that would have been removed or were removed - * from the explosion event. ++ @io.papermc.paper.annotation.DoNotUse // Paper + @Deprecated(forRemoval = true) + public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield) { + this(what, what.getState(), blocks, yield); diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java index 467a0d6cabc5e860628be3b1e62de773efde5d2e..1fb15e2ade8ff3c4d662eca87b078b4577f786e1 100644 --- a/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java |