Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.02 KB | None | 0 0
  1.  
  2. public void doExplosionB(Explosion explosion, WorldServer world) {
  3. double posX = location.getX();
  4. double posY = location.getY();
  5. double posZ = location.getZ();
  6. Entity source = null;
  7. world.a(null, posX, posY, posZ, SoundEffects.bV, SoundCategory.BLOCKS, 4.0F, (1.0F + (world.random.nextFloat() - world.random.nextFloat()) * 0.2F) * 0.7F);
  8. if (power >= 2.0F && breakBlocks) {
  9. world.addParticle(EnumParticle.EXPLOSION_HUGE, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
  10. } else {
  11. world.addParticle(EnumParticle.EXPLOSION_LARGE, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
  12. }
  13.  
  14. Iterator iterator;
  15. BlockPosition blockposition;
  16. if (breakBlocks) {
  17. org.bukkit.World bworld = world.getWorld();
  18. org.bukkit.entity.Entity explode = source == null ? null : source.getBukkitEntity();
  19. Location location = new Location(bworld, posX, posY, posZ);
  20. List<Block> blockList = Lists.newArrayList();
  21.  
  22. for (int i1 = explosion.getBlocks().size() - 1; i1 >= 0; --i1) {
  23. BlockPosition cpos = explosion.getBlocks().get(i1);
  24. Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ());
  25. if (bblock.getType() != org.bukkit.Material.AIR) {
  26. blockList.add(bblock);
  27. }
  28. }
  29.  
  30. boolean cancelled;
  31. List<Block> bukkitBlocks;
  32. if (explode != null) {
  33. EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, 1.0F / power);
  34. world.getServer().getPluginManager().callEvent(event);
  35. cancelled = event.isCancelled();
  36. bukkitBlocks = event.blockList();
  37. event.setYield(yield);
  38. } else {
  39. BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, 1.0F / power);
  40. world.getServer().getPluginManager().callEvent(event);
  41. cancelled = event.isCancelled();
  42. bukkitBlocks = event.blockList();
  43. event.setYield(yield);
  44. }
  45.  
  46. explosion.getBlocks().clear();
  47.  
  48. for (Block bukkitBlock : bukkitBlocks) {
  49. BlockPosition coords = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
  50. explosion.getBlocks().add(coords);
  51. }
  52.  
  53. if (cancelled) {
  54. explosion.wasCanceled = true;
  55. return;
  56. }
  57.  
  58. iterator = explosion.getBlocks().iterator();
  59.  
  60. while (iterator.hasNext()) {
  61. blockposition = (BlockPosition) iterator.next();
  62. IBlockData iblockdata = world.getType(blockposition);
  63. net.minecraft.server.v1_12_R1.Block block = iblockdata.getBlock();
  64. if (particles) {
  65. double d0 = (float) blockposition.getX() + world.random.nextFloat();
  66. double d1 = (float) blockposition.getY() + world.random.nextFloat();
  67. double d2 = (float) blockposition.getZ() + world.random.nextFloat();
  68. double d3 = d0 - posX;
  69. double d4 = d1 - posY;
  70. double d5 = d2 - posZ;
  71. double d6 = MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
  72. d3 /= d6;
  73. d4 /= d6;
  74. d5 /= d6;
  75. double d7 = 0.5D / (d6 / (double) power + 0.1D);
  76. d7 *= world.random.nextFloat() * world.random.nextFloat() + 0.3F;
  77. d3 *= d7;
  78. d4 *= d7;
  79. d5 *= d7;
  80. world.addParticle(EnumParticle.EXPLOSION_NORMAL, (d0 + posX) / 2.0D, (d1 + posY) / 2.0D, (d2 + posZ) / 2.0D, d3, d4, d5);
  81. world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5);
  82. }
  83.  
  84. if (iblockdata.getMaterial() != Material.AIR) {
  85. if (block.a(explosion)) {
  86. block.dropNaturally(world, blockposition, world.getType(blockposition), yield, 0);
  87. }
  88.  
  89. world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
  90. block.wasExploded(world, blockposition, explosion);
  91. }
  92. }
  93. }
  94.  
  95. if (fire) {
  96. iterator = explosion.getBlocks().iterator();
  97.  
  98. while (iterator.hasNext()) {
  99. blockposition = (BlockPosition) iterator.next();
  100. if (world.getType(blockposition).getMaterial() == Material.AIR && world.getType(blockposition.down()).b() && RANDOM.nextInt(3) == 0 && !CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), explosion).isCancelled()) {
  101. world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
  102. }
  103. }
  104. }
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement