@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class CubePos
extends java.lang.Object
Tall Worlds uses a column coordinate system (which is really just a cube coordinate system without the y-coordinate), a cube coordinate system, and two block coordinate systems, a cube-relative system, and a world absolute system.
It is important that the systems are kept separate. This class should be used whenever a cube coordinate is passed along, so that it is clear that cube coordinates are being used, and not block coordinates.
Additionally, I (Nick) like to use xRel, yRel, and zRel for the relative position of a block inside of a cube. In world space, I (Nick) refer to the coordinates as xAbs, yAbs, and zAbs.
This class also contains some helper methods to switch from/to block coordinates.
| Constructor and Description |
|---|
CubePos(int cubeX,
int cubeY,
int cubeZ) |
CubePos(XYZAddressable addressable) |
| Modifier and Type | Method and Description |
|---|---|
CubePos |
above() |
CubePos |
add(int dx,
int dy,
int dz) |
CubePos |
below() |
net.minecraft.util.math.ChunkPos |
chunkPos() |
boolean |
containsBlock(net.minecraft.util.math.BlockPos pos) |
int |
distSquared(CubePos coords) |
boolean |
equals(java.lang.Object obj)
Compares the CubeCoordinate against the given object.
|
void |
forEachWithinRange(int range,
java.util.function.Consumer<CubePos> action) |
static CubePos |
fromBlockCoords(net.minecraft.util.math.BlockPos pos) |
static CubePos |
fromBlockCoords(int blockX,
int blockY,
int blockZ) |
static CubePos |
fromEntity(net.minecraft.entity.Entity entity) |
static CubePos |
fromEntityCoords(double blockX,
double blockY,
double blockZ) |
net.minecraft.util.math.BlockPos |
getCenterBlockPos() |
net.minecraft.util.math.BlockPos |
getMaxBlockPos() |
int |
getMaxBlockX() |
int |
getMaxBlockY() |
int |
getMaxBlockZ() |
net.minecraft.util.math.BlockPos |
getMinBlockPos() |
int |
getMinBlockX() |
int |
getMinBlockY() |
int |
getMinBlockZ() |
int |
getX()
Gets the x position of the cube in the world.
|
int |
getXCenter()
Gets the absolute position of the cube's center on the x axis.
|
int |
getY()
Gets the y position of the cube in the world.
|
int |
getYCenter()
Gets the absolute position of the cube's center on the y axis.
|
int |
getZ()
Gets the z position of the cube in the world.
|
int |
getZCenter()
Gets the absolute position of the cube's center on the z axis.
|
int |
hashCode()
Returns a specification compliant hashCode for this object.
|
net.minecraft.util.math.BlockPos |
localToBlock(int localX,
int localY,
int localZ) |
net.minecraft.util.math.BlockPos |
randomPopulationPos(java.util.Random rand) |
CubePos |
sub(int dx,
int dy,
int dz) |
java.lang.String |
toString()
Gets the coordinates of the cube as a string.
|
public static final CubePos ZERO
public CubePos(int cubeX,
int cubeY,
int cubeZ)
public CubePos(XYZAddressable addressable)
public int getX()
public int getY()
public int getZ()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(@Nullable
java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int getXCenter()
public int getYCenter()
public int getZCenter()
public int getMinBlockX()
public int getMinBlockY()
public int getMinBlockZ()
public int getMaxBlockX()
public int getMaxBlockY()
public int getMaxBlockZ()
public net.minecraft.util.math.BlockPos getCenterBlockPos()
public net.minecraft.util.math.BlockPos getMinBlockPos()
public net.minecraft.util.math.BlockPos getMaxBlockPos()
public net.minecraft.util.math.BlockPos localToBlock(int localX,
int localY,
int localZ)
public CubePos sub(int dx, int dy, int dz)
public CubePos add(int dx, int dy, int dz)
public net.minecraft.util.math.ChunkPos chunkPos()
public int distSquared(CubePos coords)
public void forEachWithinRange(int range,
java.util.function.Consumer<CubePos> action)
public net.minecraft.util.math.BlockPos randomPopulationPos(java.util.Random rand)
public CubePos above()
public CubePos below()
public static CubePos fromBlockCoords(int blockX, int blockY, int blockZ)
public static CubePos fromEntityCoords(double blockX, double blockY, double blockZ)
public static CubePos fromEntity(net.minecraft.entity.Entity entity)
public static CubePos fromBlockCoords(net.minecraft.util.math.BlockPos pos)
public boolean containsBlock(net.minecraft.util.math.BlockPos pos)