| 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 |
|