From 5180196d9bc2ff2eec090716aa7821fb6aca5676 Mon Sep 17 00:00:00 2001 From: Lord Cambion Date: Wed, 18 Mar 2026 12:29:48 +0100 Subject: [PATCH] Fixed Leaves dropping wrong saplings --- Minecraft.World/LeafTile.cpp | 6 +++--- Minecraft.World/LeafTile2.cpp | 35 +++++++++++++++++++++++++++++++++++ Minecraft.World/LeafTile2.h | 1 + Minecraft.World/TreeTile2.cpp | 2 +- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/Minecraft.World/LeafTile.cpp b/Minecraft.World/LeafTile.cpp index f8f5deae..1384e7e9 100644 --- a/Minecraft.World/LeafTile.cpp +++ b/Minecraft.World/LeafTile.cpp @@ -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; } diff --git a/Minecraft.World/LeafTile2.cpp b/Minecraft.World/LeafTile2.cpp index 5a38a6d5..b9590e1c 100644 --- a/Minecraft.World/LeafTile2.cpp +++ b/Minecraft.World/LeafTile2.cpp @@ -98,4 +98,39 @@ void LeafTile2::playerDestroy(Level *level, shared_ptr 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(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(Item::apple_Id, 1, 0)); + } + } + } } \ No newline at end of file diff --git a/Minecraft.World/LeafTile2.h b/Minecraft.World/LeafTile2.h index 9f771e7b..59166c46 100644 --- a/Minecraft.World/LeafTile2.h +++ b/Minecraft.World/LeafTile2.h @@ -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); diff --git a/Minecraft.World/TreeTile2.cpp b/Minecraft.World/TreeTile2.cpp index 24f27081..75da0712 100644 --- a/Minecraft.World/TreeTile2.cpp +++ b/Minecraft.World/TreeTile2.cpp @@ -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)