1
0
forked from xjboss/KCauldronX
KCauldronX/patches/net/minecraft/entity/item/EntityTNTPrimed.java.patch

78 lines
2.4 KiB
Diff
Raw Normal View History

2015-03-22 17:38:04 +00:00
--- ../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_)
{
@@ -50,6 +54,7 @@
public void onUpdate()
{
+ if (worldObj.spigotConfig.currentPrimedTnt++ > worldObj.spigotConfig.maxTntTicksPerTick) { return; } // Spigot
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
@@ -68,12 +73,14 @@
2015-03-22 17:38:04 +00:00
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 +90,19 @@
2015-03-22 17:38:04 +00:00
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 +125,11 @@
2015-06-05 13:41:54 +00:00
{
return this.tntPlacedBy;
}
+
+ // Cauldron start
+ @Override
+ public boolean entityProjectileHook() {
2015-06-08 16:18:24 +00:00
+ return true;
2015-06-05 13:41:54 +00:00
+ }
+ // Cauldron end
}