diff options
author | Mattes D <github@xoft.cz> | 2019-09-29 14:59:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-29 14:59:24 +0200 |
commit | 365cbc6e1cea96741e26c9ce912b003f8fd2c62c (patch) | |
tree | f23682c47928597791c53f3a300b03494ffde417 /src/ChunkDef.h | |
parent | Cactus can now grow and will be dropped if there is no place to grow. (diff) | |
download | cuberite-365cbc6e1cea96741e26c9ce912b003f8fd2c62c.tar cuberite-365cbc6e1cea96741e26c9ce912b003f8fd2c62c.tar.gz cuberite-365cbc6e1cea96741e26c9ce912b003f8fd2c62c.tar.bz2 cuberite-365cbc6e1cea96741e26c9ce912b003f8fd2c62c.tar.lz cuberite-365cbc6e1cea96741e26c9ce912b003f8fd2c62c.tar.xz cuberite-365cbc6e1cea96741e26c9ce912b003f8fd2c62c.tar.zst cuberite-365cbc6e1cea96741e26c9ce912b003f8fd2c62c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ChunkDef.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 425e829a5..f3621c787 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -245,6 +245,14 @@ public: } + + inline static int MakeIndexNoCheck(Vector3i a_RelPos) + { + return MakeIndexNoCheck(a_RelPos.x, a_RelPos.y, a_RelPos.z); + } + + + inline static Vector3i IndexToCoordinate(size_t index) { #if AXIS_ORDER == AXIS_ORDER_XZY @@ -279,6 +287,13 @@ public: } + inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, Vector3i a_RelPos) + { + ASSERT(IsValidRelPos(a_RelPos)); + return a_BlockTypes[MakeIndexNoCheck(a_RelPos)]; + } + + inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_X, int a_Y, int a_Z) { ASSERT((a_X >= 0) && (a_X < Width)); @@ -358,6 +373,18 @@ public: } + static NIBBLETYPE GetNibble(const NIBBLETYPE * a_Buffer, Vector3i a_RelPos) + { + if (IsValidRelPos(a_RelPos)) + { + auto Index = MakeIndexNoCheck(a_RelPos); + return (a_Buffer[static_cast<size_t>(Index / 2)] >> ((Index & 1) * 4)) & 0x0f; + } + ASSERT(!"Coords out of chunk range!"); + return 0; + } + + static NIBBLETYPE GetNibble(const NIBBLETYPE * a_Buffer, int x, int y, int z) { if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1)) |