mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-06-26 08:57:03 +00:00
Merge pull request 'Add stuff from fishing update (TU 31)' (#9) from BrainFart17/LegacyEvolved:main into main
Reviewed-on: https://codeberg.org/piebot/LegacyEvolved/pulls/9
This commit is contained in:
commit
2eb8b58ec4
Binary file not shown.
Binary file not shown.
|
|
@ -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
|
||||
#define IDS_DESC_EXITBOOK 2422
|
||||
#define IDS_ENCHANTMENT_LURE 2423
|
||||
#define IDS_ENCHANTMENT_LUCK_OF_THE_SEA 2424
|
||||
|
|
|
|||
|
|
@ -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 *> 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];
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<FishingRodItem*>(item) != nullptr)
|
||||
{
|
||||
return this == fishing_rod;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -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;
|
||||
};
|
||||
97
Minecraft.World/FishingHelper.cpp
Normal file
97
Minecraft.World/FishingHelper.cpp
Normal file
|
|
@ -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 <memory>
|
||||
#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<CatchTypeWeighedItem *>(WeighedRandom::getRandomItem(random, catchTypeArray));
|
||||
}
|
||||
|
||||
CatchWeighedItem* FishingHelper::getRandCatch(CatchType catchType, Random* random)
|
||||
{
|
||||
CatchWeighedItem* catchWeighedItem = nullptr;
|
||||
switch (catchType) {
|
||||
case CatchType::FISH:
|
||||
return static_cast<CatchWeighedItem *>(WeighedRandom::getRandomItem(random, fishingFishArray));
|
||||
case CatchType::TREASURE:
|
||||
return static_cast<CatchWeighedItem *>(WeighedRandom::getRandomItem(random, fishingTreasuresArray));;
|
||||
case CatchType::JUNK:
|
||||
return static_cast<CatchWeighedItem *>(WeighedRandom::getRandomItem(random, fishingJunkArray));
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<ItemInstance> FishingHelper::handleCatch(CatchWeighedItem* weighedCatch, CatchType catchType, Random* random)
|
||||
{
|
||||
std::shared_ptr<ItemInstance> itemInstance = std::make_shared<ItemInstance>(
|
||||
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<ItemInstance> FishingHelper::getCatch(int luck, Random* random)
|
||||
{
|
||||
CatchType catchType = getRandCatchType(luck, random);
|
||||
CatchWeighedItem* catchWeighedItem = getRandCatch(catchType, random);
|
||||
return handleCatch(catchWeighedItem, catchType, random);
|
||||
}
|
||||
102
Minecraft.World/FishingHelper.h
Normal file
102
Minecraft.World/FishingHelper.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#pragma once
|
||||
|
||||
#include "../Minecraft.World/WeighedTreasure.h"
|
||||
#include "../Minecraft.World/ItemInstance.h"
|
||||
#include "net.minecraft.world.item.h"
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
|
||||
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<CatchTypeWeighedItem *>(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<ItemInstance> getCatch(int luck, Random* random);
|
||||
private:
|
||||
CatchType getRandCatchType(int level, Random* random);
|
||||
CatchWeighedItem* getRandCatch(CatchType catchType, Random* random);
|
||||
std::shared_ptr<ItemInstance> handleCatch(CatchWeighedItem* weighedCatch, CatchType catchType, Random* random);
|
||||
|
||||
};
|
||||
|
|
@ -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<Player> owner) : Entity( level )
|
||||
FishingHook::FishingHook(Level *level, double x, double y, double z, std::shared_ptr<Player> 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<Player> mob) : Entity( level )
|
||||
FishingHook::FishingHook(Level *level, std::shared_ptr<Player> mob) : Entity( level )
|
||||
{
|
||||
_init();
|
||||
|
||||
|
|
@ -172,7 +178,7 @@ void FishingHook::tick()
|
|||
|
||||
if (!level->isClientSide)
|
||||
{
|
||||
shared_ptr<ItemInstance> selectedItem = owner->getSelectedItem();
|
||||
std::shared_ptr<ItemInstance> 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<Entity> hitEntity = nullptr;
|
||||
vector<shared_ptr<Entity> > *objects = level->getEntities(shared_from_this(), bb->expand(xd, yd, zd)->grow(1, 1, 1));
|
||||
std::shared_ptr<Entity> hitEntity = nullptr;
|
||||
vector< std::shared_ptr<Entity> > *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<Entity> e = *it; // objects->at(i);
|
||||
std::shared_ptr<Entity> 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<ItemInstance> 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<float>(Mth::floor(bb->y0));
|
||||
|
|
@ -420,7 +458,14 @@ int FishingHook::retrieve()
|
|||
}
|
||||
else if (nibble > 0)
|
||||
{
|
||||
shared_ptr<ItemEntity> ie = std::make_shared<ItemEntity>(this->Entity::level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Item::fish_raw)));
|
||||
FishingHelper* helper = FishingHelper::getInstance();
|
||||
|
||||
std::shared_ptr<ItemInstance> 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<ItemInstance> fishingItemInstance = helper->getCatch(luckLevel, random);
|
||||
|
||||
std::shared_ptr<ItemEntity> ie = std::make_shared<ItemEntity>(this->Entity::level, x, y, z, fishingItemInstance);
|
||||
double xa = owner->x - x;
|
||||
double ya = owner->y - y;
|
||||
double za = owner->z - z;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ private:
|
|||
int life;
|
||||
int flightTime;
|
||||
int nibble;
|
||||
int nibbleTimer;
|
||||
int lureTime;
|
||||
|
||||
public:
|
||||
shared_ptr<Entity> hookedIn;
|
||||
|
|
|
|||
|
|
@ -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<ItemInstance> FishingRodItem::use(shared_ptr<ItemInstance> instance, Level *level, shared_ptr<Player> player)
|
||||
{
|
||||
if (player->fishing != nullptr)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
virtual bool isHandEquipped();
|
||||
virtual bool isMirroredArt();
|
||||
virtual shared_ptr<ItemInstance> use(shared_ptr<ItemInstance> instance, Level *level, shared_ptr<Player> player);
|
||||
|
||||
virtual int getEnchantmentValue();
|
||||
void registerIcons(IconRegister *iconRegister);
|
||||
Icon *getEmptyIcon();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<FishingRodItem *>((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);
|
||||
|
||||
|
|
|
|||
25
Minecraft.World/LuckOfTheSeaEnchantment.cpp
Normal file
25
Minecraft.World/LuckOfTheSeaEnchantment.cpp
Normal file
|
|
@ -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;
|
||||
}
|
||||
13
Minecraft.World/LuckOfTheSeaEnchantment.h
Normal file
13
Minecraft.World/LuckOfTheSeaEnchantment.h
Normal file
|
|
@ -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();
|
||||
};
|
||||
25
Minecraft.World/LureEnchantment.cpp
Normal file
25
Minecraft.World/LureEnchantment.cpp
Normal file
|
|
@ -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;
|
||||
}
|
||||
13
Minecraft.World/LureEnchantment.h
Normal file
13
Minecraft.World/LureEnchantment.h
Normal file
|
|
@ -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();
|
||||
};
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -21,4 +21,10 @@
|
|||
#include "ArrowInfiniteEnchantment.h"
|
||||
#include "ArrowKnockbackEnchantment.h"
|
||||
|
||||
#include "ThornsEnchantment.h"
|
||||
#include "ThornsEnchantment.h"
|
||||
|
||||
// Fishing
|
||||
|
||||
#include "LuckOfTheSeaEnchantment.h"
|
||||
|
||||
#include "LureEnchantment.h"
|
||||
Loading…
Reference in a new issue