Guest User

Untitled

a guest
May 18th, 2014
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. package fantasy_biomes.blocks;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5.  
  6. import java.util.List;
  7. import java.util.Random;
  8.  
  9. import fantasy_biomes.Main;
  10. import net.minecraft.block.Block;
  11. import net.minecraft.block.BlockRotatedPillar;
  12. import net.minecraft.block.material.Material;
  13. import net.minecraft.client.renderer.texture.IconRegister;
  14. import net.minecraft.creativetab.CreativeTabs;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.util.Icon;
  17. import net.minecraft.world.World;
  18.  
  19. public class BlockRedwoodLog extends BlockRotatedPillar
  20. {
  21. /** The type of tree this log came from. */
  22. public static final String[] woodType = new String[] {"Redwood"};
  23. @SideOnly(Side.CLIENT)
  24. private Icon[] field_111052_c;
  25. @SideOnly(Side.CLIENT)
  26. private Icon[] tree_top;
  27.  
  28. public BlockRedwoodLog(int par1)
  29. {
  30. super(par1, Material.wood);
  31. this.setCreativeTab(CreativeTabs.tabBlock);
  32. }
  33.  
  34. /**
  35. * Returns the quantity of items to drop on block destruction.
  36. */
  37. public int quantityDropped(Random par1Random)
  38. {
  39. return 1;
  40. }
  41.  
  42. /**
  43. * Returns the ID of the items to drop on destruction.
  44. */
  45. public int idDropped(int par1, Random par2Random, int par3)
  46. {
  47. return Main.blockRedwoodLog.blockID;
  48. }
  49.  
  50. /**
  51. * Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
  52. * different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
  53. * metadata
  54. */
  55. public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
  56. {
  57. byte b0 = 4;
  58. int j1 = b0 + 1;
  59.  
  60. if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1))
  61. {
  62. for (int k1 = -b0; k1 <= b0; ++k1)
  63. {
  64. for (int l1 = -b0; l1 <= b0; ++l1)
  65. {
  66. for (int i2 = -b0; i2 <= b0; ++i2)
  67. {
  68. int j2 = par1World.getBlockId(par2 + k1, par3 + l1, par4 + i2);
  69.  
  70. if (Block.blocksList[j2] != null)
  71. {
  72. Block.blocksList[j2].beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2);
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
  79.  
  80. @SideOnly(Side.CLIENT)
  81.  
  82. /**
  83. * The icon for the side of the block.
  84. */
  85. protected Icon getSideIcon(int par1)
  86. {
  87. return this.field_111052_c[par1];
  88. }
  89.  
  90. @SideOnly(Side.CLIENT)
  91.  
  92. /**
  93. * The icon for the tops and bottoms of the block.
  94. */
  95. protected Icon getEndIcon(int par1)
  96. {
  97. return this.tree_top[par1];
  98. }
  99.  
  100. /**
  101. * returns a number between 0 and 3
  102. */
  103. public static int limitToValidMetadata(int par0)
  104. {
  105. return par0 & 3;
  106. }
  107.  
  108. @SideOnly(Side.CLIENT)
  109.  
  110. /**
  111. * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
  112. */
  113. public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
  114. {
  115. par3List.add(new ItemStack(par1, 1, 0));
  116. }
  117.  
  118. @SideOnly(Side.CLIENT)
  119.  
  120. /**
  121. * When this method is called, your block should register all the icons it needs with the given IconRegister. This
  122. * is the only chance you get to register icons.
  123. */
  124. public void registerIcons(IconRegister par1IconRegister)
  125. {
  126. this.field_111052_c = new Icon[woodType.length];
  127. this.tree_top = new Icon[woodType.length];
  128.  
  129. for (int i = 0; i < this.field_111052_c.length; ++i)
  130. {
  131. this.field_111052_c[i] = par1IconRegister.registerIcon(Main.modid + ":" + "BlockRedwoodLog_Side");
  132. this.tree_top[i] = par1IconRegister.registerIcon(Main.modid + ":" + "BlockRedwoodLog_Top");
  133. }
  134. }
  135.  
  136. @Override
  137. public boolean canSustainLeaves(World world, int x, int y, int z)
  138. {
  139. return true;
  140. }
  141.  
  142. @Override
  143. public boolean isWood(World world, int x, int y, int z)
  144. {
  145. return true;
  146. }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment