From 433bd530f38b78bb7e276acafef40fec47d43267 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 12 Apr 2014 00:35:13 +0200 Subject: Some tweaks GetPyramidLevel returns 0 when no layers were found, 1 for one layer etc. Auto adjust the minY and/or maxY to 0 if the beacon is low. --- src/BlockEntities/BeaconEntity.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index 65fda827c..dd340f24f 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -20,14 +20,26 @@ cBeaconEntity::cBeaconEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * int cBeaconEntity::GetPyramidLevel() { cBlockArea Area; + int MinY = GetPosY() - 4; + if (MinY < 0) + { + MinY = 0; + } + int MaxY = GetPosY() - 1; + if (MaxY < 0) + { + MaxY = 0; + } + Area.Read( m_World, GetPosX() - 4, GetPosX() + 4, - GetPosY() - 5, - GetPosY() - 1, + MinY, + MaxY, GetPosZ() - 4, - GetPosZ() + 4 + GetPosZ() + 4, + cBlockArea::baTypes ); int Layer = 1; @@ -41,14 +53,14 @@ int cBeaconEntity::GetPyramidLevel() { if (!IsMineralBlock(Area.GetRelBlockType(X, Y, Z))) { - return Layer; + return Layer - 1; } } } Layer++; } - return Layer; + return Layer - 1; } -- cgit v1.2.3