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

View file

@ -100,7 +100,7 @@ void LeafTile::onRemove(Level *level, int x, int y, int z, int id, int data)
for (int zo = -r; zo <= r; zo++)
{
int t = level->getTile(x + xo, y + yo, z + zo);
if (t == Tile::leaves_Id)
if (t == Tile::leaves_Id|| t == Tile::leaves2_Id)
{
int currentData = level->getData(x + xo, y + yo, z + zo);
level->setData(x + xo, y + yo, z + zo, currentData | UPDATE_LEAF_BIT, Tile::UPDATE_NONE);
@ -137,11 +137,11 @@ void LeafTile::tick(Level *level, int x, int y, int z, Random *random)
for (int yo = -r; yo <= r; yo++)
{
int t = level->getTile(x + xo, y + yo, z + zo);
if (t == Tile::treeTrunk_Id)
if (t == (Tile::treeTrunk_Id||Tile::tree2Trunk_Id))
{
checkBuffer[(xo + WO) * WW + (yo + WO) * W + (zo + WO)] = 0;
}
else if (t == Tile::leaves_Id)
else if (t == (Tile::leaves_Id||Tile::leaves2_Id))
{
checkBuffer[(xo + WO) * WW + (yo + WO) * W + (zo + WO)] = -2;
}

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));
}
}
}
}

View file

@ -23,6 +23,7 @@ public:
virtual Icon *getTexture(int face, int data);
virtual unsigned int getDescriptionId(int iData = -1);
virtual void registerIcons(IconRegister *iconRegister);
virtual void spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonusLevel) override;
virtual int getColor(int data);

View file

@ -39,7 +39,7 @@ void TreeTile2::onRemove(Level* level, int x, int y, int z, int id, int data)
for (int zo = -r; zo <= r; zo++)
{
int t = level->getTile(x + xo, y + yo, z + zo);
if (t == Tile::leaves_Id)
if (t == (Tile::leaves_Id||Tile::leaves2_Id))
{
int currentData = level->getData(x + xo, y + yo, z + zo);
if ((currentData & LeafTile::UPDATE_LEAF_BIT) == 0)