Advertisement
AvidPenguin

BlockTomato.java

Jul 24th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. package avidpenguin.bettercraft.block;
  2.  
  3. import avidpenguin.bettercraft.BetterCraft;
  4. import cpw.mods.fml.relauncher.Side;
  5. import cpw.mods.fml.relauncher.SideOnly;
  6.  
  7. import java.util.Random;
  8.  
  9. import net.minecraft.block.Block;
  10. import net.minecraft.block.material.Material;
  11. import net.minecraft.client.renderer.texture.IconRegister;
  12. import net.minecraft.creativetab.CreativeTabs;
  13. import net.minecraft.item.Item;
  14. import net.minecraft.util.Icon;
  15.  
  16. public class BlockTomato extends Block
  17. {
  18. @SideOnly(Side.CLIENT)
  19. private Icon theIcon;
  20.  
  21. protected BlockTomato(int par1)
  22. {
  23. super(par1, Material.pumpkin);
  24. }
  25.  
  26. @SideOnly(Side.CLIENT)
  27.  
  28. /**
  29. * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
  30. */
  31. public Icon getIcon(int par1, int par2)
  32. {
  33. return par1 != 1 && par1 != 0 ? this.blockIcon : this.theIcon;
  34. }
  35.  
  36. /**
  37. * Returns the ID of the items to drop on destruction.
  38. */
  39. public int idDropped(int par1, Random par2Random, int par3)
  40. {
  41. return BetterCraft.tomato.itemID;
  42. }
  43.  
  44. /**
  45. * Returns the quantity of items to drop on block destruction.
  46. */
  47. public int quantityDropped(Random par1Random)
  48. {
  49. return 3 + par1Random.nextInt(5);
  50. }
  51.  
  52. /**
  53. * Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
  54. */
  55. public int quantityDroppedWithBonus(int par1, Random par2Random)
  56. {
  57. int j = this.quantityDropped(par2Random) + par2Random.nextInt(1 + par1);
  58.  
  59. if (j > 9)
  60. {
  61. j = 9;
  62. }
  63.  
  64. return j;
  65. }
  66.  
  67. @SideOnly(Side.CLIENT)
  68.  
  69. /**
  70. * When this method is called, your block should register all the icons it needs with the given IconRegister. This
  71. * is the only chance you get to register icons.
  72. */
  73. public void registerIcons(IconRegister par1IconRegister)
  74. {
  75. this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");
  76. this.theIcon = par1IconRegister.registerIcon(this.getTextureName() + "_top");
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement