summaryrefslogtreecommitdiffstats
path: root/src/BlockArea.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-04-30 23:16:33 +0200
committerMattes D <github@xoft.cz>2015-04-30 23:16:33 +0200
commita3c4b7580b1f5e0ac6aa74ba8c702359d32eda27 (patch)
treebcb6ff9fc661b0fc1d8ad492f12c874227b4d949 /src/BlockArea.cpp
parentMerge pull request #1923 from mc-server/ReadWholeFileFix (diff)
downloadcuberite-a3c4b7580b1f5e0ac6aa74ba8c702359d32eda27.tar
cuberite-a3c4b7580b1f5e0ac6aa74ba8c702359d32eda27.tar.gz
cuberite-a3c4b7580b1f5e0ac6aa74ba8c702359d32eda27.tar.bz2
cuberite-a3c4b7580b1f5e0ac6aa74ba8c702359d32eda27.tar.lz
cuberite-a3c4b7580b1f5e0ac6aa74ba8c702359d32eda27.tar.xz
cuberite-a3c4b7580b1f5e0ac6aa74ba8c702359d32eda27.tar.zst
cuberite-a3c4b7580b1f5e0ac6aa74ba8c702359d32eda27.zip
Diffstat (limited to '')
-rw-r--r--src/BlockArea.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 600940d96..89cf18d4a 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -1634,6 +1634,37 @@ void cBlockArea::GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTY
+size_t cBlockArea::CountNonAirBlocks(void) const
+{
+ // Check if blocktypes are valid:
+ if (m_BlockTypes == nullptr)
+ {
+ LOGWARNING("%s: BlockTypes have not been read!", __FUNCTION__);
+ return 0;
+ }
+
+ // Count the blocks:
+ size_t res = 0;
+ 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)] != E_BLOCK_AIR)
+ {
+ ++res;
+ }
+ } // for x
+ } // for z
+ } // for y
+ return res;
+}
+
+
+
+
+
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: