Search in sources :

Example 6 with EntityExplosive

use of icbm.classic.content.entity.EntityExplosive 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)

Aggregations

EntityExplosive (icbm.classic.content.entity.EntityExplosive)6 Pos (com.builtbroken.mc.imp.transform.vector.Pos)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityExplosion (icbm.classic.content.entity.EntityExplosion)2 EntityLiving (net.minecraft.entity.EntityLiving)2 TileEntity (net.minecraft.tileentity.TileEntity)2 Cube (com.builtbroken.mc.imp.transform.region.Cube)1 EulerAngle (com.builtbroken.mc.imp.transform.rotation.EulerAngle)1 Location (com.builtbroken.mc.imp.transform.vector.Location)1 IBlast (icbm.classic.api.explosion.IBlast)1 BlastAntimatter (icbm.classic.content.blast.threaded.BlastAntimatter)1 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)1 EntityMissile (icbm.classic.content.entity.missile.EntityMissile)1 Pos (icbm.classic.lib.transform.vector.Pos)1 Block (net.minecraft.block.Block)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 IInventory (net.minecraft.inventory.IInventory)1 ItemStack (net.minecraft.item.ItemStack)1