mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-07-03 12:27:02 +00:00
Add fishing stuff from TU 31
This commit is contained in:
parent
d75e167f12
commit
f0b28416c0
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: 2416
|
||||
|
||||
#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,4 +2416,6 @@
|
|||
#define IDS_DESC_LARGE_FERN 2410
|
||||
#define IDS_DESC_ROSE_BUSH 2411
|
||||
#define IDS_DESC_PEONY 2412
|
||||
#define IDS_ENDERMITE 2413
|
||||
#define IDS_ENDERMITE 2413
|
||||
#define IDS_ENCHANTMENT_LUCK_OF_THE_SEA 2414
|
||||
#define IDS_ENCHANTMENT_LURE 2415
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
|
||||
#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() :
|
||||
random(new Random()), level0Array(3), level1Array(3), level2Array(3), level3Array(3),
|
||||
fishingFishArray(4), fishingJunkArray(12), fishingTreasuresArray(5)
|
||||
{
|
||||
|
||||
// Source: https://minecraft.wiki/w/Fishing
|
||||
level0Array[0] = new CatchTypeWeighedItem(CatchType::JUNK, 10 );
|
||||
level0Array[1] = new CatchTypeWeighedItem(CatchType::TREASURE, 5 );
|
||||
level0Array[2] = new CatchTypeWeighedItem(CatchType::FISH, 85 );
|
||||
|
||||
level1Array[0] = new CatchTypeWeighedItem(CatchType::JUNK, 81 );
|
||||
level1Array[1] = new CatchTypeWeighedItem(CatchType::TREASURE, 71 );
|
||||
level1Array[2] = new CatchTypeWeighedItem(CatchType::FISH, 848 );
|
||||
|
||||
level2Array[0] = new CatchTypeWeighedItem(CatchType::JUNK, 61 );
|
||||
level2Array[1] = new CatchTypeWeighedItem(CatchType::TREASURE, 92 );
|
||||
level2Array[2] = new CatchTypeWeighedItem(CatchType::FISH, 847 );
|
||||
|
||||
level3Array[0] = new CatchTypeWeighedItem(CatchType::JUNK, 41 );
|
||||
level3Array[1] = new CatchTypeWeighedItem(CatchType::TREASURE, 113 );
|
||||
level3Array[2] = new CatchTypeWeighedItem(CatchType::FISH, 845 );
|
||||
|
||||
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, 2); // Doubled the chance of name tags to account for lack of nautilus shells.
|
||||
fishingTreasuresArray[4] = new CatchWeighedItem(Item::saddle_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[0] = new CatchWeighedItem(Tile::waterLily_Id, 1, 0, 17);
|
||||
fishingJunkArray[1] = new CatchWeighedItem(Item::bone_Id, 1, 0, 10);
|
||||
fishingJunkArray[2] = new CatchWeighedItem(Item::bowl_Id, 1, 0, 10);
|
||||
fishingJunkArray[3] = new CatchWeighedItem(Item::leather_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[6] = new CatchWeighedItem(Item::potion_Id, 1, 0, 10); // Water bottle
|
||||
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 level)
|
||||
{
|
||||
CatchTypeWeighedItem* catchTypeWeighedItem = nullptr;
|
||||
switch (level) {
|
||||
case 0:
|
||||
catchTypeWeighedItem = static_cast<CatchTypeWeighedItem *>(WeighedRandom::getRandomItem(random, level0Array));
|
||||
return catchTypeWeighedItem->getType();
|
||||
case 1:
|
||||
catchTypeWeighedItem = static_cast<CatchTypeWeighedItem *>(WeighedRandom::getRandomItem(random, level1Array));
|
||||
return catchTypeWeighedItem->getType();
|
||||
case 2:
|
||||
catchTypeWeighedItem = static_cast<CatchTypeWeighedItem *>(WeighedRandom::getRandomItem(random, level2Array));
|
||||
return catchTypeWeighedItem->getType();
|
||||
case 3:
|
||||
catchTypeWeighedItem = static_cast<CatchTypeWeighedItem *>(WeighedRandom::getRandomItem(random, level3Array));
|
||||
return catchTypeWeighedItem->getType();
|
||||
}
|
||||
}
|
||||
|
||||
CatchWeighedItem* FishingHelper::getRandCatch(CatchType catchType)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
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) + 750.0) / 1000.0)); // 75% to 100% damage
|
||||
itemInstance = EnchantmentHelper::enchantItem(random, itemInstance, random->nextInt(9) + 22); // 22 to 30 enchantment level
|
||||
}
|
||||
else if (itemInstance->id == Item::bow_Id) {
|
||||
itemInstance->setAuxValue((int) (itemInstance->getMaxDamage() * ((double) random->nextInt(250) + 750.0) / 1000.0)); // 75% to 100% damage
|
||||
itemInstance = EnchantmentHelper::enchantItem(random, itemInstance, random->nextInt(9) + 22); // 22 to 30 enchantment level
|
||||
}
|
||||
else if (itemInstance->id == Item::book_Id) {
|
||||
itemInstance = EnchantmentHelper::enchantItem(random, itemInstance, 30);
|
||||
}
|
||||
|
||||
return itemInstance;
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
#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;
|
||||
|
||||
public:
|
||||
CatchTypeWeighedItem(CatchType type, int weight) : WeighedRandomItem(weight)
|
||||
{
|
||||
this->type = type;
|
||||
}
|
||||
|
||||
CatchType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
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();
|
||||
Random* random;
|
||||
|
||||
WeighedRandomItemArray level0Array;
|
||||
WeighedRandomItemArray level1Array;
|
||||
WeighedRandomItemArray level2Array;
|
||||
WeighedRandomItemArray level3Array;
|
||||
|
||||
WeighedRandomItemArray fishingFishArray;
|
||||
WeighedRandomItemArray fishingJunkArray;
|
||||
WeighedRandomItemArray fishingTreasuresArray;
|
||||
public:
|
||||
|
||||
FishingHelper(const FishingHelper&) = delete;
|
||||
FishingHelper& operator=(const FishingHelper&) = delete;
|
||||
|
||||
static FishingHelper* getInstance();
|
||||
|
||||
CatchType getRandCatchType(int level);
|
||||
CatchWeighedItem* getRandCatch(CatchType catchType);
|
||||
std::shared_ptr<ItemInstance> handleCatch(CatchWeighedItem* weighedCatch, CatchType catchType);
|
||||
};
|
||||
|
|
@ -11,8 +11,13 @@
|
|||
#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"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
// 4J - added common ctor code.
|
||||
void FishingHook::_init()
|
||||
|
|
@ -29,6 +34,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 +61,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 +72,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 +181,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 +239,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 +334,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 +461,23 @@ 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();
|
||||
int luckLevel = EnchantmentHelper::getEnchantmentLevel(65, selectedItemSeaLuck); // Luck of the sea
|
||||
CatchType type = helper->getRandCatchType(luckLevel);
|
||||
CatchWeighedItem* caughtItem = helper->getRandCatch(type);
|
||||
|
||||
std::shared_ptr<ItemInstance> fishingItemInstance;
|
||||
|
||||
if (!caughtItem) {
|
||||
// Fall back to default if caught item is a nullptr
|
||||
fishingItemInstance = shared_ptr<ItemInstance>(new ItemInstance(Item::fish_raw));
|
||||
} else {
|
||||
fishingItemInstance = helper->handleCatch(caughtItem, type);
|
||||
}
|
||||
|
||||
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();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -398,8 +398,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();
|
||||
};
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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