From f72dbc96cd4e904fdb91ffac50a7163f1653d503 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 11 Feb 2023 18:59:06 +1100 Subject: [PATCH] SPIGOT-4569: Add more BlockData API By: Parker Hawke --- .../java/org/bukkit/block/data/BlockData.java | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/block/data/BlockData.java b/paper-api/src/main/java/org/bukkit/block/data/BlockData.java index 62273e32e8..e7ea3f9a60 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/BlockData.java +++ b/paper-api/src/main/java/org/bukkit/block/data/BlockData.java @@ -7,6 +7,8 @@ import org.bukkit.SoundGroup; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockSupport; +import org.bukkit.block.PistonMoveReaction; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -108,6 +110,53 @@ public interface BlockData extends Cloneable { @NotNull SoundGroup getSoundGroup(); + /** + * Get the amount of light emitted by this state when in the world. + * + * @return the light emission + */ + int getLightEmission(); + + /** + * Check whether or not this state will occlude other blocks. + *

+ * Block state occlusion affects visual features of other blocks (e.g. leaves and + * wet sponges will not spawn dripping water particles if an occluding state is + * below it), or whether light will pass through it. + * + * @return true if occluding, false otherwise + */ + boolean isOccluding(); + + /** + * Check whether or not this state requires a specific item to be used to drop + * items when broken. For example, diamond ore requires an iron pickaxe and will + * not drop diamonds when broken with a wooden or stone pickaxe. + * + * @return true if a more specific item is required for drops, false if any item + * (or an empty hand) will drop items + */ + boolean requiresCorrectToolForDrops(); + + /** + * Returns if the given item is a preferred choice to break this Block. + * + * In some cases this determines if a block will drop anything or extra + * loot. + * + * @param tool The tool or item used for breaking this block + * @return true if the tool is preferred for breaking this block. + */ + boolean isPreferredTool(@NotNull ItemStack tool); + + /** + * Returns the reaction of the block when moved by a piston + * + * @return reaction + */ + @NotNull + PistonMoveReaction getPistonMoveReaction(); + /** * Checks if this state would be properly supported if it were placed at * the given {@link Block}. @@ -116,7 +165,6 @@ public interface BlockData extends Cloneable { * capable of surviving on its neighbouring block states. * * @param block the block position at which the state would be placed - * * @return true if the block is supported, false if this state would not survive * the world conditions */