use of resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent in project ICBM-Classic by BuiltBrokenModding.
the class BlockExplosive method triggerExplosive.
/*
* Called to detonate the TNT. Args: world, x, y, z, metaData, CauseOfExplosion (0, intentional,
* 1, exploded, 2 burned)
*/
public static void triggerExplosive(World world, int x, int y, int z, Explosives explosiveID, int causeOfExplosion) {
if (!world.isRemote) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
if (tileEntity instanceof TileEntityExplosive) {
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, x, y, z, ExplosiveType.BLOCK, ((TileEntityExplosive) tileEntity).explosive.handler);
MinecraftForge.EVENT_BUS.post(evt);
if (!evt.isCanceled()) {
((TileEntityExplosive) tileEntity).exploding = true;
EntityExplosive eZhaDan = new EntityExplosive(world, new Pos(x, y, z).add(0.5), ((TileEntityExplosive) tileEntity).explosive, (byte) world.getBlockMetadata(x, y, z), ((TileEntityExplosive) tileEntity).nbtData);
switch(causeOfExplosion) {
case 2:
eZhaDan.setFire(100);
break;
}
world.spawnEntityInWorld(eZhaDan);
world.setBlockToAir(x, y, z);
}
}
}
}
}
use of resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent in project ICBM-Classic by BuiltBrokenModding.
the class EntityExplosive method onUpdate.
/** Called to update the entity's position/logic. */
@Override
public void onUpdate() {
if (!this.worldObj.isRemote) {
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(worldObj, posX, posY, posZ, ExplosiveType.BLOCK, explosiveID.handler);
MinecraftForge.EVENT_BUS.post(evt);
if (evt.isCanceled()) {
ICBMClassic.blockExplosive.dropBlockAsItem(this.worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, this.explosiveID.ordinal(), 0);
this.setDead();
return;
}
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionX *= 0.95;
this.motionY -= 0.045D;
this.motionZ *= 0.95;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
if (this.fuse < 1) {
this.explode();
} else {
this.explosiveID.handler.onYinZha(this.worldObj, new Pos(this.posX, this.posY, this.posZ), this.fuse);
}
this.fuse--;
super.onUpdate();
}
Aggregations