Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. package assets.pamharvestcraft;
  2.  
  3. import java.util.List;
  4.  
  5. import cpw.mods.fml.common.registry.VillagerRegistry;
  6. import cpw.mods.fml.relauncher.Side;
  7. import cpw.mods.fml.relauncher.SideOnly;
  8. import net.minecraft.item.ItemFood;
  9. import net.minecraft.block.Block;
  10. import net.minecraft.client.renderer.texture.IconRegister;
  11. import net.minecraft.entity.player.EntityPlayer;
  12. import net.minecraft.item.ItemFood;
  13. import net.minecraft.item.ItemSeedFood;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraft.util.Icon;
  16. import net.minecraft.world.World;
  17. import net.minecraftforge.common.EnumPlantType;
  18.  
  19. public class ItemPamSeedFood extends ItemSeedFood
  20. {
  21. public int cropID;
  22.  
  23. public ItemPamSeedFood (int par1, int par2, float par3, int par4)
  24. {
  25. super(par1, par2, par3, par4, par4);
  26. this.cropID = par4;
  27. this.setCreativeTab(PamHarvestCraft.tabHarvestCraft);
  28.  
  29.  
  30. }
  31.  
  32.  
  33.  
  34. public void setCropIDAndGrowthStage(ItemStack itemstack, World world, int i, int j, int k, int l) {
  35. world.setBlock(i, j + 1, k, PamHarvestCraft.pamCrop.blockID);
  36. TileEntityPamCrop tileentitypamcrop = (TileEntityPamCrop)world.getBlockTileEntity(i, j + 1, k);
  37. if(tileentitypamcrop != null) {
  38. tileentitypamcrop.setCropID(this.cropID);
  39. tileentitypamcrop.setGrowthStage(0);
  40. }
  41.  
  42. }
  43.  
  44. public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int i, int j, int k, int l, float par8, float par9, float par10) {
  45. int i1 = par3World.getBlockId(i, j, k);
  46. if(i1 == Block.tilledField.blockID && par3World.isAirBlock(i, j + 1, k)) {
  47. this.setCropIDAndGrowthStage(par1ItemStack, par3World, i, j, k, l);
  48. --par1ItemStack.stackSize;
  49. return true;
  50. } else {
  51. return false;
  52. }
  53. }
  54.  
  55. @Override
  56. @SideOnly(Side.CLIENT)
  57. public void registerIcons(IconRegister ir)
  58. {
  59. this.itemIcon = ir.registerIcon((this.getUnlocalizedName().substring(5)));
  60. }
  61.  
  62. /**
  63. * allows items to add custom lines of information to the mouseover description
  64. */
  65. public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
  66. {
  67.  
  68. int hungerFill = this.getHealAmount();
  69. float satiation = (this.getSaturationModifier() * 10) - (float) hungerFill;
  70.  
  71. String tooltip = "";
  72.  
  73. if (satiation >= 3.0F) {
  74. tooltip += "hearty ";
  75. } else if (satiation >= 2.0F) {
  76. tooltip += "wholesome ";
  77. } else if (satiation > 0.0F) {
  78. tooltip += "nourishing ";
  79. } else if (satiation < 0.0F) {
  80. tooltip += "unfulfilling ";
  81. }
  82.  
  83. if (hungerFill <= 1) {
  84. tooltip += "morsel";
  85. } else if (hungerFill <= 2) {
  86. tooltip += "snack";
  87. } else if (hungerFill <= 5) {
  88. tooltip += "light meal";
  89. } else if (hungerFill <= 8) {
  90. tooltip += "meal";
  91. } else if (hungerFill <= 11) {
  92. tooltip += "large meal";
  93. } else {
  94. tooltip += "feast";
  95. }
  96.  
  97. par3List.add(tooltip.substring(0, 1).toUpperCase() + tooltip.substring(1));
  98.  
  99. }
  100.  
  101. @Override
  102. public EnumPlantType getPlantType(World world, int x, int y, int z)
  103. {
  104. return EnumPlantType.Crop;
  105. }
  106.  
  107. @Override
  108. public int getPlantID(World world, int x, int y, int z)
  109. {
  110. return cropID;
  111. }
  112.  
  113. @Override
  114. public int getPlantMetadata(World world, int x, int y, int z)
  115. {
  116. return 0;
  117. }
  118.  
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement