ItemSaddle .java

net.minecraft.item.ItemSaddle (class): members: itemInteractionForEntity, hitEntity. strings: "mob.horse.leather". imports: EntityPig, CreativeTabs.

net.minecraft.itemclass50 linescommonextends Item1.4 KB

API Surface (2)

boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)

String literals (1)

"mob.horse.leather"

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ItemSaddle.java50 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item;
2
3
import net.minecraft.creativetab.CreativeTabs;
4
import net.minecraft.entity.EntityLivingBase;
5
import net.minecraft.entity.passive.EntityPig;
6
import net.minecraft.entity.player.EntityPlayer;
7
8
public class ItemSaddle extends Item
9
{
10
    public ItemSaddle()
11
    {
12
        this.maxStackSize = 1;
13
        this.setCreativeTab(CreativeTabs.tabTransport);
14
    }
15
16
    /**
17
     * Returns true if the item can be used on the given entity, e.g. shears on sheep.
18
     */
19
    public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
20
    {
21
        if (target instanceof EntityPig)
22
        {
23
            EntityPig entitypig = (EntityPig)target;
24
25
            if (!entitypig.getSaddled() && !entitypig.isChild())
26
            {
27
                entitypig.setSaddled(true);
28
                entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F);
29
                --stack.stackSize;
30
            }
31
32
            return true;
33
        }
34
        else
35
        {
36
            return false;
37
        }
38
    }
39
40
    /**
41
     * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
42
     * the damage on the stack.
43
     */
44
    public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
45
    {
46
        this.itemInteractionForEntity(stack, (EntityPlayer)null, target);
47
        return true;
48
    }
49
}
50

Deobfuscated MCP 1.8.9 source of ItemSaddle from Marcelektro/MavenMCP-1.8.9 (net/minecraft/item/ItemSaddle.java), stored verbatim.