diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java index 44f7f6939a..e534954457 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java @@ -2,26 +2,38 @@ package org.bukkit.event.block; import java.util.List; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; /** - * Called when a block explodes + * Called when a block explodes. + *

+ * 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. */ public class BlockExplodeEvent extends BlockEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancel; + private final BlockState blockState; private final List blocks; private float yield; - public BlockExplodeEvent(@NotNull final Block what, @NotNull final List blocks, final float yield) { + public BlockExplodeEvent(@NotNull final Block what, @NotNull final BlockState blockState, @NotNull final List blocks, final float yield) { super(what); + this.blockState = blockState; this.blocks = blocks; this.yield = yield; this.cancel = false; } + @Deprecated(forRemoval = true) + public BlockExplodeEvent(@NotNull final Block what, @NotNull final List blocks, final float yield) { + this(what, what.getState(), blocks, yield); + } + @Override public boolean isCancelled() { return cancel; @@ -32,6 +44,16 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { this.cancel = cancel; } + /** + * Returns the captured BlockState of the block that exploded. + * + * @return the block state + */ + @NotNull + public BlockState getExplodedBlockState() { + return blockState; + } + /** * Returns the list of blocks that would have been removed or were removed * from the explosion event.