Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package assets.pamharvestcraft;
- import java.util.List;
- import cpw.mods.fml.common.registry.VillagerRegistry;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.item.ItemFood;
- import net.minecraft.block.Block;
- import net.minecraft.client.renderer.texture.IconRegister;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemFood;
- import net.minecraft.item.ItemSeedFood;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.Icon;
- import net.minecraft.world.World;
- import net.minecraftforge.common.EnumPlantType;
- public class ItemPamSeedFood extends ItemSeedFood
- {
- public int cropID;
- public ItemPamSeedFood (int par1, int par2, float par3, int par4)
- {
- super(par1, par2, par3, par4, par4);
- this.cropID = par4;
- this.setCreativeTab(PamHarvestCraft.tabHarvestCraft);
- }
- public void setCropIDAndGrowthStage(ItemStack itemstack, World world, int i, int j, int k, int l) {
- world.setBlock(i, j + 1, k, PamHarvestCraft.pamCrop.blockID);
- TileEntityPamCrop tileentitypamcrop = (TileEntityPamCrop)world.getBlockTileEntity(i, j + 1, k);
- if(tileentitypamcrop != null) {
- tileentitypamcrop.setCropID(this.cropID);
- tileentitypamcrop.setGrowthStage(0);
- }
- }
- public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int i, int j, int k, int l, float par8, float par9, float par10) {
- int i1 = par3World.getBlockId(i, j, k);
- if(i1 == Block.tilledField.blockID && par3World.isAirBlock(i, j + 1, k)) {
- this.setCropIDAndGrowthStage(par1ItemStack, par3World, i, j, k, l);
- --par1ItemStack.stackSize;
- return true;
- } else {
- return false;
- }
- }
- @Override
- @SideOnly(Side.CLIENT)
- public void registerIcons(IconRegister ir)
- {
- this.itemIcon = ir.registerIcon((this.getUnlocalizedName().substring(5)));
- }
- /**
- * allows items to add custom lines of information to the mouseover description
- */
- public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
- {
- int hungerFill = this.getHealAmount();
- float satiation = (this.getSaturationModifier() * 10) - (float) hungerFill;
- String tooltip = "";
- if (satiation >= 3.0F) {
- tooltip += "hearty ";
- } else if (satiation >= 2.0F) {
- tooltip += "wholesome ";
- } else if (satiation > 0.0F) {
- tooltip += "nourishing ";
- } else if (satiation < 0.0F) {
- tooltip += "unfulfilling ";
- }
- if (hungerFill <= 1) {
- tooltip += "morsel";
- } else if (hungerFill <= 2) {
- tooltip += "snack";
- } else if (hungerFill <= 5) {
- tooltip += "light meal";
- } else if (hungerFill <= 8) {
- tooltip += "meal";
- } else if (hungerFill <= 11) {
- tooltip += "large meal";
- } else {
- tooltip += "feast";
- }
- par3List.add(tooltip.substring(0, 1).toUpperCase() + tooltip.substring(1));
- }
- @Override
- public EnumPlantType getPlantType(World world, int x, int y, int z)
- {
- return EnumPlantType.Crop;
- }
- @Override
- public int getPlantID(World world, int x, int y, int z)
- {
- return cropID;
- }
- @Override
- public int getPlantMetadata(World world, int x, int y, int z)
- {
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement