blob: 3701fce108ff40ed8af39485dcf6642972ac659b (
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
|
#include "stdafx.h"
#include "net.minecraft.world.entity.animal.h"
#include "net.minecraft.world.entity.player.h"
#include "net.minecraft.world.entity.ai.goal.h"
#include "net.minecraft.world.item.h"
#include "CarrotOnAStickItem.h"
CarrotOnAStickItem::CarrotOnAStickItem(int id) : Item(id)
{
setMaxStackSize(1);
setMaxDamage(25);
}
bool CarrotOnAStickItem::isHandEquipped()
{
return true;
}
bool CarrotOnAStickItem::isMirroredArt()
{
return true;
}
shared_ptr<ItemInstance> CarrotOnAStickItem::use(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
{
if (player->isRiding())
{
shared_ptr<Pig> pig = dynamic_pointer_cast<Pig>(player->riding);
if(pig)
{
if (pig->getControlGoal()->canBoost() && itemInstance->getMaxDamage() - itemInstance->getAuxValue() >= 7)
{
pig->getControlGoal()->boost();
itemInstance->hurtAndBreak(7, player);
if (itemInstance->count == 0)
{
shared_ptr<ItemInstance> replacement = shared_ptr<ItemInstance>(new ItemInstance(Item::fishingRod));
replacement->setTag(itemInstance->tag);
return replacement;
}
}
}
}
return itemInstance;
}
|