summaryrefslogtreecommitdiffstats
path: root/src/ChunkDef.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-04-26 01:38:41 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-06-06 13:21:19 +0200
commit84534dfeb288dd12d998f3f192ee162a1def5367 (patch)
treea8debc1723cafc6066d46edfc02888218ba7cb4d /src/ChunkDef.h
parentProvides improvements to redstone wire (diff)
downloadcuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar
cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.gz
cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.bz2
cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.lz
cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.xz
cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.tar.zst
cuberite-84534dfeb288dd12d998f3f192ee162a1def5367.zip
Diffstat (limited to '')
-rw-r--r--src/ChunkDef.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index fb3451db1..a1273bd23 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -96,6 +96,19 @@ public:
a_Z = a_Z - a_ChunkZ * Width;
}
+ inline static Vector3i AbsoluteToRelative(Vector3i a_BlockPosition)
+ {
+ int ChunkX, ChunkZ;
+ BlockToChunk(a_BlockPosition.x, a_BlockPosition.z, ChunkX, ChunkZ);
+
+ return {a_BlockPosition.x - ChunkX * Width, a_BlockPosition.y, a_BlockPosition.z - ChunkZ * Width};
+ }
+
+ inline static Vector3i AbsoluteToRelative(Vector3i a_BlockPosition, int a_ChunkX, int a_ChunkZ)
+ {
+ return {a_BlockPosition.x - a_ChunkX * Width, a_BlockPosition.y, a_BlockPosition.z - a_ChunkZ * Width};
+ }
+
/** Converts relative block coordinates into absolute coordinates with a known chunk location */
inline static Vector3i RelativeToAbsolute(const Vector3i & a_RelBlockPosition, int a_ChunkX, int a_ChunkZ)
{