Class PylonUtils
-
public final class PylonUtils
-
-
Field Summary
Fields Modifier and Type Field Description public final static Array<BlockFace>IMMEDIATE_FACESpublic final static Array<BlockFace>IMMEDIATE_FACES_WITH_DIAGONALS
-
Method Summary
Modifier and Type Method Description final BooleangetReplaceableOrAir()final StringgetPlainText()final static BooleanisKeyFromAddon(NamespacedKey $self, PylonAddon 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(Vector vector)Converts an orthogonal vector to a BlockFace final static BlockFacerotateToPlayerFacing(Player player, BlockFace face, Boolean allowVertical)Rotates a BlockFace to the player's reference frame. final static Vector3irotateVectorToFace(Vector3i vector, BlockFace face)Rotates vector to face a directionAssumes north to be the default direction (i.e. final static BooleanisCardinalDirection(Vector3i vector)final static BooleanisCardinalDirection(Vector3f vector)final static PylonAddongetAddon(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 IntegerfindPylonItemInInventory(Inventory inventory, PylonItem targetItem)Finds a Pylon item in an inventory. final static BooleanisPylonSimilar(ItemStack $self, ItemStack item2)Compares two Pylon items to check if they have the same Pylon ID. 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 voiddamageItem(ItemStack itemStack, Integer amount, LivingEntity entity)-
-
Method Detail
-
getReplaceableOrAir
final Boolean getReplaceableOrAir()
-
getPlainText
final String getPlainText()
-
isKeyFromAddon
final static Boolean isKeyFromAddon(NamespacedKey $self, PylonAddon 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(Vector vector)
Converts an orthogonal vector to a BlockFace
- Returns:
The face that the vector is facing
-
rotateToPlayerFacing
final static BlockFace rotateToPlayerFacing(Player player, BlockFace face, Boolean allowVertical)
Rotates a BlockFace to the player's reference frame.
- Parameters:
player- The player to act as the reference frame.face- The face to rotateallowVertical- Whether we should include UP and DOWN- Returns:
The block face rotated to the player's reference frame
-
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 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 PylonAddon 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.
-
findPylonItemInInventory
final static Integer findPylonItemInInventory(Inventory inventory, PylonItem targetItem)
Finds a Pylon item in an inventory. Use this to find Pylon items instead of traditional find methods, because this will compare Pylon IDs.
- Parameters:
inventory- The inventory to searchtargetItem- The item to find.- Returns:
The slot containing the item, or null if no item was found
-
isPylonSimilar
final static Boolean isPylonSimilar(ItemStack $self, ItemStack item2)
Compares two Pylon items to check if they have the same Pylon ID. If neither item is a Pylon item, the material will be compared instead.
- Returns:
Whether the items are the same.
-
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)
-
damageItem
final static void damageItem(ItemStack itemStack, Integer amount, LivingEntity entity)
-
-
-
-