ItemCarrotOnAStick .java

net.minecraft.item.ItemCarrotOnAStick (class): members: shouldRotateAroundWhenRendering, isFull3D, onItemRightClick. imports: EntityPig, StatList, Items.

net.minecraft.itemclass63 linescommonextends Item1.9 KB

API Surface (3)

boolean isFull3D()
boolean shouldRotateAroundWhenRendering()
ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)

Code Graph: Dependencies (8)

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

Full Source

ItemCarrotOnAStick.java63 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item;
2
3
import net.minecraft.creativetab.CreativeTabs;
4
import net.minecraft.entity.passive.EntityPig;
5
import net.minecraft.entity.player.EntityPlayer;
6
import net.minecraft.init.Items;
7
import net.minecraft.stats.StatList;
8
import net.minecraft.world.World;
9
10
public class ItemCarrotOnAStick extends Item
11
{
12
    public ItemCarrotOnAStick()
13
    {
14
        this.setCreativeTab(CreativeTabs.tabTransport);
15
        this.setMaxStackSize(1);
16
        this.setMaxDamage(25);
17
    }
18
19
    /**
20
     * Returns True is the item is renderer in full 3D when hold.
21
     */
22
    public boolean isFull3D()
23
    {
24
        return true;
25
    }
26
27
    /**
28
     * Returns true if this item should be rotated by 180 degrees around the Y axis when being held in an entities
29
     * hands.
30
     */
31
    public boolean shouldRotateAroundWhenRendering()
32
    {
33
        return true;
34
    }
35
36
    /**
37
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
38
     */
39
    public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
40
    {
41
        if (playerIn.isRiding() && playerIn.ridingEntity instanceof EntityPig)
42
        {
43
            EntityPig entitypig = (EntityPig)playerIn.ridingEntity;
44
45
            if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7)
46
            {
47
                entitypig.getAIControlledByPlayer().boostSpeed();
48
                itemStackIn.damageItem(7, playerIn);
49
50
                if (itemStackIn.stackSize == 0)
51
                {
52
                    ItemStack itemstack = new ItemStack(Items.fishing_rod);
53
                    itemstack.setTagCompound(itemStackIn.getTagCompound());
54
                    return itemstack;
55
                }
56
            }
57
        }
58
59
        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
60
        return itemStackIn;
61
    }
62
}
63

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