Class RebarUtils
-
public final class RebarUtils
-
-
Field Summary
Fields Modifier and Type Field Description public final static Array<BlockFace>CARDINAL_FACESpublic final static Array<BlockFace>IMMEDIATE_FACESpublic final static Array<BlockFace>IMMEDIATE_FACES_WITH_DIAGONALSpublic final static Consumer<ItemPreUpdateEvent>DISALLOW_PLAYERS_FROM_ADDING_ITEMS_HANDLER
-
Method Summary
Modifier and Type Method Description final BooleangetReplaceableOrAir()final StringgetPlainText()final static BooleanisKeyFromAddon(NamespacedKey $self, RebarAddon addon)Checks whether a NamespacedKey is from addon final static BlockFacevectorToBlockFace(Vector3i vector)Converts an orthogonal vector to a BlockFace final static BlockFacevectorToBlockFace(Vector3f vector)Converts an orthogonal vector to a BlockFace final static BlockFacevectorToBlockFace(Vector3d vector)Converts an orthogonal vector to a BlockFace final static BlockFacevectorToBlockFace(Vector vector)Converts an orthogonal vector to a BlockFace final static DoublefaceToYaw(BlockFace face)Returns the yaw (in radians) that a face has, starting at NORTH and going counterclockwise. final static Vector3irotateVectorToFace(Vector3i vector, BlockFace face)Rotates vector to face a directionAssumes north to be the default direction (i.e. final static Vector3drotateVectorToFace(Vector3d vector, BlockFace face)Rotates vector to face a directionAssumes north to be the default direction (i.e. final static BlockFacerotateFaceToReference(BlockFace referenceFace, BlockFace face)Rotates face to be relative to referenceFace. final static BooleanisCardinalDirection(Vector3i vector)final static BooleanisCardinalDirection(Vector3f vector)final static RebarAddongetAddon(NamespacedKey key)final static ComponentattachArguments(Component $self, List<TranslationArgumentLike> args)Attaches arguments to a component and all its children. final static BooleanisFakeEvent(Event event)(Heuristically) checks whether an event is 'fake' (by checking if it has 'Fake' in its name)'Fake' events are often used to check actions before performing them. final static List<BlockFace>perpendicularImmediateFaces(BlockFace face)Returns all the immediate faces that are perpendicular to the given face final static BooleanisSubclassOf(Class<?> $self, Class<?> other)final static IntegerfindRebarItemInInventory(Inventory inventory, RebarItem targetItem)Finds a Rebar item in an inventory. final static <P extends Any, C extends Any> voidsetNullable(PersistentDataContainer $self, NamespacedKey key, PersistentDataType<P, C> type, C value)Wrapper around PersistentDataContainer.set that allows nullable values to be passed final static ComponentvanillaDisplayName(ItemStack $self)final static List<Block>blocksOnPath(BlockPosition from, BlockPosition to)Does not include first or last block final static FloatfindClosestPointBetweenSkewLines(Vector3f p1, Vector3f d1, Vector3f p2, Vector3f d2)final static FloatfindClosestPointToOtherPointOnLine(Vector3f p, Vector3f p1, Vector3f d1)final static FloatfindClosestDistanceBetweenLineAndPoint(Vector3f p, Vector3f p1, Vector3f d1)Unidirectional, meaning if the closest point is 'behind' the starting point, returns the distance from the starting point. final static Tag<BlockType>pickaxeMineable()final static Tag<BlockType>axeMineable()final static Tag<BlockType>shovelMineable()final static Tag<BlockType>hoeMineable()final static voiddamageItem(ItemStack itemStack, Integer amount, World world, Function1<Material, Unit> onBreak, Boolean force)final static voiddamageItem(ItemStack itemStack, Integer amount, World world, Function1<Material, Unit> onBreak)final static voiddamageItem(ItemStack itemStack, Integer amount, World world)final static voiddamageItem(ItemStack itemStack, Integer amount, LivingEntity entity, EquipmentSlot slot, Boolean force)final static voiddamageItem(ItemStack itemStack, Integer amount, LivingEntity entity, EquipmentSlot slot)final static FloatgetBlockBreakTicks(ItemStack tool, Block block)final static BukkitTaskscheduleRemove(Entity $self)Schedules the entity to be removed next tick final static BlockgetRelative(Block $self, Vector3i vector)-
-
Method Detail
-
getReplaceableOrAir
final Boolean getReplaceableOrAir()
-
getPlainText
final String getPlainText()
-
isKeyFromAddon
final static Boolean isKeyFromAddon(NamespacedKey $self, RebarAddon addon)
Checks whether a NamespacedKey is from addon
-
vectorToBlockFace
final static BlockFace vectorToBlockFace(Vector3i vector)
Converts an orthogonal vector to a BlockFace
- Returns:
The face that the vector is facing
-
vectorToBlockFace
final static BlockFace vectorToBlockFace(Vector3f vector)
Converts an orthogonal vector to a BlockFace
- Returns:
The face that the vector is facing
-
vectorToBlockFace
final static BlockFace vectorToBlockFace(Vector3d vector)
Converts an orthogonal vector to a BlockFace
- Returns:
The face that the vector is facing
-
vectorToBlockFace
final static BlockFace vectorToBlockFace(Vector vector)
Converts an orthogonal vector to a BlockFace
- Returns:
The face that the vector is facing
-
faceToYaw
final static Double faceToYaw(BlockFace face)
Returns the yaw (in radians) that a face has, starting at NORTH and going counterclockwise.
Only works for cardinal directions.
-
rotateVectorToFace
final static Vector3i rotateVectorToFace(Vector3i vector, BlockFace face)
Rotates vector to face a direction
Assumes north to be the default direction (i.e. supplying north will result in no rotation)
- Parameters:
face- Must be a immediate direction (north, east, south, west, up, down)- Returns:
The rotated vector
-
rotateVectorToFace
final static Vector3d rotateVectorToFace(Vector3d vector, BlockFace face)
Rotates vector to face a direction
Assumes north to be the default direction (i.e. supplying north will result in no rotation)
- Parameters:
face- Must be a immediate direction (north, east, south, west, up, down)- Returns:
The rotated vector
-
rotateFaceToReference
final static BlockFace rotateFaceToReference(BlockFace referenceFace, BlockFace face)
Rotates face to be relative to referenceFace.
Assumes north to be the default direction (i.e. supplying north will result in no rotation)
Think of this like changing the direction of North. For example, if you change North to point where East would be, then suddenly East in your coordinate system becomes South.
- Parameters:
face- Must be a horizontal cardinal direction (north, east, south, west)- Returns:
The rotated vector
-
isCardinalDirection
final static Boolean isCardinalDirection(Vector3i vector)
- Returns:
Whether vector is a cardinal direction
-
isCardinalDirection
final static Boolean isCardinalDirection(Vector3f vector)
- Returns:
Whether vector is a cardinal direction
-
getAddon
final static RebarAddon getAddon(NamespacedKey key)
- Returns:
The addon that key belongs to
-
attachArguments
final static Component attachArguments(Component $self, List<TranslationArgumentLike> args)
Attaches arguments to a component and all its children.
- Parameters:
args- List of arguments to attach- Returns:
The component with the arguments attached
-
isFakeEvent
final static Boolean isFakeEvent(Event event)
(Heuristically) checks whether an event is 'fake' (by checking if it has 'Fake' in its name)
'Fake' events are often used to check actions before performing them.
-
perpendicularImmediateFaces
final static List<BlockFace> perpendicularImmediateFaces(BlockFace face)
Returns all the immediate faces that are perpendicular to the given face
-
isSubclassOf
final static Boolean isSubclassOf(Class<?> $self, Class<?> other)
-
findRebarItemInInventory
final static Integer findRebarItemInInventory(Inventory inventory, RebarItem targetItem)
Finds a Rebar item in an inventory. Use this to find Rebar items instead of traditional find methods, because this will compare Rebar IDs.
- Parameters:
inventory- The inventory to searchtargetItem- The item to find.- Returns:
The slot containing the item, or null if no item was found
-
setNullable
final static <P extends Any, C extends Any> void setNullable(PersistentDataContainer $self, NamespacedKey key, PersistentDataType<P, C> type, C value)
Wrapper around PersistentDataContainer.set that allows nullable values to be passed
- Parameters:
value- The value to set.
-
vanillaDisplayName
final static Component vanillaDisplayName(ItemStack $self)
-
blocksOnPath
final static List<Block> blocksOnPath(BlockPosition from, BlockPosition to)
Does not include first or last block
-
findClosestPointBetweenSkewLines
final static Float findClosestPointBetweenSkewLines(Vector3f p1, Vector3f d1, Vector3f p2, Vector3f d2)
-
findClosestPointToOtherPointOnLine
final static Float findClosestPointToOtherPointOnLine(Vector3f p, Vector3f p1, Vector3f d1)
- Parameters:
p- The pointp1- The starting point of the lined1- The direction of the line- Returns:
Supposing the equation of the line is p1 + t*d1, returns the t representing the closest point
-
findClosestDistanceBetweenLineAndPoint
final static Float findClosestDistanceBetweenLineAndPoint(Vector3f p, Vector3f p1, Vector3f d1)
Unidirectional, meaning if the closest point is 'behind' the starting point, returns the distance from the starting point.
- Parameters:
p- The pointp1- The starting point of the lined1- The direction of the line
-
pickaxeMineable
final static Tag<BlockType> pickaxeMineable()
-
axeMineable
final static Tag<BlockType> axeMineable()
-
shovelMineable
final static Tag<BlockType> shovelMineable()
-
hoeMineable
final static Tag<BlockType> hoeMineable()
-
damageItem
final static void damageItem(ItemStack itemStack, Integer amount, World world, Function1<Material, Unit> onBreak, Boolean force)
-
damageItem
final static void damageItem(ItemStack itemStack, Integer amount, World world, Function1<Material, Unit> onBreak)
-
damageItem
final static void damageItem(ItemStack itemStack, Integer amount, World world)
-
damageItem
final static void damageItem(ItemStack itemStack, Integer amount, LivingEntity entity, EquipmentSlot slot, Boolean force)
-
damageItem
final static void damageItem(ItemStack itemStack, Integer amount, LivingEntity entity, EquipmentSlot slot)
-
getBlockBreakTicks
final static Float getBlockBreakTicks(ItemStack tool, Block block)
-
scheduleRemove
final static BukkitTask scheduleRemove(Entity $self)
Schedules the entity to be removed next tick
-
getRelative
final static Block getRelative(Block $self, Vector3i vector)
-
-
-
-