Search in sources :

Example 6 with ExplosivePreDetonationEvent

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);
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityExplosive(icbm.classic.content.entity.EntityExplosive)

Example 7 with ExplosivePreDetonationEvent

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();
}
Also used : ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) Pos(com.builtbroken.mc.imp.transform.vector.Pos)

Aggregations

ExplosivePreDetonationEvent (resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent)7 Pos (com.builtbroken.mc.imp.transform.vector.Pos)4 Explosives (icbm.classic.content.explosive.Explosives)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 TileEntity (net.minecraft.tileentity.TileEntity)2 RenderBombBlock (icbm.classic.client.render.tile.RenderBombBlock)1 EntityExplosive (icbm.classic.content.entity.EntityExplosive)1 EntityGrenade (icbm.classic.content.entity.EntityGrenade)1 EntityMissile (icbm.classic.content.entity.EntityMissile)1 Explosive (icbm.classic.content.explosive.Explosive)1 Explosion (icbm.classic.content.explosive.ex.Explosion)1 ItemBlockExplosive (icbm.classic.content.explosive.tile.ItemBlockExplosive)1 Block (net.minecraft.block.Block)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPigZombie (net.minecraft.entity.monster.EntityPigZombie)1 EntityZombie (net.minecraft.entity.monster.EntityZombie)1 EntityPig (net.minecraft.entity.passive.EntityPig)1 EntityVillager (net.minecraft.entity.passive.EntityVillager)1 ItemStack (net.minecraft.item.ItemStack)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1