Class DefaultSableCompanion
java.lang.Object
dev.ryanhcode.sable.companion.impl.DefaultSableCompanion
- All Implemented Interfaces:
SableCompanion
Default implementation of
SableCompanion for when Sable is missing at runtime.-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.ryanhcode.sable.companion.SableCompanion
SableCompanion.LoadPriority -
Field Summary
Fields inherited from interface dev.ryanhcode.sable.companion.SableCompanion
INSTANCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubledistanceSquaredWithSubLevels(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 a, net.minecraft.world.phys.Vec3 b) Computes the distance squared between two points, taking into account sublevels and their plots/poses.doubledistanceSquaredWithSubLevels(net.minecraft.world.level.Level level, org.joml.Vector3dc a, org.joml.Vector3dc b) Computes the distance squared between two points, taking into account sublevels and their plots/poses.booleanfindIncludingSubLevels(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 origin, boolean shouldCheckOrigin, @Nullable SubLevelAccess subLevel, BiFunction<@Nullable SubLevelAccess, net.minecraft.core.BlockPos, Boolean> converter) Checks positions in a level, including sublevels, for a true value from the converter.getAllIntersecting(net.minecraft.world.level.Level level, BoundingBox3dc bounds) Gets all sublevels that intersect with the given bounding boxnet.minecraft.world.level.Level@Nullable SubLevelAccessgetContaining(net.minecraft.world.level.Level level, int chunkX, int chunkZ) Gets the sub-level that contains the given point in its plot, or null if none donet.minecraft.world.phys.Vec3getVelocity(net.minecraft.world.level.Level level, SubLevelAccess subLevel, net.minecraft.world.phys.Vec3 pos) Gets the global velocity of a point in a sub-levelorg.joml.Vector3dgetVelocity(net.minecraft.world.level.Level level, SubLevelAccess subLevel, org.joml.Vector3dc pos, org.joml.Vector3d dest) Gets the global velocity of a point in a sub-levelnet.minecraft.world.phys.Vec3getVelocity(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 pos) Gets the global velocity of a point in a level, taking into account sub-level movement.org.joml.Vector3dgetVelocity(net.minecraft.world.level.Level level, org.joml.Vector3dc pos, org.joml.Vector3d dest) Gets the global velocity of a point in a level, taking into account sub-level movement.net.minecraft.world.phys.Vec3getVelocityRelativeToAir(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 pos) Gets the global velocity of a point in a level relative to the air, taking into account sublevels and their plots/posesorg.joml.Vector3dgetVelocityRelativeToAir(net.minecraft.world.level.Level level, org.joml.Vector3dc pos, org.joml.Vector3d dest) Gets the global velocity of a point in a level relative to the air, taking into account sublevels and their plots/posesbooleanisInPlotGrid(net.minecraft.world.level.Level level, int chunkX, int chunkZ) Checks if the plot grid contains the given chunk.net.minecraft.world.phys.Vec3projectOutOfSubLevel(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 pos) Projects a point out of a sublevel, if it is within oneorg.joml.Vector3dprojectOutOfSubLevel(net.minecraft.world.level.Level level, org.joml.Vector3dc pos, org.joml.Vector3d dest) Projects a point out of a sublevel, if it is within one<T> TrunIncludingSubLevels(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 origin, boolean shouldCheckOrigin, @Nullable SubLevelAccess subLevel, BiFunction<@Nullable SubLevelAccess, net.minecraft.core.BlockPos, T> converter) Checks positions in a level, including sublevels, for a valid position matching the converter to a non-null value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.ryanhcode.sable.companion.SableCompanion
getContaining, getContaining, getContaining, getContaining, getContaining, getContaining, getContainingClient, getContainingClient, getContainingClient, isInPlotGrid, isInPlotGrid, isInPlotGrid, isInPlotGrid, isInPlotGrid, isInPlotGrid
-
Constructor Details
-
DefaultSableCompanion
public DefaultSableCompanion()
-
-
Method Details
-
getAllIntersecting
public Iterable<SubLevelAccess> getAllIntersecting(net.minecraft.world.level.Level level, BoundingBox3dc bounds) Description copied from interface:SableCompanionGets all sublevels that intersect with the given bounding box- Specified by:
getAllIntersectingin interfaceSableCompanion- Parameters:
bounds- The bounding box to check.
NOTE: the bounds must NOT be modified during the iteration. this will cause undefined behavior!
-
getContaining
@Nullable public @Nullable SubLevelAccess getContaining(net.minecraft.world.level.Level level, int chunkX, int chunkZ) Description copied from interface:SableCompanionGets the sub-level that contains the given point in its plot, or null if none do- Specified by:
getContainingin interfaceSableCompanion- Parameters:
level- the level to checkchunkX- the global chunk X positionchunkZ- the global chunk Z position- Returns:
- the sub-level that contains the point, or null if none do
-
projectOutOfSubLevel
public org.joml.Vector3d projectOutOfSubLevel(net.minecraft.world.level.Level level, org.joml.Vector3dc pos, org.joml.Vector3d dest) Description copied from interface:SableCompanionProjects a point out of a sublevel, if it is within one- Specified by:
projectOutOfSubLevelin interfaceSableCompanion- Parameters:
level- the level to checkpos- the point to project- Returns:
- the projected point
-
projectOutOfSubLevel
public net.minecraft.world.phys.Vec3 projectOutOfSubLevel(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 pos) Description copied from interface:SableCompanionProjects a point out of a sublevel, if it is within one- Specified by:
projectOutOfSubLevelin interfaceSableCompanion- Parameters:
level- the level to checkpos- the point to project- Returns:
- the projected point
-
runIncludingSubLevels
@Nullable public <T> T runIncludingSubLevels(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 origin, boolean shouldCheckOrigin, @Nullable @Nullable SubLevelAccess subLevel, BiFunction<@Nullable SubLevelAccess, net.minecraft.core.BlockPos, T> converter) Description copied from interface:SableCompanionChecks positions in a level, including sublevels, for a valid position matching the converter to a non-null value. Priority: World -> World, Sub-level -> World, World -> Sub-level- Specified by:
runIncludingSubLevelsin interfaceSableCompanion- Type Parameters:
T- The type of the resulting value- Parameters:
level- The levelorigin- The origin to checkshouldCheckOrigin- Whether the origin should be checkedsubLevel- The data the origin is assumed to be inconverter- The function to convert a BlockPos to a non-null value- Returns:
- The resulting value from the converter, or null if nothing is found for all 3 check sets that are done
-
findIncludingSubLevels
public boolean findIncludingSubLevels(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 origin, boolean shouldCheckOrigin, @Nullable @Nullable SubLevelAccess subLevel, BiFunction<@Nullable SubLevelAccess, net.minecraft.core.BlockPos, Boolean> converter) Description copied from interface:SableCompanionChecks positions in a level, including sublevels, for a true value from the converter. Priority: World -> World, Sub-level -> World, World -> Sub-level- Specified by:
findIncludingSubLevelsin interfaceSableCompanion- Parameters:
level- The levelorigin- The origin to checkshouldCheckOrigin- Whether the origin should be checkedsubLevel- The data the origin is assumed to be inconverter- The function to convert a BlockPos to a boolean value- Returns:
- True if any of the checks returned true, otherwise false
-
distanceSquaredWithSubLevels
public double distanceSquaredWithSubLevels(net.minecraft.world.level.Level level, org.joml.Vector3dc a, org.joml.Vector3dc b) Description copied from interface:SableCompanionComputes the distance squared between two points, taking into account sublevels and their plots/poses.- Specified by:
distanceSquaredWithSubLevelsin interfaceSableCompanion- Parameters:
level- the level to checka- the first pointb- the second point- Returns:
- the distance squared between the two points
-
distanceSquaredWithSubLevels
public double distanceSquaredWithSubLevels(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 a, net.minecraft.world.phys.Vec3 b) Description copied from interface:SableCompanionComputes the distance squared between two points, taking into account sublevels and their plots/poses.- Specified by:
distanceSquaredWithSubLevelsin interfaceSableCompanion- Parameters:
level- the level to checka- the first pointb- the second point- Returns:
- the distance squared between the two points
-
getVelocity
public org.joml.Vector3d getVelocity(net.minecraft.world.level.Level level, org.joml.Vector3dc pos, org.joml.Vector3d dest) Description copied from interface:SableCompanionGets the global velocity of a point in a level, taking into account sub-level movement.- Specified by:
getVelocityin interfaceSableCompanion- Parameters:
level- the level to checkpos- the position of the pointdest- the vector to hold the result- Returns:
- the global velocity of the point stored in dest [m/s]
-
getVelocity
public net.minecraft.world.phys.Vec3 getVelocity(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 pos) Description copied from interface:SableCompanionGets the global velocity of a point in a level, taking into account sub-level movement.- Specified by:
getVelocityin interfaceSableCompanion- Parameters:
level- the level to checkpos- the position of the point- Returns:
- the global velocity of the point stored in dest [m/s]
-
getVelocity
public org.joml.Vector3d getVelocity(net.minecraft.world.level.Level level, SubLevelAccess subLevel, org.joml.Vector3dc pos, org.joml.Vector3d dest) Description copied from interface:SableCompanionGets the global velocity of a point in a sub-level- Specified by:
getVelocityin interfaceSableCompanion- Parameters:
level- the level to checksubLevel- the sub-level the point is assumed to be inpos- the position of the pointdest- the vector to hold the result- Returns:
- the global velocity of the point stored in dest [m/s]
-
getVelocity
public net.minecraft.world.phys.Vec3 getVelocity(net.minecraft.world.level.Level level, SubLevelAccess subLevel, net.minecraft.world.phys.Vec3 pos) Description copied from interface:SableCompanionGets the global velocity of a point in a sub-level- Specified by:
getVelocityin interfaceSableCompanion- Parameters:
level- the level to checksubLevel- the sub-level the point is assumed to be inpos- the position of the point- Returns:
- the global velocity of the point stored in dest [m/s]
-
getVelocityRelativeToAir
public org.joml.Vector3d getVelocityRelativeToAir(net.minecraft.world.level.Level level, org.joml.Vector3dc pos, org.joml.Vector3d dest) Description copied from interface:SableCompanionGets the global velocity of a point in a level relative to the air, taking into account sublevels and their plots/poses- Specified by:
getVelocityRelativeToAirin interfaceSableCompanion- Parameters:
level- the level to checkpos- the position of the pointdest- the vector to hold the result- Returns:
- the global velocity of the point stored in dest [m/s]
-
getVelocityRelativeToAir
public net.minecraft.world.phys.Vec3 getVelocityRelativeToAir(net.minecraft.world.level.Level level, net.minecraft.world.phys.Vec3 pos) Description copied from interface:SableCompanionGets the global velocity of a point in a level relative to the air, taking into account sublevels and their plots/poses- Specified by:
getVelocityRelativeToAirin interfaceSableCompanion- Parameters:
level- the level to checkpos- the position of the point- Returns:
- the global velocity of the point stored in dest [m/s]
-
isInPlotGrid
public boolean isInPlotGrid(net.minecraft.world.level.Level level, int chunkX, int chunkZ) Description copied from interface:SableCompanionChecks if the plot grid contains the given chunk.- Specified by:
isInPlotGridin interfaceSableCompanion- Parameters:
level- the level to checkchunkX- the global chunk X positionchunkZ- the global chunk Z position- Returns:
- If the chunk is inside the plot-grid
-
getClientLevel
public net.minecraft.world.level.Level getClientLevel()- Specified by:
getClientLevelin interfaceSableCompanion- Returns:
- The client level instance for #getContainingClient instances
-