001 package net.minecraft.item;
002
003 import net.minecraft.entity.player.EntityPlayer;
004 import net.minecraft.world.World;
005
006 public class ItemSeedFood extends ItemFood
007 {
008 /** Block ID of the crop this seed food should place. */
009 private int cropId;
010
011 /** Block ID of the soil this seed food should be planted on. */
012 private int soilId;
013
014 public ItemSeedFood(int par1, int par2, float par3, int par4, int par5)
015 {
016 super(par1, par2, par3, false);
017 this.cropId = par4;
018 this.soilId = par5;
019 }
020
021 /**
022 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
023 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
024 */
025 public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
026 {
027 if (par7 != 1)
028 {
029 return false;
030 }
031 else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack))
032 {
033 int var11 = par3World.getBlockId(par4, par5, par6);
034
035 if (var11 == this.soilId && par3World.isAirBlock(par4, par5 + 1, par6))
036 {
037 par3World.setBlockWithNotify(par4, par5 + 1, par6, this.cropId);
038 --par1ItemStack.stackSize;
039 return true;
040 }
041 else
042 {
043 return false;
044 }
045 }
046 else
047 {
048 return false;
049 }
050 }
051 }