diff --git a/Minecraft.Client/Common/Media/MediaWindows64.arc b/Minecraft.Client/Common/Media/MediaWindows64.arc index 4fa07d73..e3e0f778 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64.arc and b/Minecraft.Client/Common/Media/MediaWindows64.arc differ diff --git a/Minecraft.Client/Common/Media/languages.loc b/Minecraft.Client/Common/Media/languages.loc index 3fb5b1a0..f65559b2 100644 Binary files a/Minecraft.Client/Common/Media/languages.loc and b/Minecraft.Client/Common/Media/languages.loc differ diff --git a/Minecraft.Client/Windows64Media/strings.h b/Minecraft.Client/Windows64Media/strings.h index 8132d984..1ed1b4be 100644 --- a/Minecraft.Client/Windows64Media/strings.h +++ b/Minecraft.Client/Windows64Media/strings.h @@ -1,7 +1,7 @@ #pragma once // Auto-generated by StringTable builder — do not edit manually. // Source language: en-US -// Total strings: 2339 +// Total strings: 2425 #define IDS_NULL 0 #define IDS_OK 1 @@ -2345,19 +2345,19 @@ #define IDS_TILE_PRISMARINE 2339 #define IDS_TILE_PRISMARINE_DARK 2340 #define IDS_TILE_PRISMARINE_BRICKS 2341 -#define IDS_ITEM_PRISMARINE_SHARD 2342 -#define IDS_ITEM_PRISMARINE_DESC 2343 -#define IDS_ITEM_PRISMARINE_DARK_DESC 2344 -#define IDS_ITEM_PRISMARINE_BRICK_DESC 2345 -#define IDS_ITEM_PRISMARINE_CRYSTAL_DESC 2346 -#define IDS_ITEM_PRISMARINE_SHARD_DESC 2347 +#define IDS_ITEM_PRISMARINE_SHARD 2342 +#define IDS_ITEM_PRISMARINE_DESC 2343 +#define IDS_ITEM_PRISMARINE_DARK_DESC 2344 +#define IDS_ITEM_PRISMARINE_BRICK_DESC 2345 +#define IDS_ITEM_PRISMARINE_CRYSTAL_DESC 2346 +#define IDS_ITEM_PRISMARINE_SHARD_DESC 2347 #define IDS_ITEM_RABBIT_STEW 2348 #define IDS_TILE_DOUBLE_TALL_GRASS 2349 #define IDS_TILE_LARGE_FERN 2350 #define IDS_TILE_LILAC 2351 #define IDS_TILE_ROSE_BUSH 2352 #define IDS_TILE_PEONY 2353 -#define IDS_TILE_PACKED_ICE 2354 +#define IDS_TILE_PACKED_ICE 2354 #define IDS_TILE_SUNFLOWER 2355 #define IDS_DESC_PACKED_ICE 2356 #define IDS_DESC_RED_SANDSTONE 2357 @@ -2416,13 +2416,15 @@ #define IDS_DESC_LARGE_FERN 2410 #define IDS_DESC_ROSE_BUSH 2411 #define IDS_DESC_PEONY 2412 -#define IDS_ENDERMITE 2413 -#define IDS_ITEM_WRITTENBOOK 2414 -#define IDS_DESC_WRITTENBOOK 2415 -#define IDS_ITEM_WRITINGBOOK 2416 -#define IDS_DESC_WRITINGBOOK 2417 +#define IDS_ENDERMITE 2413 +#define IDS_ITEM_WRITTENBOOK 2414 +#define IDS_DESC_WRITTENBOOK 2415 +#define IDS_ITEM_WRITINGBOOK 2416 +#define IDS_DESC_WRITINGBOOK 2417 #define IDS_TOOLTIPS_NEXTPAGE 2418 #define IDS_TOOLTIPS_BACKPAGE 2419 #define IDS_TOOLTIPS_ADDPAGE 2420 #define IDS_TITLE_EXITBOOK 2421 -#define IDS_DESC_EXITBOOK 2422 \ No newline at end of file +#define IDS_DESC_EXITBOOK 2422 +#define IDS_ENCHANTMENT_LURE 2423 +#define IDS_ENCHANTMENT_LUCK_OF_THE_SEA 2424 diff --git a/Minecraft.World/Enchantment.cpp b/Minecraft.World/Enchantment.cpp index c2f981a6..5d0743cc 100644 --- a/Minecraft.World/Enchantment.cpp +++ b/Minecraft.World/Enchantment.cpp @@ -3,6 +3,9 @@ #include "net.minecraft.world.item.h" #include "Enchantment.h" +#include "LuckOfTheSeaEnchantment.h" +#include "LureEnchantment.h" + //Enchantment *Enchantment::enchantments[256]; EnchantmentArray Enchantment::enchantments = EnchantmentArray( 256 ); vector Enchantment::validEnchantments; @@ -36,6 +39,10 @@ Enchantment *Enchantment::arrowKnockback = nullptr; Enchantment *Enchantment::arrowFire = nullptr; Enchantment *Enchantment::arrowInfinite = nullptr; +// fishing rod +Enchantment *Enchantment::lure = nullptr; +Enchantment *Enchantment::luckOfTheSea = nullptr; + void Enchantment::staticCtor() { allDamageProtection = new ProtectionEnchantment(0, FREQ_COMMON, ProtectionEnchantment::ALL); @@ -67,6 +74,10 @@ void Enchantment::staticCtor() arrowFire = new ArrowFireEnchantment(50, FREQ_RARE); arrowInfinite = new ArrowInfiniteEnchantment(51, FREQ_VERY_RARE); + // fishing rod + lure = new LureEnchantment(64, FREQ_RARE); + luckOfTheSea = new LuckOfTheSeaEnchantment(65, FREQ_RARE); + for(unsigned int i = 0; i < 256; ++i) { Enchantment *enchantment = enchantments[i]; diff --git a/Minecraft.World/Enchantment.h b/Minecraft.World/Enchantment.h index 7daa1a37..d7bbca58 100644 --- a/Minecraft.World/Enchantment.h +++ b/Minecraft.World/Enchantment.h @@ -47,6 +47,10 @@ public : static Enchantment *arrowFire; static Enchantment *arrowInfinite; + // fishing rod + static Enchantment *lure; + static Enchantment *luckOfTheSea; + const int id; static void staticCtor(); diff --git a/Minecraft.World/EnchantmentCategory.cpp b/Minecraft.World/EnchantmentCategory.cpp index b1c951ee..437c8e5d 100644 --- a/Minecraft.World/EnchantmentCategory.cpp +++ b/Minecraft.World/EnchantmentCategory.cpp @@ -11,6 +11,7 @@ const EnchantmentCategory *EnchantmentCategory::armor_head = new EnchantmentCate const EnchantmentCategory *EnchantmentCategory::weapon = new EnchantmentCategory(); const EnchantmentCategory *EnchantmentCategory::digger = new EnchantmentCategory(); const EnchantmentCategory *EnchantmentCategory::bow = new EnchantmentCategory(); +const EnchantmentCategory *EnchantmentCategory::fishing_rod = new EnchantmentCategory(); bool EnchantmentCategory::canEnchant(Item *item) const { @@ -38,5 +39,9 @@ bool EnchantmentCategory::canEnchant(Item *item) const { return this == bow; } + else if (dynamic_cast(item) != nullptr) + { + return this == fishing_rod; + } return false; } \ No newline at end of file diff --git a/Minecraft.World/EnchantmentCategory.h b/Minecraft.World/EnchantmentCategory.h index b5976307..aebf97bd 100644 --- a/Minecraft.World/EnchantmentCategory.h +++ b/Minecraft.World/EnchantmentCategory.h @@ -14,6 +14,7 @@ public: static const EnchantmentCategory *weapon; static const EnchantmentCategory *digger; static const EnchantmentCategory *bow; + static const EnchantmentCategory *fishing_rod; bool canEnchant(Item *item) const; }; \ No newline at end of file diff --git a/Minecraft.World/FishingHelper.cpp b/Minecraft.World/FishingHelper.cpp new file mode 100644 index 00000000..b9903c9b --- /dev/null +++ b/Minecraft.World/FishingHelper.cpp @@ -0,0 +1,97 @@ + +#include "../Minecraft.World/WeighedTreasure.h" +#include "../Minecraft.World/Biome.h" +#include "../Minecraft.World/FishingHelper.h" +#include "../Minecraft.World/ItemInstance.h" +#include "../Minecraft.World/EnchantmentHelper.h" +#include +#include "net.minecraft.world.item.h" + +FishingHelper* FishingHelper::getInstance() +{ + static FishingHelper instance; + return &instance; +} + +FishingHelper::FishingHelper() : catchTypeArray(3), fishingFishArray(4), fishingJunkArray(12), fishingTreasuresArray(5) +{ + // Source: https://github.com/WangTingZheng/mcp940/tree/master/src/minecraft/assets/minecraft/loot_tables/gameplay + catchTypeArray[0] = new CatchTypeWeighedItem(CatchType::JUNK, -2, 10 ); + catchTypeArray[1] = new CatchTypeWeighedItem(CatchType::TREASURE, 2, 5 ); + catchTypeArray[2] = new CatchTypeWeighedItem(CatchType::FISH, -1, 85); + + fishingTreasuresArray[0] = new CatchWeighedItem(Item::bow_Id, 1, 0, 1); + fishingTreasuresArray[1] = new CatchWeighedItem(Item::book_Id, 1, 0, 1); + fishingTreasuresArray[2] = new CatchWeighedItem(Item::fishingRod_Id, 1, 0, 1); + fishingTreasuresArray[3] = new CatchWeighedItem(Item::nameTag_Id, 1, 0, 1); + fishingTreasuresArray[4] = new CatchWeighedItem(Item::saddle_Id, 1, 0, 1); + fishingTreasuresArray[4] = new CatchWeighedItem(Tile::waterLily_Id, 1, 0, 1); + + fishingFishArray[0] = new CatchWeighedItem(Item::fish_raw_Id, 1, 0, 60); // Fish + fishingFishArray[1] = new CatchWeighedItem(Item::fish_raw_Id, 1, 1, 25); // Salmon + fishingFishArray[2] = new CatchWeighedItem(Item::fish_raw_Id, 1, 2, 2); // Clownfish + fishingFishArray[3] = new CatchWeighedItem(Item::fish_raw_Id, 1, 3, 13); // Pufferfish + + fishingJunkArray[3] = new CatchWeighedItem(Item::leather_Id, 1, 0, 10); + fishingJunkArray[1] = new CatchWeighedItem(Item::bone_Id, 1, 0, 10); + fishingJunkArray[6] = new CatchWeighedItem(Item::potion_Id, 1, 0, 10); // Water bottle + fishingJunkArray[2] = new CatchWeighedItem(Item::bowl_Id, 1, 0, 10); + fishingJunkArray[4] = new CatchWeighedItem(Item::boots_leather_Id, 1, 0, 10); + fishingJunkArray[5] = new CatchWeighedItem(Item::rotten_flesh_Id, 1, 0, 10); + fishingJunkArray[7] = new CatchWeighedItem(Tile::tripWireSource_Id, 1, 0, 10); + fishingJunkArray[8] = new CatchWeighedItem(Item::stick_Id, 1, 0, 5); + fishingJunkArray[9] = new CatchWeighedItem(Item::string_Id, 1, 0, 5); + fishingJunkArray[10] = new CatchWeighedItem(Item::fishingRod_Id, 1, 0, 2); + fishingJunkArray[11] = new CatchWeighedItem(Item::dye_powder_Id, 10, 0, 1); // 10 ink sacs +} + +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)); +} + +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));; + case CatchType::JUNK: + return static_cast(WeighedRandom::getRandomItem(random, fishingJunkArray)); + } +} + +std::shared_ptr FishingHelper::handleCatch(CatchWeighedItem* weighedCatch, CatchType catchType, Random* random) +{ + std::shared_ptr itemInstance = std::make_shared( + weighedCatch->getItemId(), weighedCatch->getCount(), weighedCatch->getAuxValue() + ); + + if ((itemInstance->id == Item::fishingRod_Id && catchType == CatchType::JUNK) || (itemInstance->id == Item::boots_leather_Id)) { + 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 = 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 = EnchantmentHelper::enchantItem(random, itemInstance, 30); + } + else if (itemInstance->id == Item::book_Id) { + itemInstance = EnchantmentHelper::enchantItem(random, itemInstance, 30); + } + + return itemInstance; +} + +std::shared_ptr FishingHelper::getCatch(int luck, Random* random) +{ + CatchType catchType = getRandCatchType(luck, random); + CatchWeighedItem* catchWeighedItem = getRandCatch(catchType, random); + return handleCatch(catchWeighedItem, catchType, random); +} \ No newline at end of file diff --git a/Minecraft.World/FishingHelper.h b/Minecraft.World/FishingHelper.h new file mode 100644 index 00000000..9a32b044 --- /dev/null +++ b/Minecraft.World/FishingHelper.h @@ -0,0 +1,102 @@ +#pragma once + +#include "../Minecraft.World/WeighedTreasure.h" +#include "../Minecraft.World/ItemInstance.h" +#include "net.minecraft.world.item.h" +#include +#include + +enum CatchType { + FISH, + TREASURE, + JUNK +}; + +class CatchTypeWeighedItem : public WeighedRandomItem { + protected: + CatchType type; + int quality; + int weight; + + public: + CatchTypeWeighedItem(CatchType type, int quality, int weight) : WeighedRandomItem(weight) + { + this->type = type; + this->quality = quality; + this->weight = weight; + } + + CatchType getType() + { + return type; + } + + void calcWeight(int luck) { + int newWeight = this->weight + this->quality * luck; + if (newWeight < 0) { + newWeight = 0; + } + this->randomWeight = newWeight; + } +}; + +class CatchTypeWeighedItems : public WeighedRandomItemArray { + public: + using WeighedRandomItemArray::WeighedRandomItemArray; + void calcWeights(int luck) { + for (unsigned int i = 0; i < this->length; i++) { + CatchTypeWeighedItem* catchTypeWeighedItem = static_cast(this->data[i]); + catchTypeWeighedItem->calcWeight(luck); + } + } +}; + +class CatchWeighedItem : public WeighedRandomItem { + protected: + int itemId; + int count; + int auxValue; + + public: + CatchWeighedItem(int itemId, int count, int auxValue, int weight) : WeighedRandomItem(weight) + { + this->itemId = itemId; + this->count = count; + this->auxValue = auxValue; + } + int getItemId() + { + return this->itemId; + } + int getCount() + { + return this->count; + } + int getAuxValue() + { + return this->auxValue; + } +}; + +class FishingHelper +{ + private: + FishingHelper(); + + CatchTypeWeighedItems catchTypeArray; + + WeighedRandomItemArray fishingFishArray; + WeighedRandomItemArray fishingJunkArray; + WeighedRandomItemArray fishingTreasuresArray; + public: + // Setup singleton + FishingHelper(const FishingHelper&) = delete; + FishingHelper& operator=(const FishingHelper&) = delete; + static FishingHelper* getInstance(); + std::shared_ptr getCatch(int luck, Random* random); + private: + CatchType getRandCatchType(int level, Random* random); + CatchWeighedItem* getRandCatch(CatchType catchType, Random* random); + std::shared_ptr handleCatch(CatchWeighedItem* weighedCatch, CatchType catchType, Random* random); + +}; \ No newline at end of file diff --git a/Minecraft.World/FishingHook.cpp b/Minecraft.World/FishingHook.cpp index ba0876d9..9ff420ef 100644 --- a/Minecraft.World/FishingHook.cpp +++ b/Minecraft.World/FishingHook.cpp @@ -11,8 +11,10 @@ #include "com.mojang.nbt.h" #include "FishingHook.h" #include "SoundTypes.h" - - +#include "../Minecraft.World/FishingHelper.h" +#include "../Minecraft.World/EnchantmentHelper.h" +#include "../Minecraft.World/Enchantment.h" +#include "../Minecraft.World/ItemInstance.h" // 4J - added common ctor code. void FishingHook::_init() @@ -29,6 +31,10 @@ void FishingHook::_init() shakeTime = 0; flightTime = 0; nibble = 0; + + // TU 31: Fishing rod now has a random nibble timer between 5 and 30 seconds, instead of a 1/500 chance every tick (plus modifiers). Source: https://minecraft.wiki/w/Fishing + nibbleTimer = random->nextInt(501) + 100; + lureTime = 0; hookedIn = nullptr; lSteps = 0; @@ -52,7 +58,7 @@ FishingHook::FishingHook(Level *level) : Entity( level ) _init(); } -FishingHook::FishingHook(Level *level, double x, double y, double z, shared_ptr owner) : Entity( level ) +FishingHook::FishingHook(Level *level, double x, double y, double z, std::shared_ptr owner) : Entity( level ) { _init(); @@ -63,7 +69,7 @@ FishingHook::FishingHook(Level *level, double x, double y, double z, shared_ptr< setPos(x, y, z); } -FishingHook::FishingHook(Level *level, shared_ptr mob) : Entity( level ) +FishingHook::FishingHook(Level *level, std::shared_ptr mob) : Entity( level ) { _init(); @@ -172,7 +178,7 @@ void FishingHook::tick() if (!level->isClientSide) { - shared_ptr selectedItem = owner->getSelectedItem(); + std::shared_ptr selectedItem = owner->getSelectedItem(); if (owner->removed || !owner->isAlive() || selectedItem == nullptr || selectedItem->getItem() != Item::fishingRod || distanceToSqr(owner) > 32 * 32) { remove(); @@ -230,12 +236,12 @@ void FishingHook::tick() { to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z); } - shared_ptr hitEntity = nullptr; - vector > *objects = level->getEntities(shared_from_this(), bb->expand(xd, yd, zd)->grow(1, 1, 1)); + std::shared_ptr hitEntity = nullptr; + vector< std::shared_ptr > *objects = level->getEntities(shared_from_this(), bb->expand(xd, yd, zd)->grow(1, 1, 1)); double nearest = 0; for (auto it = objects->begin(); it != objects->end(); it++) { - shared_ptr e = *it; // objects->at(i); + std::shared_ptr e = *it; // objects->at(i); if (!e->isPickable() || (e == owner && flightTime < 5)) continue; float rr = 0.3f; @@ -325,16 +331,48 @@ void FishingHook::tick() { if (nibble > 0) { + nibble--; } else - { - int nibbleOdds = 500; - if (level->isRainingAt( Mth::floor(x), Mth::floor(y) + 1, Mth::floor(z))) nibbleOdds = 300; + { + // TU 31: Raining affects the nibble timer by random chance rather than being a fixed rate. Source: https://minecraft.wiki/w/Fishing + if (!(level->isRainingAt( Mth::floor(x), Mth::floor(y) + 1, Mth::floor(z)))) { + nibbleTimer--; + } - if (random->nextInt(nibbleOdds) == 0) + else { + if (random->nextInt(4) == 0) { + nibbleTimer -= 2; + } + else { + nibbleTimer--; + } + } + + // Only calculate the effect of lure if it hasn't been calculated already. + if (lureTime == 0 && owner != nullptr) { - nibble = random->nextInt(30) + 10; + std::shared_ptr selectedItemLureCheck = owner->getSelectedItem(); + int level = EnchantmentHelper::getEnchantmentLevel(64, selectedItemLureCheck); // Lure + lureTime = level * 100; + nibbleTimer -= lureTime; + // if the lure effect causes the nibble timer to go below 0, reset the timer and lure time to recalculate next tick. Source: https://minecraft.wiki/w/Fishing + if (nibbleTimer < 0) + { + nibbleTimer = random->nextInt(501) + 100; + lureTime = 0; + } + } + + // Checks if the nibble timer has ran out. Edge case for if it's raining and the nibble timer goes + // below 0 due to the random chance of the rain decreasing the timer by 2 instead of 1. + if (nibbleTimer == 0 || nibbleTimer == -1) + { + // TU 31: Increase the nibble time to between 1 and 2 seconds. https://minecraft.wiki/w/Fishing + nibble = random->nextInt(21) + 20; + nibbleTimer = random->nextInt(501) + 100; + lureTime = 0; yd -= 0.2f; playSound(eSoundType_RANDOM_SPLASH, 0.25f, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f); float yt = static_cast(Mth::floor(bb->y0)); @@ -420,7 +458,14 @@ int FishingHook::retrieve() } else if (nibble > 0) { - shared_ptr ie = std::make_shared(this->Entity::level, x, y, z, shared_ptr(new ItemInstance(Item::fish_raw))); + FishingHelper* helper = FishingHelper::getInstance(); + + std::shared_ptr selectedItemSeaLuck = owner->getSelectedItem(); + // TODO: Take into account luck potion effect when calculating luck level once it's implemented + int luckLevel = EnchantmentHelper::getEnchantmentLevel(65, selectedItemSeaLuck); // Luck of the sea + std::shared_ptr fishingItemInstance = helper->getCatch(luckLevel, random); + + std::shared_ptr ie = std::make_shared(this->Entity::level, x, y, z, fishingItemInstance); double xa = owner->x - x; double ya = owner->y - y; double za = owner->z - z; diff --git a/Minecraft.World/FishingHook.h b/Minecraft.World/FishingHook.h index 879be954..c9eaebd5 100644 --- a/Minecraft.World/FishingHook.h +++ b/Minecraft.World/FishingHook.h @@ -25,6 +25,8 @@ private: int life; int flightTime; int nibble; + int nibbleTimer; + int lureTime; public: shared_ptr hookedIn; diff --git a/Minecraft.World/FishingRodItem.cpp b/Minecraft.World/FishingRodItem.cpp index b9eafd18..95408fa5 100644 --- a/Minecraft.World/FishingRodItem.cpp +++ b/Minecraft.World/FishingRodItem.cpp @@ -30,6 +30,12 @@ bool FishingRodItem::isMirroredArt() return true; } +// This makes it so that fishing rods can be enchanted at an enchanting table. +int FishingRodItem::getEnchantmentValue() +{ + return 1; // Enchantibility of a fishing rod. // Source: https://minecraft.wiki/w/Fishing_Rod +} + shared_ptr FishingRodItem::use(shared_ptr instance, Level *level, shared_ptr player) { if (player->fishing != nullptr) diff --git a/Minecraft.World/FishingRodItem.h b/Minecraft.World/FishingRodItem.h index 5d95177a..4a6153d5 100644 --- a/Minecraft.World/FishingRodItem.h +++ b/Minecraft.World/FishingRodItem.h @@ -17,7 +17,7 @@ public: virtual bool isHandEquipped(); virtual bool isMirroredArt(); virtual shared_ptr use(shared_ptr instance, Level *level, shared_ptr player); - + virtual int getEnchantmentValue(); void registerIcons(IconRegister *iconRegister); Icon *getEmptyIcon(); }; diff --git a/Minecraft.World/Item.cpp b/Minecraft.World/Item.cpp index c4713b5d..3d72b78a 100644 --- a/Minecraft.World/Item.cpp +++ b/Minecraft.World/Item.cpp @@ -400,8 +400,8 @@ void Item::staticCtor() Item::egg = ( new EggItem(88) ) ->setIconName(L"egg")->setDescriptionId(IDS_ITEM_EGG)->setUseDescriptionId(IDS_DESC_EGG); Item::fishingRod = static_cast((new FishingRodItem(90))->setBaseItemTypeAndMaterial(eBaseItemType_rod, eMaterial_wood)->setIconName(L"fishingRod")->setDescriptionId(IDS_ITEM_FISHING_ROD)->setUseDescriptionId(IDS_DESC_FISHINGROD)); Item::yellowDust = ( new Item(92) ) ->setIconName(L"yellowDust")->setDescriptionId(IDS_ITEM_YELLOW_DUST)->setUseDescriptionId(IDS_DESC_YELLOW_DUST)->setPotionBrewingFormula(PotionBrewing::MOD_GLOWSTONE); - Item::fish_raw = ( new FishFoodItem(93, false) ) ->setIconName(L"fishRaw")->setDescriptionId(IDS_ITEM_FISH_RAW)->setUseDescriptionId(IDS_DESC_FISH_RAW); - Item::fish_cooked = (new FishFoodItem(94, true)) ->setIconName(L"fishCooked")->setDescriptionId(IDS_ITEM_FISH_COOKED)->setUseDescriptionId(IDS_DESC_FISH_COOKED); + Item::fish_raw = ( new FishFoodItem(93, false) ) ->setIconName(L"fishRaw")->setDescriptionId(IDS_ITEM_FISH_RAW)->setUseDescriptionId(IDS_DESC_FISH_RAW)->setStackedByData(true); + Item::fish_cooked = (new FishFoodItem(94, true)) ->setIconName(L"fishCooked")->setDescriptionId(IDS_ITEM_FISH_COOKED)->setUseDescriptionId(IDS_DESC_FISH_COOKED)->setStackedByData(true); Item::dye_powder = ( new DyePowderItem(95) ) ->setBaseItemTypeAndMaterial(eBaseItemType_dyepowder, eMaterial_dye)->setIconName(L"dyePowder")->setDescriptionId(IDS_ITEM_DYE_POWDER)->setUseDescriptionId(-1); diff --git a/Minecraft.World/LuckOfTheSeaEnchantment.cpp b/Minecraft.World/LuckOfTheSeaEnchantment.cpp new file mode 100644 index 00000000..6dd8edaa --- /dev/null +++ b/Minecraft.World/LuckOfTheSeaEnchantment.cpp @@ -0,0 +1,25 @@ +#include "stdafx.h" +#include "LuckOfTheSeaEnchantment.h" + + +LuckOfTheSeaEnchantment::LuckOfTheSeaEnchantment(int id, int frequency) : Enchantment(id, frequency, EnchantmentCategory::fishing_rod) +{ + setDescriptionId(IDS_ENCHANTMENT_LUCK_OF_THE_SEA); +} + +// Source: https://github.com/GRAnimated/MinecraftLCE + +int LuckOfTheSeaEnchantment::getMinCost(int level) +{ + return 9 * level + 6; +} + +int LuckOfTheSeaEnchantment::getMaxCost(int level) +{ + return Enchantment::getMinCost(level) + 50;; +} + +int LuckOfTheSeaEnchantment::getMaxLevel() +{ + return 3; +} \ No newline at end of file diff --git a/Minecraft.World/LuckOfTheSeaEnchantment.h b/Minecraft.World/LuckOfTheSeaEnchantment.h new file mode 100644 index 00000000..0428dc3c --- /dev/null +++ b/Minecraft.World/LuckOfTheSeaEnchantment.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Enchantment.h" + +class LuckOfTheSeaEnchantment : public Enchantment +{ +public: + LuckOfTheSeaEnchantment(int id, int frequency); + + virtual int getMinCost(int level); + virtual int getMaxCost(int level); + virtual int getMaxLevel(); +}; \ No newline at end of file diff --git a/Minecraft.World/LureEnchantment.cpp b/Minecraft.World/LureEnchantment.cpp new file mode 100644 index 00000000..d44e76a4 --- /dev/null +++ b/Minecraft.World/LureEnchantment.cpp @@ -0,0 +1,25 @@ +#include "stdafx.h" +#include "LureEnchantment.h" + + +LureEnchantment::LureEnchantment(int id, int frequency) : Enchantment(id, frequency, EnchantmentCategory::fishing_rod) +{ + setDescriptionId(IDS_ENCHANTMENT_LURE); +} + +// Source: https://github.com/GRAnimated/MinecraftLCE + +int LureEnchantment::getMinCost(int level) +{ + return 9 * level + 6; +} + +int LureEnchantment::getMaxCost(int level) +{ + return Enchantment::getMinCost(level) + 50;; +} + +int LureEnchantment::getMaxLevel() +{ + return 3; +} \ No newline at end of file diff --git a/Minecraft.World/LureEnchantment.h b/Minecraft.World/LureEnchantment.h new file mode 100644 index 00000000..e549f64b --- /dev/null +++ b/Minecraft.World/LureEnchantment.h @@ -0,0 +1,13 @@ + #pragma once + +#include "Enchantment.h" + +class LureEnchantment : public Enchantment +{ +public: + LureEnchantment(int id, int frequency); + + virtual int getMinCost(int level); + virtual int getMaxCost(int level); + virtual int getMaxLevel(); +}; \ No newline at end of file diff --git a/Minecraft.World/cmake/sources/Common.cmake b/Minecraft.World/cmake/sources/Common.cmake index 01bcffb8..19e92eaf 100644 --- a/Minecraft.World/cmake/sources/Common.cmake +++ b/Minecraft.World/cmake/sources/Common.cmake @@ -469,6 +469,8 @@ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_UTIL "${CMAKE_CURRENT_SOURCE_DIR}/WeighedRandom.h" "${CMAKE_CURRENT_SOURCE_DIR}/WeighedTreasure.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/WeighedTreasure.h" + "${CMAKE_CURRENT_SOURCE_DIR}/FishingHelper.h" + "${CMAKE_CURRENT_SOURCE_DIR}/FishingHelper.cpp" ) source_group("net/minecraft/util" FILES ${_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_UTIL}) @@ -1206,6 +1208,10 @@ source_group("net/minecraft/world/item/crafting" FILES ${_MINECRAFT_WORLD_COMMON set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_ITEM_ENCHANTMENT "${CMAKE_CURRENT_SOURCE_DIR}/ArrowDamageEnchantment.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ArrowDamageEnchantment.h" + "${CMAKE_CURRENT_SOURCE_DIR}/LureEnchantment.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/LureEnchantment.h" + "${CMAKE_CURRENT_SOURCE_DIR}/LuckOfTheSeaEnchantment.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/LuckOfTheSeaEnchantment.h" "${CMAKE_CURRENT_SOURCE_DIR}/ArrowFireEnchantment.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ArrowFireEnchantment.h" "${CMAKE_CURRENT_SOURCE_DIR}/ArrowInfiniteEnchantment.cpp" diff --git a/Minecraft.World/net.minecraft.world.item.enchantment.h b/Minecraft.World/net.minecraft.world.item.enchantment.h index c0df5226..57ec4753 100644 --- a/Minecraft.World/net.minecraft.world.item.enchantment.h +++ b/Minecraft.World/net.minecraft.world.item.enchantment.h @@ -21,4 +21,10 @@ #include "ArrowInfiniteEnchantment.h" #include "ArrowKnockbackEnchantment.h" -#include "ThornsEnchantment.h" \ No newline at end of file +#include "ThornsEnchantment.h" + +// Fishing + +#include "LuckOfTheSeaEnchantment.h" + +#include "LureEnchantment.h" \ No newline at end of file