aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/FishingRodItem.cpp
blob: 418bc625c0583c24f46d445a3613619778d3eeba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "stdafx.h"
#include "net.minecraft.network.packet.h"
#include "net.minecraft.world.entity.h"
#include "net.minecraft.world.entity.player.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.chunk.h"
#include "net.minecraft.world.level.material.h"
#include "net.minecraft.world.level.saveddata.h"
#include "net.minecraft.world.level.tile.h"
#include "net.minecraft.world.entity.projectile.h"
#include "net.minecraft.world.h"
#include "ItemInstance.h"
#include "FishingRodItem.h"
#include "SoundTypes.h"

const wstring FishingRodItem::TEXTURE_EMPTY = L"fishingRod_empty";

FishingRodItem::FishingRodItem(int id) : Item(id)
{
	setMaxDamage(64);
	setMaxStackSize(1);
	emptyIcon = NULL;
}

bool FishingRodItem::isHandEquipped()
{
	return true;
}

bool FishingRodItem::isMirroredArt()
{
	return true;
}

std::shared_ptr<ItemInstance> FishingRodItem::use(std::shared_ptr<ItemInstance> instance, Level *level, std::shared_ptr<Player> player)
{
	if (player->fishing != NULL)
	{
		int dmg = player->fishing->retrieve();
		instance->hurt(dmg, player);
		player->swing();
	}
	else
	{
		level->playSound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f));
		if (!level->isClientSide)
		{
			// 4J Stu - Move the player->fishing out of the ctor as we cannot reference 'this'
			std::shared_ptr<FishingHook> hook = std::shared_ptr<FishingHook>( new FishingHook(level, player) );
			player->fishing = hook;
			level->addEntity( std::shared_ptr<FishingHook>( hook ) );
		}
		player->swing();
	}
	return instance;
}

void FishingRodItem::registerIcons(IconRegister *iconRegister)
{
	Item::registerIcons(iconRegister);
	emptyIcon = iconRegister->registerIcon(TEXTURE_EMPTY);
}

Icon *FishingRodItem::getEmptyIcon()
{
	return emptyIcon;
}