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