Record Class TileCoord
java.lang.Object
java.lang.Record
io.hymods.lib.tiles.TileCoord
- Record Components:
x- Tile X coordinate in world spacez- Tile Z coordinate in world space
Represents a tile coordinate in world space.
Tiles are fixed regions of the world, each covering TILE_SIZE_CHUNKS chunks.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(int dx, int dz) Add an offset to this tile coordinate.doublecenterBlockX(int tileSizeChunks) Get the center block X coordinate of this tile.doublecenterBlockZ(int tileSizeChunks) Get the center block Z coordinate of this tile.final booleanIndicates whether some other object is "equal to" this one.static TileCoordfromBlock(double blockX, double blockZ, int tileSizeChunks) Calculate the tile coordinate that contains a given block coordinate.static TileCoordfromChunk(int chunkX, int chunkZ, int tileSizeChunks) Calculate the tile coordinate that contains a given chunk coordinate.final inthashCode()Returns a hash code value for this object.intmaxChunkX(int tileSizeChunks) Get the maximum chunk X coordinate covered by this tile (inclusive).intmaxChunkZ(int tileSizeChunks) Get the maximum chunk Z coordinate covered by this tile (inclusive).doubleminBlockX(int tileSizeChunks) Get the minimum block X coordinate of this tile.doubleminBlockZ(int tileSizeChunks) Get the minimum block Z coordinate of this tile.intminChunkX(int tileSizeChunks) Get the minimum chunk X coordinate covered by this tile.intminChunkZ(int tileSizeChunks) Get the minimum chunk Z coordinate covered by this tile.Calculate offset from another tile coordinate.toString()Returns a string representation of this record class.intx()Returns the value of thexrecord component.intz()Returns the value of thezrecord component.
-
Field Details
-
BLOCKS_PER_CHUNK
public static final int BLOCKS_PER_CHUNK- See Also:
-
-
Constructor Details
-
TileCoord
-
-
Method Details
-
fromChunk
Calculate the tile coordinate that contains a given chunk coordinate.- Parameters:
chunkX- Chunk X coordinatechunkZ- Chunk Z coordinatetileSizeChunks- Size of each tile in chunks- Returns:
- The tile coordinate containing this chunk
-
fromBlock
Calculate the tile coordinate that contains a given block coordinate.- Parameters:
blockX- Block X coordinateblockZ- Block Z coordinatetileSizeChunks- Size of each tile in chunks- Returns:
- The tile coordinate containing this block
-
minChunkX
public int minChunkX(int tileSizeChunks) Get the minimum chunk X coordinate covered by this tile. -
minChunkZ
public int minChunkZ(int tileSizeChunks) Get the minimum chunk Z coordinate covered by this tile. -
maxChunkX
public int maxChunkX(int tileSizeChunks) Get the maximum chunk X coordinate covered by this tile (inclusive). -
maxChunkZ
public int maxChunkZ(int tileSizeChunks) Get the maximum chunk Z coordinate covered by this tile (inclusive). -
centerBlockX
public double centerBlockX(int tileSizeChunks) Get the center block X coordinate of this tile. -
centerBlockZ
public double centerBlockZ(int tileSizeChunks) Get the center block Z coordinate of this tile. -
minBlockX
public double minBlockX(int tileSizeChunks) Get the minimum block X coordinate of this tile. -
minBlockZ
public double minBlockZ(int tileSizeChunks) Get the minimum block Z coordinate of this tile. -
offset
-
add
Add an offset to this tile coordinate.- Parameters:
dx- X offsetdz- Z offset- Returns:
- A new TileCoord with the offset applied
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
x
-
z
-