From 8445534dc1efe323ec9381e2599c07432748d4e4 Mon Sep 17 00:00:00 2001 From: "George V." Date: Mon, 6 Apr 2026 16:35:42 +0300 Subject: [PATCH] fix(fishing): fix catch type return and correct aux value calculations - Add missing return of CatchType in getRandCatchType - Remove unused variable in getRandCatch - Fix duplicate semicolon in TREASURE case - Fix missing parentheses in fishing rod and bow calculations in handleCatch --- Minecraft.World/FishingHelper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Minecraft.World/FishingHelper.cpp b/Minecraft.World/FishingHelper.cpp index b9903c9b..dfa34b77 100644 --- a/Minecraft.World/FishingHelper.cpp +++ b/Minecraft.World/FishingHelper.cpp @@ -50,16 +50,16 @@ CatchType FishingHelper::getRandCatchType(int luck, Random* random) CatchTypeWeighedItem* catchTypeWeighedItem = nullptr; catchTypeArray.calcWeights(luck); // Recalculate the weights based on the luck level of the player catchTypeWeighedItem = static_cast(WeighedRandom::getRandomItem(random, catchTypeArray)); + return catchTypeWeighedItem->getType(); } CatchWeighedItem* FishingHelper::getRandCatch(CatchType catchType, Random* random) { - CatchWeighedItem* catchWeighedItem = nullptr; switch (catchType) { case CatchType::FISH: return static_cast(WeighedRandom::getRandomItem(random, fishingFishArray)); case CatchType::TREASURE: - return static_cast(WeighedRandom::getRandomItem(random, fishingTreasuresArray));; + return static_cast(WeighedRandom::getRandomItem(random, fishingTreasuresArray)); case CatchType::JUNK: return static_cast(WeighedRandom::getRandomItem(random, fishingJunkArray)); } @@ -75,11 +75,11 @@ std::shared_ptr FishingHelper::handleCatch(CatchWeighedItem* weigh itemInstance->setAuxValue((int) (itemInstance->getMaxDamage() * ((double) random->nextInt(901) + 100.0) / 1000.0)); // 10% to 100% damage } else if (itemInstance->id == Item::fishingRod_Id && catchType == CatchType::TREASURE) { - itemInstance->setAuxValue((int)(itemInstance->getMaxDamage() * ((double)random->nextInt(251) / 1000.0)); // 0% to 25% damage + itemInstance->setAuxValue((int)(itemInstance->getMaxDamage() * ((double)random->nextInt(251) / 1000.0))); // 0% to 25% damage itemInstance = EnchantmentHelper::enchantItem(random, itemInstance, 30); } else if (itemInstance->id == Item::bow_Id) { - itemInstance->setAuxValue((int)(itemInstance->getMaxDamage() * ((double)random->nextInt(251) / 1000.0)); // 0% to 25% damage + itemInstance->setAuxValue((int)(itemInstance->getMaxDamage() * ((double)random->nextInt(251) / 1000.0))); // 0% to 25% damage itemInstance = EnchantmentHelper::enchantItem(random, itemInstance, 30); } else if (itemInstance->id == Item::book_Id) {