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_HANDLERpublic final static DoubleFLUID_EPSILON
-
Method Summary
Modifier and Type Method Description final BooleangetReplaceableOrAir()final StringgetPlainText()final BooleangetIsChunkLoaded()final FloatgetBreakProgress()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 IntegerfindRebar(Inventory $self, NamespacedKey targetItemId)Finds a Rebar item in this inventory. final static IntegerfindRebar(Inventory $self, RebarItemSchema targetItem)Finds a Rebar item in this inventory. final static IntegerfindType(Inventory $self, ItemTypeWrapper targetType)Finds an item of the right type in this inventory. final static voidswapItem(Inventory $self, Integer from, Integer to)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>blocksWithin(World world, BoundingBox boundingBox)final static List<Block>blocksBetween(BlockPosition from, BlockPosition to)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)final static BooleanhasTracker(Entity $self)final static ItemStacksourceItem(Projectile $self)final static ItemStackgetWeaponItem(Entity $self)final static TextColorcolorToTextColor(Color $self)final static BooleanrebarTypeSimilar(ItemStack item1, ItemStack item2)Checks whether two items are of the same type, comparing Rebar IDs if they are Rebar items and vanilla IDs if they are not. final static <T extends Any> voidforceSetData(ItemStack $self, DataComponentType.Valued<T> type, Object value)final static voidsetComponents(ItemStack $self, Map<DataComponentType, Object> components)final static List<DataComponentType>overriddenDataTypes(ItemStack $self)final static MaterialgetPreferredTool(Material $self)-
-
Method Detail
-
getReplaceableOrAir
final Boolean getReplaceableOrAir()
-
getPlainText
final String getPlainText()
-
getIsChunkLoaded
final Boolean getIsChunkLoaded()
-
getBreakProgress
final Float getBreakProgress()
-
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)
-
findRebar
final static Integer findRebar(Inventory $self, NamespacedKey targetItemId)
Finds a Rebar item in this inventory. Use this to find Rebar items instead of traditional find methods, because this will compare Rebar IDs.
- Parameters:
targetItemId- The item id to find.- Returns:
The slot containing the item, or null if no item was found
-
findRebar
final static Integer findRebar(Inventory $self, RebarItemSchema targetItem)
Finds a Rebar item in this inventory. Use this to find Rebar items instead of traditional find methods, because this will compare Rebar IDs.
- Parameters:
targetItem- The item to find.- Returns:
The slot containing the item, or null if no item was found
-
findType
final static Integer findType(Inventory $self, ItemTypeWrapper targetType)
Finds an item of the right type in this inventory. Use this to find items purely based on Vanilla / Rebar IDs.
- Parameters:
targetType- The type 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)
-
blocksWithin
final static List<Block> blocksWithin(World world, BoundingBox boundingBox)
-
blocksBetween
final static List<Block> blocksBetween(BlockPosition from, BlockPosition to)
-
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)
-
hasTracker
final static Boolean hasTracker(Entity $self)
- Returns:
Whether the entity has at least one tracking player, a tracking player is just a player who has & is receiving packets for the entity.
-
sourceItem
final static ItemStack sourceItem(Projectile $self)
-
getWeaponItem
final static ItemStack getWeaponItem(Entity $self)
-
colorToTextColor
final static TextColor colorToTextColor(Color $self)
-
rebarTypeSimilar
final static Boolean rebarTypeSimilar(ItemStack item1, ItemStack item2)
Checks whether two items are of the same type, comparing Rebar IDs if they are Rebar items and vanilla IDs if they are not.
-
forceSetData
final static <T extends Any> void forceSetData(ItemStack $self, DataComponentType.Valued<T> type, Object value)
-
setComponents
final static void setComponents(ItemStack $self, Map<DataComponentType, Object> components)
-
overriddenDataTypes
final static List<DataComponentType> overriddenDataTypes(ItemStack $self)
-
getPreferredTool
final static Material getPreferredTool(Material $self)
-
-
-
-