aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/SaddleItem.cpp
blob: 6387306096a11ebef2887f2bb0262dbf29b7de2d (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
#include "stdafx.h"
#include "net.minecraft.world.entity.animal.h"
#include "net.minecraft.world.item.h"
#include "net.minecraft.world.entity.h"
#include "SaddleItem.h"

SaddleItem::SaddleItem(int id) : Item(id)
{
	maxStackSize = 1;
}

bool SaddleItem::interactEnemy(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, shared_ptr<LivingEntity> mob) 
{
	if ( (mob != nullptr) && mob->instanceof(eTYPE_PIG) )
	{
		shared_ptr<Pig> pig = dynamic_pointer_cast<Pig>(mob);
		if (!pig->hasSaddle() && !pig->isBaby()) 
		{
			pig->setSaddle(true);
			itemInstance->count--;
		}
		return true;
	}
	return false;
}

bool SaddleItem::hurtEnemy(shared_ptr<ItemInstance> itemInstance, shared_ptr<LivingEntity> mob, shared_ptr<LivingEntity> attacker) 
{
	interactEnemy(itemInstance, nullptr, mob);
	return true;
}