summaryrefslogtreecommitdiffstats
path: root/src/BlockArea.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-04-29 15:14:22 +0200
committerMattes D <github@xoft.cz>2015-04-29 15:14:22 +0200
commitfc95501f68b28f2fc595eb574546500c2713ef96 (patch)
tree4201e7e773b152aea800f1024bc0ea4bca28eeda /src/BlockArea.cpp
parentFix explosions trying to write to unread blockarea (diff)
downloadcuberite-fc95501f68b28f2fc595eb574546500c2713ef96.tar
cuberite-fc95501f68b28f2fc595eb574546500c2713ef96.tar.gz
cuberite-fc95501f68b28f2fc595eb574546500c2713ef96.tar.bz2
cuberite-fc95501f68b28f2fc595eb574546500c2713ef96.tar.lz
cuberite-fc95501f68b28f2fc595eb574546500c2713ef96.tar.xz
cuberite-fc95501f68b28f2fc595eb574546500c2713ef96.tar.zst
cuberite-fc95501f68b28f2fc595eb574546500c2713ef96.zip
Diffstat (limited to '')
-rw-r--r--src/BlockArea.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 4c3da0535..7526e1c32 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -1614,6 +1614,73 @@ void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTY
+void cBlockArea::GetNonAirCropRelCoords(int & a_MinRelX, int & a_MinRelY, int & a_MinRelZ, int & a_MaxRelX, int & a_MaxRelY, int & a_MaxRelZ, BLOCKTYPE a_IgnoreBlockType)
+{
+ // Check if blocktypes are valid:
+ if (m_BlockTypes == nullptr)
+ {
+ LOGWARNING("%s: BlockTypes have not been read!", __FUNCTION__);
+ a_MinRelX = 1;
+ a_MaxRelX = 0;
+ return;
+ }
+
+ // Walk all the blocks and find the min and max coords for the non-ignored ones:
+ int MaxX = 0, MinX = m_Size.x - 1;
+ int MaxY = 0, MinY = m_Size.y - 1;
+ int MaxZ = 0, MinZ = m_Size.z - 1;
+ for (int y = 0; y < m_Size.y; y++)
+ {
+ for (int z = 0; z < m_Size.z; z++)
+ {
+ for (int x = 0; x < m_Size.x; x++)
+ {
+ if (m_BlockTypes[MakeIndex(x, y, z)] == a_IgnoreBlockType)
+ {
+ continue;
+ }
+ // The block is not ignored, update any coords that need updating:
+ if (x < MinX)
+ {
+ MinX = x;
+ }
+ if (x > MaxX)
+ {
+ MaxX = x;
+ }
+ if (y < MinY)
+ {
+ MinY = y;
+ }
+ if (y > MaxY)
+ {
+ MaxY = y;
+ }
+ if (z < MinZ)
+ {
+ MinZ = z;
+ }
+ if (z > MaxZ)
+ {
+ MaxZ = z;
+ }
+ } // for x
+ } // for z
+ } // for y
+
+ // Assign to the output:
+ a_MinRelX = MinX;
+ a_MinRelY = MinY;
+ a_MinRelZ = MinZ;
+ a_MaxRelX = MaxX;
+ a_MaxRelY = MaxY;
+ a_MaxRelZ = MaxZ;
+}
+
+
+
+
+
int cBlockArea::GetDataTypes(void) const
{
int res = 0;