aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/FishingRodItem.cpp
blob: 883eb2dedc6ebe26b3b995b102380df03fe4e6c5 (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
#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"

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

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

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

shared_ptr<ItemInstance> FishingRodItem::use(shared_ptr<ItemInstance> instance, Level *level, shared_ptr<Player> player) 
{
	if (player->fishing != NULL) 
	{
		int dmg = player->fishing->retrieve();
		instance->hurtAndBreak(dmg, player);
		player->swing();
	} 
	else 
	{
		level->playEntitySound(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'
			shared_ptr<FishingHook> hook = shared_ptr<FishingHook>( new FishingHook(level, player) );
			player->fishing = hook;
			level->addEntity( shared_ptr<FishingHook>( hook ) );
		}
		player->swing();
	}
	return instance;
}

void FishingRodItem::registerIcons(IconRegister *iconRegister)
{
        icon = iconRegister->registerIcon(getIconName() + L"_uncast");
	emptyIcon = iconRegister->registerIcon(getIconName() + L"_cast");
}

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