aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreh-K <165239265+eh-K@users.noreply.github.com>2026-03-09 22:07:38 -0500
committerGitHub <noreply@github.com>2026-03-09 22:07:38 -0500
commitc998346312c753fa4359804c2c1823e23bce5b91 (patch)
tree0309a5ecf2202ccdb9d2e8cfba28a7a4e32dda28
parent91ae76f132678b010dabd30dbd87abf2087dd929 (diff)
FIX: Bonus Chests spawn again when loading back in. #982 (#992)
* Fixed bug where Bonus Chests would spawn again when loading back into it. Fixes #982 Added a check for if the world is new. Meaning no more additional chests if the world is loaded up again. * Replace NULL with nullptr for chest check
-rw-r--r--Minecraft.World/BonusChestFeature.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/Minecraft.World/BonusChestFeature.cpp b/Minecraft.World/BonusChestFeature.cpp
index cd33e60a..86dc9725 100644
--- a/Minecraft.World/BonusChestFeature.cpp
+++ b/Minecraft.World/BonusChestFeature.cpp
@@ -24,18 +24,21 @@ bool BonusChestFeature::place(Level *level, Random *random, int x, int y, int z)
bool BonusChestFeature::place(Level *level, Random *random, int x, int y, int z, bool force)
{
- if( !force )
+ //Will only spawn a bonus chest if the world is new and has never been saved.
+ if (level->isNew)
{
- int t = 0;
- while (((t = level->getTile(x, y, z)) == 0 || t == Tile::leaves_Id) && y > 1)
+ if( !force )
+ {
+ int t = 0;
+ while (((t = level->getTile(x, y, z)) == 0 || t == Tile::leaves_Id) && y > 1)
y--;
- if (y < 1)
- {
- return false;
+ if (y < 1)
+ {
+ return false;
+ }
+ y++;
}
- y++;
- }
for (int i = 0; i < 4; i++)
{
@@ -85,4 +88,6 @@ bool BonusChestFeature::place(Level *level, Random *random, int x, int y, int z,
}
return false;
+
+ }
}