Package net.bitbylogic.packetblocks.util
Class BoundingBoxes
java.lang.Object
net.bitbylogic.packetblocks.util.BoundingBoxes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<org.bukkit.util.BoundingBox> getBoxes(@NonNull org.bukkit.block.Block block) Retrieves a list of bounding boxes associated with the given block.static List<org.bukkit.util.BoundingBox> getBoxes(@NonNull org.bukkit.block.data.BlockData blockData) Retrieves a list of bounding boxes associated with the given block data.static List<org.bukkit.util.BoundingBox> getBoxesAt(@NonNull org.bukkit.Location location) Retrieves a list of bounding boxes associated with the given location.static List<org.bukkit.util.BoundingBox> getBoxesAt(@NonNull org.bukkit.block.Block block) Retrieves a list of world-space bounding boxes at the specified block's location.static List<org.bukkit.util.BoundingBox> getBoxesAt(@NonNull org.bukkit.block.data.BlockData blockData, @NonNull org.bukkit.Location location) Calculates a list of world-space bounding boxes for the provided block data at the given location.static voidinit(@NonNull PacketBlocks plugin) static org.bukkit.util.RayTraceResultrayTraceAt(@NonNull org.bukkit.block.Block block, @NonNull org.bukkit.block.data.BlockData blockData, @NonNull org.bukkit.util.Vector start, @NonNull org.bukkit.util.Vector direction, double maxDistance) Performs a ray trace operation against the bounding boxes of the specified block and block data.
-
Constructor Details
-
BoundingBoxes
public BoundingBoxes()
-
-
Method Details
-
init
-
getBoxes
public static List<org.bukkit.util.BoundingBox> getBoxes(@NonNull @NonNull org.bukkit.block.data.BlockData blockData) Retrieves a list of bounding boxes associated with the given block data. The method fetches cached bounding boxes if available, otherwise parses and generates bounding boxes from a predefined JSON structure.- Parameters:
blockData- the block data for which the bounding boxes are retrieved; must not be null- Returns:
- a list of bounding boxes associated with the given block data, or null if no bounding boxes are defined
-
getBoxes
public static List<org.bukkit.util.BoundingBox> getBoxes(@NonNull @NonNull org.bukkit.block.Block block) Retrieves a list of bounding boxes associated with the given block. This method internally resolves block data from the provided block and delegates the operation to fetch the bounding boxes.- Parameters:
block- the block for which the bounding boxes are retrieved; must not be null- Returns:
- a list of bounding boxes associated with the provided block, or null if no bounding boxes are defined
-
getBoxesAt
public static List<org.bukkit.util.BoundingBox> getBoxesAt(@NonNull @NonNull org.bukkit.block.data.BlockData blockData, @NonNull @NonNull org.bukkit.Location location) Calculates a list of world-space bounding boxes for the provided block data at the given location. The method retrieves bounding boxes defined for the block data, adjusts their positions based on the block's location in the world, and returns the resulting list.- Parameters:
blockData- the block data used to retrieve and calculate bounding boxes; must not be nulllocation- the location of the block in the world, used to translate the bounding boxes; must not be null- Returns:
- a list of bounding boxes translated to world coordinates; an empty list if no bounding boxes are defined
-
getBoxesAt
public static List<org.bukkit.util.BoundingBox> getBoxesAt(@NonNull @NonNull org.bukkit.block.Block block) Retrieves a list of world-space bounding boxes at the specified block's location. This method resolves the block data from the provided block and calculates the bounding boxes based on the block's location in the world.- Parameters:
block- the block for which the bounding boxes are to be calculated; must not be null- Returns:
- a list of bounding boxes aligned to the world-space location of the specified block, or an empty list if no bounding boxes are defined
-
getBoxesAt
public static List<org.bukkit.util.BoundingBox> getBoxesAt(@NonNull @NonNull org.bukkit.Location location) Retrieves a list of bounding boxes associated with the given location. The method resolves the block at the specified location and retrieves its bounding boxes by delegating the operation to another method.- Parameters:
location- the location for which the bounding boxes are retrieved; must not be null- Returns:
- a list of bounding boxes associated with the block at the given location
-
rayTraceAt
public static org.bukkit.util.RayTraceResult rayTraceAt(@NonNull @NonNull org.bukkit.block.Block block, @NonNull @NonNull org.bukkit.block.data.BlockData blockData, @NonNull @NonNull org.bukkit.util.Vector start, @NonNull @NonNull org.bukkit.util.Vector direction, double maxDistance) Performs a ray trace operation against the bounding boxes of the specified block and block data. This method calculates the world-space bounding boxes for the given block data at the block's location, then performs a ray trace on each bounding box to find the closest intersection point.- Parameters:
block- the block for which the ray trace is performed; must not be nullblockData- the block data of the block; must not be nullstart- the starting position of the ray; must not be nulldirection- the direction vector of the ray; must not be nullmaxDistance- the maximum distance to trace; must be a positive double- Returns:
- the closest
RayTraceResultif an intersection is found, ornullif no intersection occurs within the specified bounds
-