Coordinate Classes
Package: thaumcraft.api
Author: Azanor
Thaumcraft provides two coordinate classes for different use cases: WorldCoordinates (dimension-aware) and BlockCoordinates (dimension-agnostic).
WorldCoordinates
File: WorldCoordinates.java
Implements: Comparable
Dimension-aware coordinate class that includes a dimension ID. Used when the specific dimension matters for the coordinate.
Fields
| Field | Type | Description |
|---|---|---|
x |
int |
X coordinate |
y |
int |
Y coordinate |
z |
int |
Z coordinate |
dim |
int |
Dimension ID |
Constructors
| Signature | Description |
|---|---|
WorldCoordinates() |
Empty constructor |
WorldCoordinates(int x, int y, int z, int dim) |
Direct construction |
WorldCoordinates(TileEntity tile) |
From tile entity (reads position and dimension) |
WorldCoordinates(WorldCoordinates other) |
Copy constructor |
Methods
| Method | Signature | Description |
|---|---|---|
equals |
Object par1Obj → boolean |
Compares coordinates and dimension |
hashCode |
→ int |
Hash based on x, y, z, and dim |
compareWorldCoordinate |
WorldCoordinates par1 → int |
Compares coordinates |
set |
int x, int y, int z, int dim → void |
Sets coordinate values |
getDistanceSquared |
int x, int y, int z → float |
Squared distance to point |
getDistanceSquaredToWorldCoordinates |
WorldCoordinates → float |
Squared distance to other coordinate |
compareTo |
Object par1Obj → int |
Comparable implementation |
readNBT |
NBTTagCompound nbt → void |
Reads from NBT |
writeNBT |
NBTTagCompound nbt → void |
Writes to NBT |
BlockCoordinates
File: BlockCoordinates.java
Implements: Comparable
Dimension-agnostic coordinate class used for architect tools and block highlighting. Does not store dimension information.
Fields
| Field | Type | Description |
|---|---|---|
x |
int |
X coordinate |
y |
int |
Y coordinate |
z |
int |
Z coordinate |
Constructors
| Signature | Description |
|---|---|
BlockCoordinates() |
Empty constructor |
BlockCoordinates(int x, int y, int z) |
Direct construction |
BlockCoordinates(TileEntity tile) |
From tile entity |
BlockCoordinates(BlockCoordinates other) |
Copy constructor |
Methods
| Method | Signature | Description |
|---|---|---|
equals |
Object par1Obj → boolean |
Compares coordinates |
hashCode |
→ int |
Hash based on x, y, and z |
compareWorldCoordinate |
BlockCoordinates par1 → int |
Compares coordinates (Y > Z > X priority) |
set |
int x, int y, int z, int d → void |
Sets x/y/z |
⚠️ 已订正(mod 源码缺陷):
BlockCoordinates.set的真实签名是set(int par1, int par2, int par3, int d)——4 个参数(证据:BlockCoordinates.java:66), 而不是原条目写的 3 参数。 但类中没有dim字段(BlockCoordinates.java:9/12/15只有x/y/z), 方法体也从不使用第 4 个参数d(BlockCoordinates.java:66-70)。 即:这是一个上游遗留的死参数,调用方必须传一个被忽略的值。 对照WorldCoordinates.set(int, int, int, int d)(WorldCoordinates.java:71-77)——那边 4 个参数全部有效。 |getDistanceSquared|int x, int y, int z→float| Squared distance to point | |getDistanceSquaredToWorldCoordinates|BlockCoordinates→float| Squared distance to other coordinate | |compareTo|Object par1Obj→int| Comparable implementation | |readNBT|NBTTagCompound nbt→void| Reads from NBT | |writeNBT|NBTTagCompound nbt→void| Writes to NBT |
Comparison
| Feature | WorldCoordinates | BlockCoordinates |
|---|---|---|
| Dimension-aware | Yes | No |
| Use case | General world operations | Architect tool highlighting |
| NBT serialization | Supported | Supported |
Usage with IArchitect
The IArchitect interface uses BlockCoordinates for returning blocks to highlight:
public ArrayList<BlockCoordinates> getArchitectBlocks(ItemStack stack, World world,
int x, int y, int z, int side, EntityPlayer player);
Tags
#api #coordinates #world #blocks