O3Bubbles09

TNT FILE

Jul 2nd, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.Random;
  4.  
  5. public class BlockTNT extends Block
  6. {
  7. public BlockTNT(int par1, int par2)
  8. {
  9. super(par1, par2, Material.tnt);
  10. }
  11.  
  12. /**
  13. * Returns the block texture based on the side being looked at. Args: side
  14. */
  15. public int getBlockTextureFromSide(int par1)
  16. {
  17. if (par1 == 0)
  18. {
  19. return blockIndexInTexture + 2;
  20. }
  21.  
  22. if (par1 == 1)
  23. {
  24. return blockIndexInTexture + 1;
  25. }
  26. else
  27. {
  28. return blockIndexInTexture;
  29. }
  30. }
  31.  
  32. /**
  33. * Called whenever the block is added into the world. Args: world, x, y, z
  34. */
  35. public void onBlockAdded(World par1World, int par2, int par3, int par4)
  36. {
  37. super.onBlockAdded(par1World, par2, par3, par4);
  38.  
  39. if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
  40. {
  41. onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
  42. par1World.setBlockWithNotify(par2, par3, par4, 0);
  43. }
  44. }
  45.  
  46. /**
  47. * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
  48. * their own) Args: x, y, z, neighbor blockID
  49. */
  50. public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
  51. {
  52. if (par5 > 0 && Block.blocksList[par5].canProvidePower() && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
  53. {
  54. onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
  55. par1World.setBlockWithNotify(par2, par3, par4, 0);
  56. }
  57. }
  58.  
  59. /**
  60. * Returns the quantity of items to drop on block destruction.
  61. */
  62. public int quantityDropped(Random par1Random)
  63. {
  64. return 0;
  65. }
  66.  
  67. /**
  68. * Called upon the block being destroyed by an explosion
  69. */
  70. public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4)
  71. {
  72. if (par1World.isRemote)
  73. {
  74. return;
  75. }
  76. else
  77. {
  78. EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(par1World, (float)par2 + 0.5F, (float)par3 + 0.5F, (float)par4 + 0.5F);
  79. entitytntprimed.fuse = par1World.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
  80. par1World.spawnEntityInWorld(entitytntprimed);
  81. return;
  82. }
  83. }
  84.  
  85. /**
  86. * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData
  87. */
  88. public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
  89. {
  90. if (par1World.isRemote)
  91. {
  92. return;
  93. }
  94.  
  95. if ((par5 & 1) == 0)
  96. {
  97. dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Block.tnt.blockID, 1, 0));
  98. }
  99. else
  100. {
  101. EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(par1World, (float)par2 + 0.5F, (float)par3 + 0.5F, (float)par4 + 0.5F);
  102. par1World.spawnEntityInWorld(entitytntprimed);
  103. par1World.playSoundAtEntity(entitytntprimed, "random.fuse", 1.0F, 1.0F);
  104. }
  105. }
  106.  
  107. /**
  108. * Called when the block is clicked by a player. Args: x, y, z, entityPlayer
  109. */
  110. public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
  111. {
  112. super.onBlockClicked(par1World, par2, par3, par4, par5EntityPlayer);
  113. }
  114.  
  115. /**
  116. * Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
  117. * block.
  118. */
  119. public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
  120. {
  121. if (par5EntityPlayer.getCurrentEquippedItem() != null && par5EntityPlayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.shiftedIndex)
  122. {
  123. onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
  124. par1World.setBlockWithNotify(par2, par3, par4, 0);
  125. return true;
  126. }
  127. else
  128. {
  129. return super.blockActivated(par1World, par2, par3, par4, par5EntityPlayer);
  130. }
  131. }
  132.  
  133. /**
  134. * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
  135. * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
  136. */
  137. protected ItemStack createStackedBlock(int par1)
  138. {
  139. return null;
  140. }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment