001 package net.minecraft.src;
002
003 public class ItemMinecart extends Item
004 {
005 public int minecartType;
006
007 public ItemMinecart(int par1, int par2)
008 {
009 super(par1);
010 this.maxStackSize = 1;
011 this.minecartType = par2;
012 this.setCreativeTab(CreativeTabs.tabTransport);
013 }
014
015 /**
016 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
017 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
018 */
019 public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
020 {
021 int var11 = par3World.getBlockId(par4, par5, par6);
022
023 if (BlockRail.isRailBlock(var11))
024 {
025 if (!par3World.isRemote)
026 {
027 par3World.spawnEntityInWorld(new EntityMinecart(par3World, (double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.minecartType));
028 }
029
030 --par1ItemStack.stackSize;
031 return true;
032 }
033 else
034 {
035 return false;
036 }
037 }
038 }