#767: Add support checking/survivability methods for BlockData

By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
Bukkit/Spigot
2022-07-09 20:04:45 +10:00
parent 73d53d00e8
commit a4a0b99e49
2 changed files with 81 additions and 0 deletions

View File

@@ -1,8 +1,12 @@
package org.bukkit.block.data;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.SoundGroup;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockSupport;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -103,4 +107,48 @@ public interface BlockData extends Cloneable {
*/
@NotNull
SoundGroup getSoundGroup();
/**
* Checks if this state would be properly supported if it were placed at
* the given {@link Block}.
* <p>
* This may be useful, for instance, to check whether or not a wall torch is
* 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
*/
boolean isSupported(@NotNull Block block);
/**
* Checks if this state would be properly supported if it were placed at
* the block at the given {@link Location}.
* <p>
* This may be useful, for instance, to check whether or not a wall torch is
* capable of surviving on its neighbouring block states.
*
* @param location the location at which the state would be placed
*
* @return true if the block is supported, false if this state would not survive
* the world conditions
*/
boolean isSupported(@NotNull Location location);
/**
* Checks if a state's {@link BlockFace} is capable of providing a given level
* of {@link BlockSupport} for neighbouring block states.
* <p>
* Any given state may support either none, one, or more than one level of block
* support depending on its states. A common example would be a wall's ability to support
* torches only on the center of the upper block face, whereas a grass block would
* support all levels of block support on all block faces.
*
* @param face the face to check
* @param support the possible support level
*
* @return true if the face is sturdy and can support a block, false otherwise
*/
boolean isFaceSturdy(@NotNull BlockFace face, @NotNull BlockSupport support);
}