summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-08-26 14:08:37 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-08-27 18:32:48 +0200
commitc98a2d9acfdf4350479b925f216a1b1fb49688f6 (patch)
tree54b74265f680dae0031cf2da4b83068d7cc3dbbd /src/World.cpp
parentAdded a "reloadweb" command for reloading web admin config. (diff)
downloadcuberite-c98a2d9acfdf4350479b925f216a1b1fb49688f6.tar
cuberite-c98a2d9acfdf4350479b925f216a1b1fb49688f6.tar.gz
cuberite-c98a2d9acfdf4350479b925f216a1b1fb49688f6.tar.bz2
cuberite-c98a2d9acfdf4350479b925f216a1b1fb49688f6.tar.lz
cuberite-c98a2d9acfdf4350479b925f216a1b1fb49688f6.tar.xz
cuberite-c98a2d9acfdf4350479b925f216a1b1fb49688f6.tar.zst
cuberite-c98a2d9acfdf4350479b925f216a1b1fb49688f6.zip
Diffstat (limited to '')
-rw-r--r--src/World.cpp62
1 files changed, 32 insertions, 30 deletions
diff --git a/src/World.cpp b/src/World.cpp
index aca640091..721624790 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1599,17 +1599,17 @@ bool cWorld::DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
-bool cWorld::GrowTree(int a_X, int a_Y, int a_Z)
+bool cWorld::GrowTree(const Vector3i a_BlockPos)
{
- if (GetBlock(a_X, a_Y, a_Z) == E_BLOCK_SAPLING)
+ if (GetBlock(a_BlockPos) == E_BLOCK_SAPLING)
{
// There is a sapling here, grow a tree according to its type:
- return GrowTreeFromSapling(a_X, a_Y, a_Z, GetBlockMeta(a_X, a_Y, a_Z));
+ return GrowTreeFromSapling(a_BlockPos);
}
else
{
// There is nothing here, grow a tree based on the current biome here:
- return GrowTreeByBiome(a_X, a_Y, a_Z);
+ return GrowTreeByBiome(a_BlockPos);
}
}
@@ -1617,36 +1617,37 @@ bool cWorld::GrowTree(int a_X, int a_Y, int a_Z)
-bool cWorld::GrowTreeFromSapling(int a_X, int a_Y, int a_Z, NIBBLETYPE a_SaplingMeta)
+bool cWorld::GrowTreeFromSapling(Vector3i a_BlockPos)
{
cNoise Noise(m_Generator.GetSeed());
sSetBlockVector Logs, Other;
auto WorldAge = static_cast<int>(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count() & 0xffffffff);
- switch (a_SaplingMeta & 0x07)
+ auto SaplingMeta = GetBlockMeta(a_BlockPos);
+ switch (SaplingMeta & 0x07)
{
- case E_META_SAPLING_APPLE: GetAppleTreeImage ({ a_X, a_Y, a_Z }, Noise, WorldAge, Logs, Other); break;
- case E_META_SAPLING_BIRCH: GetBirchTreeImage ({ a_X, a_Y, a_Z }, Noise, WorldAge, Logs, Other); break;
+ case E_META_SAPLING_APPLE: GetAppleTreeImage (a_BlockPos, Noise, WorldAge, Logs, Other); break;
+ case E_META_SAPLING_BIRCH: GetBirchTreeImage (a_BlockPos, Noise, WorldAge, Logs, Other); break;
case E_META_SAPLING_CONIFER:
{
- bool IsLarge = GetLargeTreeAdjustment(a_X, a_Y, a_Z, a_SaplingMeta);
- GetConiferTreeImage({ a_X, a_Y, a_Z }, Noise, WorldAge, Logs, Other, IsLarge);
+ bool IsLarge = GetLargeTreeAdjustment(a_BlockPos, SaplingMeta);
+ GetConiferTreeImage(a_BlockPos, Noise, WorldAge, Logs, Other, IsLarge);
break;
}
- case E_META_SAPLING_ACACIA: GetAcaciaTreeImage ({ a_X, a_Y, a_Z }, Noise, WorldAge, Logs, Other); break;
+ case E_META_SAPLING_ACACIA: GetAcaciaTreeImage (a_BlockPos, Noise, WorldAge, Logs, Other); break;
case E_META_SAPLING_JUNGLE:
{
- bool IsLarge = GetLargeTreeAdjustment(a_X, a_Y, a_Z, a_SaplingMeta);
- GetJungleTreeImage({ a_X, a_Y, a_Z }, Noise, WorldAge, Logs, Other, IsLarge);
+ bool IsLarge = GetLargeTreeAdjustment(a_BlockPos, SaplingMeta);
+ GetJungleTreeImage(a_BlockPos, Noise, WorldAge, Logs, Other, IsLarge);
break;
}
case E_META_SAPLING_DARK_OAK:
{
- if (!GetLargeTreeAdjustment(a_X, a_Y, a_Z, a_SaplingMeta))
+ if (!GetLargeTreeAdjustment(a_BlockPos, SaplingMeta))
{
return false;
}
- GetDarkoakTreeImage({ a_X, a_Y, a_Z }, Noise, WorldAge, Logs, Other);
+ GetDarkoakTreeImage(a_BlockPos, Noise, WorldAge, Logs, Other);
break;
}
}
@@ -1659,7 +1660,7 @@ bool cWorld::GrowTreeFromSapling(int a_X, int a_Y, int a_Z, NIBBLETYPE a_Sapling
-bool cWorld::GetLargeTreeAdjustment(int & a_X, int & a_Y, int & a_Z, NIBBLETYPE a_Meta)
+bool cWorld::GetLargeTreeAdjustment(Vector3i & a_BlockPos, NIBBLETYPE a_Meta)
{
bool IsLarge = true;
a_Meta = a_Meta & 0x07;
@@ -1671,8 +1672,8 @@ bool cWorld::GetLargeTreeAdjustment(int & a_X, int & a_Y, int & a_Z, NIBBLETYPE
{
NIBBLETYPE meta;
BLOCKTYPE type;
- GetBlockTypeMeta(a_X + x, a_Y, a_Z + z, type, meta);
- IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+ GetBlockTypeMeta(a_BlockPos.addedXZ(x, z), type, meta);
+ IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((meta & 0x07) == a_Meta);
}
}
@@ -1689,14 +1690,14 @@ bool cWorld::GetLargeTreeAdjustment(int & a_X, int & a_Y, int & a_Z, NIBBLETYPE
{
NIBBLETYPE meta;
BLOCKTYPE type;
- GetBlockTypeMeta(a_X + x, a_Y, a_Z + z, type, meta);
- IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+ GetBlockTypeMeta(a_BlockPos.addedXZ(x, z), type, meta);
+ IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((meta & 0x07) == a_Meta);
}
}
if (IsLarge)
{
- --a_Z;
+ --a_BlockPos.z;
return true;
}
@@ -1708,15 +1709,15 @@ bool cWorld::GetLargeTreeAdjustment(int & a_X, int & a_Y, int & a_Z, NIBBLETYPE
{
NIBBLETYPE meta;
BLOCKTYPE type;
- GetBlockTypeMeta(a_X + x, a_Y, a_Z + z, type, meta);
- IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+ GetBlockTypeMeta(a_BlockPos.addedXZ(x, z), type, meta);
+ IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((meta & 0x07) == a_Meta);
}
}
if (IsLarge)
{
- --a_Z;
- --a_X;
+ --a_BlockPos.x;
+ --a_BlockPos.z;
return true;
}
@@ -1728,14 +1729,14 @@ bool cWorld::GetLargeTreeAdjustment(int & a_X, int & a_Y, int & a_Z, NIBBLETYPE
{
NIBBLETYPE meta;
BLOCKTYPE type;
- GetBlockTypeMeta(a_X + x, a_Y, a_Z + z, type, meta);
- IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((a_Meta & meta) == a_Meta);
+ GetBlockTypeMeta(a_BlockPos.addedXZ(x, z), type, meta);
+ IsLarge = IsLarge && (type == E_BLOCK_SAPLING) && ((meta & 0x07) == a_Meta);
}
}
if (IsLarge)
{
- --a_X;
+ --a_BlockPos.x;
}
return IsLarge;
@@ -1745,11 +1746,12 @@ bool cWorld::GetLargeTreeAdjustment(int & a_X, int & a_Y, int & a_Z, NIBBLETYPE
-bool cWorld::GrowTreeByBiome(int a_X, int a_Y, int a_Z)
+bool cWorld::GrowTreeByBiome(const Vector3i a_BlockPos)
{
cNoise Noise(m_Generator.GetSeed());
sSetBlockVector Logs, Other;
- GetTreeImageByBiome({ a_X, a_Y, a_Z }, Noise, static_cast<int>(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count() & 0xffffffff), GetBiomeAt(a_X, a_Z), Logs, Other);
+ auto seq = static_cast<int>(std::chrono::duration_cast<cTickTimeLong>(m_WorldAge).count() & 0xffffffff);
+ GetTreeImageByBiome(a_BlockPos, Noise, seq, GetBiomeAt(a_BlockPos.x, a_BlockPos.z), Logs, Other);
Other.insert(Other.begin(), Logs.begin(), Logs.end());
Logs.clear();
return GrowTreeImage(Other);