Fixed Leaves dropping wrong saplings

This commit is contained in:
Lord Cambion
2026-03-18 12:29:48 +01:00
parent cad14c2a43
commit 5180196d9b
4 changed files with 40 additions and 4 deletions
+35
View File
@@ -98,4 +98,39 @@ void LeafTile2::playerDestroy(Level *level, shared_ptr<Player> player, int x, in
// Altrimenti usa la distruzione standard di TransparentTile
TransparentTile::playerDestroy(level, player, x, y, z, data);
}
}
void LeafTile2::spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonusLevel)
{
if (!level->isClientSide)
{
int chance = 20;
if (playerBonusLevel > 0)
{
chance -= 2 << playerBonusLevel;
if (chance < 10) chance = 10;
}
if (level->random->nextInt(chance) == 0)
{
popResource(level, x, y, z, std::make_shared<ItemInstance>(Tile::sapling2_Id, 1, data & 3));
}
if ((data & 3) == 1)
{
int appleChance = 200;
if (playerBonusLevel > 0)
{
appleChance -= 10 << playerBonusLevel;
if (appleChance < 40) appleChance = 40;
}
if (level->random->nextInt(appleChance) == 0)
{
popResource(level, x, y, z, std::make_shared<ItemInstance>(Item::apple_Id, 1, 0));
}
}
}
}