Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void doExplosionB(Explosion explosion, WorldServer world) {
- double posX = location.getX();
- double posY = location.getY();
- double posZ = location.getZ();
- Entity source = null;
- world.a(null, posX, posY, posZ, SoundEffects.bV, SoundCategory.BLOCKS, 4.0F, (1.0F + (world.random.nextFloat() - world.random.nextFloat()) * 0.2F) * 0.7F);
- if (power >= 2.0F && breakBlocks) {
- world.addParticle(EnumParticle.EXPLOSION_HUGE, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
- } else {
- world.addParticle(EnumParticle.EXPLOSION_LARGE, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
- }
- Iterator iterator;
- BlockPosition blockposition;
- if (breakBlocks) {
- org.bukkit.World bworld = world.getWorld();
- org.bukkit.entity.Entity explode = source == null ? null : source.getBukkitEntity();
- Location location = new Location(bworld, posX, posY, posZ);
- List<Block> blockList = Lists.newArrayList();
- for (int i1 = explosion.getBlocks().size() - 1; i1 >= 0; --i1) {
- BlockPosition cpos = explosion.getBlocks().get(i1);
- Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ());
- if (bblock.getType() != org.bukkit.Material.AIR) {
- blockList.add(bblock);
- }
- }
- boolean cancelled;
- List<Block> bukkitBlocks;
- if (explode != null) {
- EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, 1.0F / power);
- world.getServer().getPluginManager().callEvent(event);
- cancelled = event.isCancelled();
- bukkitBlocks = event.blockList();
- event.setYield(yield);
- } else {
- BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, 1.0F / power);
- world.getServer().getPluginManager().callEvent(event);
- cancelled = event.isCancelled();
- bukkitBlocks = event.blockList();
- event.setYield(yield);
- }
- explosion.getBlocks().clear();
- for (Block bukkitBlock : bukkitBlocks) {
- BlockPosition coords = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
- explosion.getBlocks().add(coords);
- }
- if (cancelled) {
- explosion.wasCanceled = true;
- return;
- }
- iterator = explosion.getBlocks().iterator();
- while (iterator.hasNext()) {
- blockposition = (BlockPosition) iterator.next();
- IBlockData iblockdata = world.getType(blockposition);
- net.minecraft.server.v1_12_R1.Block block = iblockdata.getBlock();
- if (particles) {
- double d0 = (float) blockposition.getX() + world.random.nextFloat();
- double d1 = (float) blockposition.getY() + world.random.nextFloat();
- double d2 = (float) blockposition.getZ() + world.random.nextFloat();
- double d3 = d0 - posX;
- double d4 = d1 - posY;
- double d5 = d2 - posZ;
- double d6 = MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
- d3 /= d6;
- d4 /= d6;
- d5 /= d6;
- double d7 = 0.5D / (d6 / (double) power + 0.1D);
- d7 *= world.random.nextFloat() * world.random.nextFloat() + 0.3F;
- d3 *= d7;
- d4 *= d7;
- d5 *= d7;
- world.addParticle(EnumParticle.EXPLOSION_NORMAL, (d0 + posX) / 2.0D, (d1 + posY) / 2.0D, (d2 + posZ) / 2.0D, d3, d4, d5);
- world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5);
- }
- if (iblockdata.getMaterial() != Material.AIR) {
- if (block.a(explosion)) {
- block.dropNaturally(world, blockposition, world.getType(blockposition), yield, 0);
- }
- world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
- block.wasExploded(world, blockposition, explosion);
- }
- }
- }
- if (fire) {
- iterator = explosion.getBlocks().iterator();
- while (iterator.hasNext()) {
- blockposition = (BlockPosition) iterator.next();
- 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()) {
- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement