1
0
forked from xjboss/KCauldronX
KCauldronX/patches/net/minecraft/entity/item/EntityTNTPrimed.java.patch
2015-06-05 20:41:54 +07:00

70 lines
2.1 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/item/EntityTNTPrimed.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityTNTPrimed.java
@@ -7,11 +7,15 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+
public class EntityTNTPrimed extends Entity
{
public int fuse;
private EntityLivingBase tntPlacedBy;
private static final String __OBFID = "CL_00001681";
+ public float yield = 4; // CraftBukkit
+ public boolean isIncendiary = false; // CraftBukkit
public EntityTNTPrimed(World p_i1729_1_)
{
@@ -68,12 +72,14 @@
if (this.fuse-- <= 0)
{
- this.setDead();
-
+ // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
if (!this.worldObj.isRemote)
{
this.explode();
}
+
+ this.setDead();
+ // CraftBukkit end
}
else
{
@@ -83,8 +89,19 @@
private void explode()
{
- float f = 4.0F;
- this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);
+ // CraftBukkit start
+ // float f = 4.0F;
+ org.bukkit.craftbukkit.CraftServer server = this.worldObj.getServer();
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.CraftEntity.getEntity(server, this));
+ server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ // give 'this' instead of (Entity) null so we know what causes the damage
+ this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, event.getRadius(), event.getFire(), true);
+ }
+
+ // CraftBukkit end
}
protected void writeEntityToNBT(NBTTagCompound p_70014_1_)
@@ -107,4 +124,11 @@
{
return this.tntPlacedBy;
}
+
+ // Cauldron start
+ @Override
+ public boolean entityProjectileHook() {
+ return true;
+ }
+ // Cauldron end
}