Package net.paulem.arcana.utils
Class BlockUtils
java.lang.Object
net.paulem.arcana.utils.BlockUtils
Utility methods for working with blocks and locations, such as enumerating
nearby locations, walking between two points, and converting block faces to vectors.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.util.VectorfaceToVector(org.bukkit.block.BlockFace face) Converts aBlockFaceto a unit vector pointing in that direction.static org.bukkit.util.VectorfaceToVector(org.bukkit.block.BlockFace face, int distance) Converts aBlockFaceto a vector pointing in that direction, scaled bydistance.static List<org.bukkit.Location> getBlocksAround(org.bukkit.Location center, int radiusX, int radiusY, int radiusZ) Returns every location inside the cuboid centered oncenter, extendingradiusX,radiusYandradiusZblocks on each axis (inclusive).static List<org.bukkit.block.Block> getBlocksBetween(org.bukkit.Location loc1, org.bukkit.Location loc2) Walks fromloc1towardsloc2and collects the blocks encountered along the way.
-
Constructor Details
-
BlockUtils
public BlockUtils()
-
-
Method Details
-
getBlocksAround
public static List<org.bukkit.Location> getBlocksAround(org.bukkit.Location center, int radiusX, int radiusY, int radiusZ) Returns every location inside the cuboid centered oncenter, extendingradiusX,radiusYandradiusZblocks on each axis (inclusive). The center location itself is included in the result.- Parameters:
center- the center of the cuboidradiusX- the radius on the X axisradiusY- the radius on the Y axisradiusZ- the radius on the Z axis- Returns:
- the list of locations contained in the cuboid
-
getBlocksBetween
public static List<org.bukkit.block.Block> getBlocksBetween(org.bukkit.Location loc1, org.bukkit.Location loc2) Walks fromloc1towardsloc2and collects the blocks encountered along the way. The straight-line distance between the two locations is split into unit-length steps, and the block at each step is added to the result until the block atloc2is reached or the computed number of steps is exhausted. If both locations are at the same position, a single-element list containing that block is returned.- Parameters:
loc1- the starting locationloc2- the ending location- Returns:
- the list of blocks encountered while walking from
loc1toloc2
-
faceToVector
public static org.bukkit.util.Vector faceToVector(org.bukkit.block.BlockFace face) Converts aBlockFaceto a unit vector pointing in that direction.- Parameters:
face- the block face to convert- Returns:
- a vector of length 1 pointing towards
face
-
faceToVector
public static org.bukkit.util.Vector faceToVector(org.bukkit.block.BlockFace face, int distance) Converts aBlockFaceto a vector pointing in that direction, scaled bydistance.- Parameters:
face- the block face to convertdistance- the length to scale the resulting vector to- Returns:
- a vector pointing towards
face, scaled bydistance
-