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