Advertisement
Guest User

Untitled

a guest
Jul 27th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. package net.phytopia.mod.biome.features;
  2.  
  3. import java.util.List;
  4.  
  5. import cpw.mods.fml.relauncher.Side;
  6. import cpw.mods.fml.relauncher.SideOnly;
  7. import net.minecraft.block.BlockLeaves;
  8. import net.minecraft.client.renderer.texture.IIconRegister;
  9. import net.minecraft.creativetab.CreativeTabs;
  10. import net.minecraft.init.Items;
  11. import net.minecraft.item.Item;
  12. import net.minecraft.item.ItemStack;
  13. import net.minecraft.util.IIcon;
  14. import net.minecraft.world.IBlockAccess;
  15. import net.minecraft.world.World;
  16. import net.phytopia.mod.Phytopia;
  17.  
  18. public class PTLeaf extends BlockLeaves {
  19.  
  20. public static final String[][] leaftypes = new String[][] {{"LeafWeirwood", "LeafWeirwoodblue", "LeafWeirwoodblack"}, {"LeafWeirwoodOpaque", "LeafWeirwoodblueOpaque", "LeafWeirwoodblackOpaque"}};
  21. public static final String[] leaves = new String[] {"Weirwood", "Weirwoodblue", "Weirwoodblack"};
  22.  
  23. protected void func_150124_c(World world, int x, int y, int z, int side, int meta)
  24. {
  25. if ((side & 3) == 1 && world.rand.nextInt(meta) == 0)
  26. {
  27. this.dropBlockAsItem(world, x, y, z, new ItemStack(Items.apple, 1, 0));
  28. }
  29. }
  30.  
  31. /**
  32. * Determines the damage on the item the block drops. Used in cloth and wood.
  33. */
  34. public int damageDropped(int i)
  35. {
  36. return super.damageDropped(i) + 4;
  37. }
  38.  
  39. /**
  40. * Get the block's damage value (for use with pick block).
  41. */
  42. public int getDamageValue(World world, int x, int y, int z)
  43. {
  44. return world.getBlockMetadata(x, y, z) & 3;
  45. }
  46.  
  47. /**
  48. * Gets the block's texture. Args: side, meta
  49. */
  50.  
  51.  
  52. /**
  53. * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
  54. */
  55. @SideOnly(Side.CLIENT)
  56. public void getSubBlocks(Item item, CreativeTabs tab, List list)
  57. {
  58. for (int i = 0; i < leaves.length; i++) {
  59. list.add(new ItemStack(item, 1, i));
  60. }
  61. }
  62.  
  63. @SideOnly(Side.CLIENT)
  64. public void registerBlockIcons(IIconRegister iconRegister)
  65. {
  66. for (int i = 0; i < leaftypes.length; ++i)
  67. {
  68. this.field_150129_M[i] = new IIcon[leaftypes[i].length];
  69.  
  70. for (int j = 0; j < leaftypes[i].length; ++j)
  71. {
  72. this.field_150129_M[i][j] = iconRegister.registerIcon(Phytopia.modid + ":" + leaftypes[i][j]);
  73. }
  74. }
  75. }
  76.  
  77. @Override
  78. public IIcon getIcon(int side, int meta) {
  79. return (meta & 3) == 1 ? this.field_150129_M[this.field_150127_b][1] : this.field_150129_M[this.field_150127_b][0];
  80. }
  81.  
  82. @Override
  83. public String[] func_150125_e() {
  84. return leaves;
  85. }
  86.  
  87. @Override
  88. public boolean renderAsNormalBlock() {
  89. return false;
  90. }
  91.  
  92. @Override
  93. public boolean isOpaqueCube() {
  94. return false;
  95. }
  96.  
  97. @Override
  98. public boolean shouldSideBeRendered(IBlockAccess blockaccess, int x, int y, int z, int side) {
  99. return true;
  100. }
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement