48 lines
1.3 KiB
Java
Executable file
48 lines
1.3 KiB
Java
Executable file
package game.item;
|
|
|
|
import game.entity.animal.EntityPig;
|
|
import game.entity.npc.EntityNPC;
|
|
import game.entity.types.EntityLiving;
|
|
|
|
public class ItemSaddle extends Item
|
|
{
|
|
public ItemSaddle()
|
|
{
|
|
this.maxStackSize = 1;
|
|
this.setTab(CheatTab.tabTools);
|
|
}
|
|
|
|
/**
|
|
* Returns true if the item can be used on the given entity, e.g. shears on sheep.
|
|
*/
|
|
public boolean itemInteractionForEntity(ItemStack stack, EntityNPC playerIn, EntityLiving target)
|
|
{
|
|
if (target instanceof EntityPig)
|
|
{
|
|
EntityPig entitypig = (EntityPig)target;
|
|
|
|
if (!entitypig.getSaddled() && !entitypig.isChild())
|
|
{
|
|
entitypig.setSaddled(true);
|
|
// entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F);
|
|
--stack.stackSize;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
|
|
* the damage on the stack.
|
|
*/
|
|
public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker)
|
|
{
|
|
this.itemInteractionForEntity(stack, (EntityNPC)null, target);
|
|
return true;
|
|
}
|
|
}
|