Class VSCHUtils

java.lang.Object
net.jcm.vsch.util.VSCHUtils

public class VSCHUtils extends Object
The main class where all handy utility functions used by VSCH are stored.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.joml.Vector3d
    clampVector(org.joml.Vector3d force, double limit)
    Clamps all axis of a Vector3d between -limit and +limit (not abs).
    static net.minecraft.server.level.ServerLevel
    dimToLevel(String dimensionString)
     
    static String
    dimToVSDim(String dimension)
    Converts a normal dimension id string of 'namespace:dimension_name' to a VS dimension id string 'minecraft:dimension:namespace:dimension_name'
    getDistanceToPlanet(net.minecraft.nbt.CompoundTag planetData, net.minecraft.world.phys.Vec3 position)
    Determines if a Vec3 position is colliding with / inside a planet.
    static List<org.valkyrienskies.core.api.ships.LoadedServerShip>
    getLoadedShipsInLevel(net.minecraft.server.level.ServerLevel level)
     
    static net.minecraft.nbt.CompoundTag
    getNearestPlanet(net.minecraft.world.level.LevelAccessor world, net.minecraft.world.phys.Vec3 position, String dimensionId)
    Gets the nearest (if available) planet to the position in the dimensionId.
    static net.lointain.cosmos.network.CosmosModVariables.PlayerVariables
    getPlayerCap(net.minecraft.world.entity.player.Player player)
    Gets a players Cosmos variables capability.
    static net.minecraft.network.chat.Component
     
    static net.minecraft.server.level.ServerLevel
    Get ServerLevel from a VS dimension ID.
    static org.joml.primitives.AABBd
    transformToAABBd(org.valkyrienskies.core.api.ships.properties.ShipTransform transform, org.joml.primitives.AABBic shipAABB)
    Takes in a ShipTransform and its ship AABBic (its shipyard AABBic) and returns a world-based AABBd using the transform

    Basically the same as Ship#getWorldAABB() but can take in a specified transform and ship AABBic
    static String
    vsDimToDim(String dimension)
    Converts a VS dimension id string of 'minecraft:dimension:namespace:dimension_name' to a normal dimension id string of 'namespace:dimension_name'

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VSCHUtils

      public VSCHUtils()
  • Method Details

    • vsDimToDim

      public static String vsDimToDim(String dimension)
      Converts a VS dimension id string of 'minecraft:dimension:namespace:dimension_name' to a normal dimension id string of 'namespace:dimension_name'
      Parameters:
      dimension - The VS format dimension id string
      Returns:
      The converted dimension id string
      See Also:
    • dimToVSDim

      public static String dimToVSDim(String dimension)
      Converts a normal dimension id string of 'namespace:dimension_name' to a VS dimension id string 'minecraft:dimension:namespace:dimension_name'
      Parameters:
      dimension - The normal format dimension id string
      Returns:
      The converted VS dimension id string
      See Also:
    • transformToAABBd

      public static org.joml.primitives.AABBd transformToAABBd(org.valkyrienskies.core.api.ships.properties.ShipTransform transform, org.joml.primitives.AABBic shipAABB)
      Takes in a ShipTransform and its ship AABBic (its shipyard AABBic) and returns a world-based AABBd using the transform

      Basically the same as Ship#getWorldAABB() but can take in a specified transform and ship AABBic
      Parameters:
      transform - The ship transform to use
      shipAABB - The shipyard AABBic of the ship
      Returns:
      The world based AABBd
    • registeryDimToLevel

      public static net.minecraft.server.level.ServerLevel registeryDimToLevel(String dimension)
      Get ServerLevel from a VS dimension ID.
      Parameters:
      dimension - The dimension ID string in format registry_namespace:registry_name:dimension_namespace:dimension_name
      Returns:
      A ServerLevel instance with the dimension ID given
    • dimToLevel

      public static net.minecraft.server.level.ServerLevel dimToLevel(String dimensionString)
    • getNearestPlanet

      @Nullable public static net.minecraft.nbt.CompoundTag getNearestPlanet(net.minecraft.world.level.LevelAccessor world, net.minecraft.world.phys.Vec3 position, String dimensionId)
      Gets the nearest (if available) planet to the position in the dimensionId.
      Parameters:
      world - A LevelAccessor for getting Cosmos world variables
      position - The position to get the nearest planet from
      dimensionId - The (normal format) dimension id to get planets from
      Returns:
      A CompoundTag of the nearest planets data, or null if it couldn't be found
    • getDistanceToPlanet

      public static VSCHUtils.DistanceInfo getDistanceToPlanet(@Nonnull net.minecraft.nbt.CompoundTag planetData, net.minecraft.world.phys.Vec3 position)
      Determines if a Vec3 position is colliding with / inside a planet. If the needed data from planetData is missing, that data will default to 0.0
      Parameters:
      planetData - A CompoundTag (nbt) of the planets data.
      position - The position to check
      Returns:
      Distance to the planet's surface
      See Also:
    • getPlayerCap

      public static net.lointain.cosmos.network.CosmosModVariables.PlayerVariables getPlayerCap(net.minecraft.world.entity.player.Player player)
      Gets a players Cosmos variables capability.
      Parameters:
      player - The player to get the capability of.
      Returns:
      The player's capability, or null if it does not exists.
    • clampVector

      public static org.joml.Vector3d clampVector(org.joml.Vector3d force, double limit)
      Clamps all axis of a Vector3d between -limit and +limit (not abs).
      Parameters:
      force - the vector to clamp
      limit - the limit to clamp all axis to
      Returns:
      clamped force
    • getLoadedShipsInLevel

      public static List<org.valkyrienskies.core.api.ships.LoadedServerShip> getLoadedShipsInLevel(net.minecraft.server.level.ServerLevel level)
    • getWarningComponent

      public static net.minecraft.network.chat.Component getWarningComponent()