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
This commit is contained in:
eh-K
2026-03-09 22:07:38 -05:00
committed by GitHub
parent 91ae76f132
commit c998346312

View File

@@ -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) 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; if( !force )
while (((t = level->getTile(x, y, z)) == 0 || t == Tile::leaves_Id) && y > 1) {
int t = 0;
while (((t = level->getTile(x, y, z)) == 0 || t == Tile::leaves_Id) && y > 1)
y--; y--;
if (y < 1) if (y < 1)
{ {
return false; return false;
}
y++;
} }
y++;
}
for (int i = 0; i < 4; i++) 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; return false;
}
} }