2015-05-25 18:37:24 +08:00
|
|
|
--- a/net/minecraft/server/Explosion.java
|
|
|
|
+++ b/net/minecraft/server/Explosion.java
|
2015-03-23 03:42:46 +08:00
|
|
|
@@ -9,6 +9,13 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Random;
|
2015-02-27 06:41:06 +08:00
|
|
|
|
2014-11-26 05:32:16 +08:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.event.entity.EntityExplodeEvent;
|
|
|
|
+import org.bukkit.Location;
|
2015-03-23 03:42:46 +08:00
|
|
|
+import org.bukkit.event.block.BlockExplodeEvent;
|
2014-11-26 05:32:16 +08:00
|
|
|
+// CraftBukkit end
|
2015-02-27 06:41:06 +08:00
|
|
|
+
|
2014-11-26 05:32:16 +08:00
|
|
|
public class Explosion {
|
|
|
|
|
2015-02-27 06:41:06 +08:00
|
|
|
private final boolean a;
|
2015-06-06 17:33:48 +08:00
|
|
|
@@ -22,11 +29,12 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
private final float size;
|
2015-02-27 06:41:06 +08:00
|
|
|
private final List<BlockPosition> blocks = Lists.newArrayList();
|
|
|
|
private final Map<EntityHuman, Vec3D> k = Maps.newHashMap();
|
2014-11-26 05:32:16 +08:00
|
|
|
+ public boolean wasCanceled = false; // CraftBukkit - add field
|
|
|
|
|
|
|
|
public Explosion(World world, Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
|
|
|
|
this.world = world;
|
|
|
|
this.source = entity;
|
|
|
|
- this.size = f;
|
|
|
|
+ this.size = (float) Math.max(f, 0.0); // CraftBukkit - clamp bad values
|
|
|
|
this.posX = d0;
|
|
|
|
this.posY = d1;
|
|
|
|
this.posZ = d2;
|
2015-03-23 03:42:46 +08:00
|
|
|
@@ -35,6 +43,11 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a() {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (this.size < 0.1F) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
HashSet hashset = Sets.newHashSet();
|
|
|
|
boolean flag = true;
|
|
|
|
|
2015-03-23 03:42:46 +08:00
|
|
|
@@ -68,7 +81,7 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
f -= (f2 + 0.3F) * 0.3F;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (f > 0.0F && (this.source == null || this.source.a(this, this.world, blockposition, iblockdata, f))) {
|
|
|
|
+ if (f > 0.0F && (this.source == null || this.source.a(this, this.world, blockposition, iblockdata, f)) && blockposition.getY() < 256 && blockposition.getY() >= 0) { // CraftBukkit - don't wrap explosions
|
|
|
|
hashset.add(blockposition);
|
|
|
|
}
|
|
|
|
|
2015-03-23 03:42:46 +08:00
|
|
|
@@ -112,7 +125,14 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
double d12 = (double) this.world.a(vec3d, entity.getBoundingBox());
|
|
|
|
double d13 = (1.0D - d7) * d12;
|
|
|
|
|
2015-01-25 07:45:02 +08:00
|
|
|
- entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 8.0D * (double) f3 + 1.0D)));
|
2015-02-27 06:41:06 +08:00
|
|
|
+ // entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 8.0D * (double) f3 + 1.0D)));+ // CraftBukkit start
|
2014-11-26 05:32:16 +08:00
|
|
|
+ CraftEventFactory.entityDamage = source;
|
2015-01-25 07:45:02 +08:00
|
|
|
+ boolean wasDamaged = entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 8.0D * (double) f3 + 1.0D)));
|
2014-11-26 05:32:16 +08:00
|
|
|
+ CraftEventFactory.entityDamage = null;
|
2015-02-01 13:13:17 +08:00
|
|
|
+ if (!wasDamaged && !(entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock)) {
|
2015-01-25 07:45:02 +08:00
|
|
|
+ continue;
|
|
|
|
+ }
|
2014-11-26 05:32:16 +08:00
|
|
|
+ // CraftBukkit end
|
|
|
|
double d14 = EnchantmentProtection.a(entity, d13);
|
|
|
|
|
|
|
|
entity.motX += d8 * d14;
|
2015-03-23 03:42:46 +08:00
|
|
|
@@ -140,6 +160,50 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
BlockPosition blockposition;
|
|
|
|
|
|
|
|
if (this.b) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.World bworld = this.world.getWorld();
|
|
|
|
+ org.bukkit.entity.Entity explode = this.source == null ? null : this.source.getBukkitEntity();
|
|
|
|
+ Location location = new Location(bworld, this.posX, this.posY, this.posZ);
|
|
|
|
+
|
|
|
|
+ List<org.bukkit.block.Block> blockList = Lists.newArrayList();
|
|
|
|
+ for (int i1 = this.blocks.size() - 1; i1 >= 0; i1--) {
|
|
|
|
+ BlockPosition cpos = (BlockPosition) this.blocks.get(i1);
|
|
|
|
+ org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ());
|
|
|
|
+ if (bblock.getType() != org.bukkit.Material.AIR) {
|
|
|
|
+ blockList.add(bblock);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2015-03-23 03:42:46 +08:00
|
|
|
+ boolean cancelled;
|
|
|
|
+ List<org.bukkit.block.Block> bukkitBlocks;
|
|
|
|
+ float yield;
|
|
|
|
+
|
|
|
|
+ if (explode != null) {
|
|
|
|
+ EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, 0.3F);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ cancelled = event.isCancelled();
|
|
|
|
+ bukkitBlocks = event.blockList();
|
|
|
|
+ yield = event.getYield();
|
|
|
|
+ } else {
|
|
|
|
+ BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, 0.3F);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ cancelled = event.isCancelled();
|
|
|
|
+ bukkitBlocks = event.blockList();
|
|
|
|
+ yield = event.getYield();
|
|
|
|
+ }
|
2014-11-26 05:32:16 +08:00
|
|
|
+
|
|
|
|
+ this.blocks.clear();
|
|
|
|
+
|
2015-03-23 03:42:46 +08:00
|
|
|
+ for (org.bukkit.block.Block bblock : bukkitBlocks) {
|
2014-11-26 05:32:16 +08:00
|
|
|
+ BlockPosition coords = new BlockPosition(bblock.getX(), bblock.getY(), bblock.getZ());
|
|
|
|
+ blocks.add(coords);
|
|
|
|
+ }
|
|
|
|
+
|
2015-03-23 03:42:46 +08:00
|
|
|
+ if (cancelled) {
|
2014-11-26 05:32:16 +08:00
|
|
|
+ this.wasCanceled = true;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
iterator = this.blocks.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
2015-03-23 03:42:46 +08:00
|
|
|
@@ -170,7 +234,8 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
|
|
|
|
if (block.getMaterial() != Material.AIR) {
|
|
|
|
if (block.a(this)) {
|
|
|
|
- block.dropNaturally(this.world, blockposition, this.world.getType(blockposition), 1.0F / this.size, 0);
|
|
|
|
+ // CraftBukkit - add yield
|
2015-03-23 03:42:46 +08:00
|
|
|
+ block.dropNaturally(this.world, blockposition, this.world.getType(blockposition), yield, 0);
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
|
2015-03-23 03:42:46 +08:00
|
|
|
@@ -185,7 +250,11 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
blockposition = (BlockPosition) iterator.next();
|
2015-02-27 06:41:06 +08:00
|
|
|
if (this.world.getType(blockposition).getBlock().getMaterial() == Material.AIR && this.world.getType(blockposition.down()).getBlock().o() && this.c.nextInt(3) == 0) {
|
2014-11-26 05:32:16 +08:00
|
|
|
- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
|
|
|
+ // CraftBukkit start - Ignition by explosion
|
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
|
|
|
|
+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-26 16:48:53 +08:00
|
|
|
@@ -197,7 +266,10 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityLiving c() {
|
|
|
|
- return this.source == null ? null : (this.source instanceof EntityTNTPrimed ? ((EntityTNTPrimed) this.source).getSource() : (this.source instanceof EntityLiving ? (EntityLiving) this.source : null));
|
|
|
|
+ // CraftBukkit start - obtain Fireball shooter for explosion tracking
|
|
|
|
+ // PAIL: Rename
|
|
|
|
+ return this.source == null ? null : (this.source instanceof EntityTNTPrimed ? ((EntityTNTPrimed) this.source).getSource() : (this.source instanceof EntityLiving ? (EntityLiving) this.source : (this.source instanceof EntityFireball ? ((EntityFireball) this.source).shooter : null)));
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void clearBlocks() {
|