Advertisement
riking

fallingblock holder

May 2nd, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.kpdus.com/jad.html
  3. // Decompiler options: packimports(3) braces deadcode fieldsfirst
  4.  
  5. package net.minecraft.src;
  6.  
  7.  
  8. // Referenced classes of package net.minecraft.src:
  9. // Entity, MathHelper, World, Block,
  10. // BlockPistonMoving, BlockSand, NBTTagCompound
  11.  
  12. public class ExplosivesPlusFallingBlock //extends Entity // Nope, this is our custom class.
  13. {
  14.  
  15. public int blockID;
  16. // public int fallTime;
  17. public Entity nova;
  18. public double posX, posY, posZ;
  19. public double prevPosX, prevPosY, prevPosZ;
  20. public short failed; // If it failed somehow, or has deposited
  21. // 0 = still going
  22. // 1 = deposited block
  23. // 2 = block destroyed
  24. public boolean canDrop; // If it is allowed to deposit block
  25.  
  26. /* public ExplosivesPlusEntityFallingBlocks(World world)
  27. {
  28. super(world);
  29. fallTime = 0;
  30. } */ // Will never use
  31.  
  32. public ExplosivesPlusEntityFallingBlocks(World world, Entity bomb, double x, double y, double z, int blockid)
  33. {
  34. if (blockid == 0)
  35. {
  36. throw new IllegalArgumentException("Block holder created with id = air!");
  37. }
  38. //super(world); // NOTE: check if Entity does anything you e
  39. // fallTime = 0;
  40. setSize(0.98F, 0.98F);
  41. yOffset = height / 2.0F;
  42. // setPosition(d + 0.5, d1, d2 + 0.5);
  43. posX = x+0.5; posY = y; posZ = z+0.5;
  44. motionX = 0.0D;
  45. motionY = 0.0D;
  46. motionZ = 0.0D;
  47. prevPosX = x;
  48. prevPosY = y; // may want to check this..
  49. prevPosZ = z;
  50. nova = bomb;
  51. failed = 0;
  52. blockID = blockid;
  53. canDrop = false;
  54. }
  55.  
  56. public void setCanDrop(boolean HighYield, Random rand)
  57. {
  58. if(!HighYield)
  59. {
  60. if (rand.random() > mod_ExplosivesPlus.lowYieldReturnRate)
  61. {
  62. System.out.println("Falling Block Entity Failed to Survive: Enable High Yield Novas for a Higher Yield");
  63. failed = 2;
  64. }
  65. }
  66. canDrop = true;
  67. }
  68.  
  69. public void onUpdate()
  70. {
  71. if (failed != 0) return;
  72. // if(blockID == 0)
  73. // {
  74. // setDead();
  75. // System.out.println("Fail Type 2");
  76. // return;
  77. // }
  78. prevPosX = posX;
  79. prevPosY = posY;
  80. prevPosZ = posZ;
  81. // fallTime++;
  82. motionY -= mod_ExplosivesPlus.FallingBlockSpeed; // motionY -= 0.009999999105930328D;
  83. // !!!!!!!!!!!!! moveEntity(motionX, motionY, motionZ);
  84. motionX *= 0.98000001907348633D;
  85. motionY *= 0.98000001907348633D;
  86. motionZ *= 0.98000001907348633D;
  87. int i = MathHelper.floor_double(posX);
  88. int j = MathHelper.floor_double(posY);
  89. int k = MathHelper.floor_double(posZ);
  90. // if(fallTime == 1 && worldObj.getBlockId(i, j, k) == blockID)
  91. // {
  92. // worldObj.setBlockWithNotify(i, j, k, 0);
  93. // } else
  94.  
  95. // if(fallTime == 1 && !mod_ExplosivesPlus.HighYieldNova)
  96. // {
  97. // setDead();
  98. // System.out.println("Falling Block Entity Failed to Survive: Enable High Yield Novas for a Higher Yield");
  99.  
  100. // }
  101.  
  102. if(onGround && canDrop) //!!!!!!!! Need to set onGround
  103. {
  104. if(worldObj.getBlockId(i, j, k) != Block.pistonMoving.blockID)
  105. {
  106. setPosition(i, j, k);
  107. worldObj.setBlockWithNotify(i, j, k, blockID);
  108. failed = 1;
  109. }
  110. }
  111. }
  112.  
  113. protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
  114. {
  115. nbttagcompound.setByte("Tile", (byte)blockID);
  116. }
  117.  
  118. protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
  119. {
  120. blockID = nbttagcompound.getByte("Tile") & 0xff;
  121. }
  122.  
  123. public World getWorld()
  124. {
  125. return worldObj;
  126. }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement