Search in sources :

Example 6 with Explosion

use of net.minecraft.world.Explosion in project LogisticsPipes by RS485.

the class PipeMultiBlockTransportLogistics method handleTileReachedClient.

@Override
protected void handleTileReachedClient(LPTravelingItemClient arrivingItem, TileEntity tile, ForgeDirection dir) {
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreMultiBlockPipe) {
        passToNextPipe(arrivingItem, tile);
        return;
    } else if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        List<LogisticsTileGenericPipe> masterTile = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
        if (!masterTile.isEmpty()) {
            if (masterTile.size() > 1) {
                throw new UnsupportedOperationException();
            }
            passToNextPipe(arrivingItem, masterTile.get(0));
            return;
        }
    }
    Explosion explosion = new Explosion(this.getWorld(), null, this.getPipe().getX(), this.getPipe().getY(), this.getPipe().getZ(), 4.0F);
    explosion.isFlaming = false;
    explosion.isSmoking = true;
    explosion.doExplosionB(true);
}
Also used : Explosion(net.minecraft.world.Explosion) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) List(java.util.List)

Example 7 with Explosion

use of net.minecraft.world.Explosion in project ArsMagica2 by Mithion.

the class Explosions method processCommand.

@Override
public void processCommand(ICommandSender icommandsender, String[] astring) {
    EntityPlayer player = getCommandSenderAsPlayer(icommandsender);
    if (player.getCommandSenderName().equals("Moridrex") || player.getCommandSenderName().equals("Mithion")) {
        if (player.worldObj.rand.nextInt(10) < 5 || !player.worldObj.canBlockSeeTheSky((int) player.posX, (int) player.posY, (int) player.posZ)) {
            Explosion explosion = player.worldObj.newExplosion(null, player.posX, player.posY, player.posZ, 10, true, true);
            player.attackEntityFrom(DamageSource.setExplosionSource(explosion), 5000);
        } else {
            if (!player.worldObj.isRemote) {
                for (int i = 0; i < 25; ++i) {
                    EntityCreeper creeper = new EntityCreeper(player.worldObj);
                    creeper.setPosition(player.posX + player.worldObj.rand.nextInt(4) - 2, player.posY + 20, player.posZ + player.worldObj.rand.nextInt(4) - 2);
                    player.worldObj.spawnEntityInWorld(creeper);
                }
            }
        }
    } else {
        player.addChatMessage(new ChatComponentText("You aren't Moridrex..."));
    }
}
Also used : Explosion(net.minecraft.world.Explosion) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 8 with Explosion

use of net.minecraft.world.Explosion in project NetherEx by LogicTechCorp.

the class EntitySporeCreeper method explode.

private void explode() {
    dead = true;
    Explosion explosion = new ExplosionSpore(world, this, posX, posY, posZ, (float) explosionRadius, true, true);
    explosion.doExplosionA();
    explosion.doExplosionB(true);
    setDead();
    spawnLingeringCloud();
}
Also used : Explosion(net.minecraft.world.Explosion) ExplosionSpore(nex.world.ExplosionSpore)

Example 9 with Explosion

use of net.minecraft.world.Explosion in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunner method onExplosionA.

public static void onExplosionA(Explosion e) {
    Vector center = new Vector(e.explosionX, e.explosionY, e.explosionZ);
    World worldIn = e.worldObj;
    float radius = e.explosionSize;
    AxisAlignedBB toCheck = new AxisAlignedBB(center.X - radius, center.Y - radius, center.Z - radius, center.X + radius, center.Y + radius, center.Z + radius);
    List<PhysicsWrapperEntity> shipsNear = ValkyrienWarfareMod.physicsManager.getManagerForWorld(e.worldObj).getNearbyPhysObjects(toCheck);
    e.doExplosionA();
    // TODO: Make this compatible and shit!
    for (PhysicsWrapperEntity ship : shipsNear) {
        Vector inLocal = new Vector(center);
        RotationMatrices.applyTransform(ship.wrapping.coordTransform.wToLTransform, inLocal);
        // inLocal.roundToWhole();
        Explosion expl = new Explosion(ship.worldObj, null, inLocal.X, inLocal.Y, inLocal.Z, radius, false, false);
        double waterRange = .6D;
        boolean cancelDueToWater = false;
        for (int x = (int) Math.floor(expl.explosionX - waterRange); x <= Math.ceil(expl.explosionX + waterRange); x++) {
            for (int y = (int) Math.floor(expl.explosionY - waterRange); y <= Math.ceil(expl.explosionY + waterRange); y++) {
                for (int z = (int) Math.floor(expl.explosionZ - waterRange); z <= Math.ceil(expl.explosionZ + waterRange); z++) {
                    if (!cancelDueToWater) {
                        IBlockState state = e.worldObj.getBlockState(new BlockPos(x, y, z));
                        if (state.getBlock() instanceof BlockLiquid) {
                            cancelDueToWater = true;
                        }
                    }
                }
            }
        }
        expl.doExplosionA();
        double affectedPositions = 0D;
        for (Object o : expl.affectedBlockPositions) {
            BlockPos pos = (BlockPos) o;
            IBlockState state = ship.worldObj.getBlockState(pos);
            Block block = state.getBlock();
            if (!block.isAir(state, worldIn, (BlockPos) o) || ship.wrapping.explodedPositionsThisTick.contains((BlockPos) o)) {
                affectedPositions++;
            }
        }
        if (!cancelDueToWater) {
            for (Object o : expl.affectedBlockPositions) {
                BlockPos pos = (BlockPos) o;
                IBlockState state = ship.worldObj.getBlockState(pos);
                Block block = state.getBlock();
                if (!block.isAir(state, worldIn, (BlockPos) o) || ship.wrapping.explodedPositionsThisTick.contains((BlockPos) o)) {
                    if (block.canDropFromExplosion(expl)) {
                        block.dropBlockAsItemWithChance(ship.worldObj, pos, state, 1.0F / expl.explosionSize, 0);
                    }
                    block.onBlockExploded(ship.worldObj, pos, expl);
                    if (!worldIn.isRemote) {
                        Vector posVector = new Vector(pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5);
                        ship.wrapping.coordTransform.fromLocalToGlobal(posVector);
                        double mass = BlockMass.basicMass.getMassFromState(state, pos, ship.worldObj);
                        double explosionForce = Math.sqrt(e.explosionSize) * 1000D * mass;
                        Vector forceVector = new Vector(pos.getX() + .5 - expl.explosionX, pos.getY() + .5 - expl.explosionY, pos.getZ() + .5 - expl.explosionZ);
                        double vectorDist = forceVector.length();
                        forceVector.normalize();
                        forceVector.multiply(explosionForce / vectorDist);
                        RotationMatrices.doRotationOnly(ship.wrapping.coordTransform.lToWRotation, forceVector);
                        PhysicsQueuedForce queuedForce = new PhysicsQueuedForce(forceVector, posVector, false, 1);
                        if (!ship.wrapping.explodedPositionsThisTick.contains(pos)) {
                            ship.wrapping.explodedPositionsThisTick.add(pos);
                        }
                        ship.wrapping.queueForce(queuedForce);
                    }
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Explosion(net.minecraft.world.Explosion) IBlockState(net.minecraft.block.state.IBlockState) World(net.minecraft.world.World) BlockLiquid(net.minecraft.block.BlockLiquid) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) PhysicsQueuedForce(ValkyrienWarfareBase.Physics.PhysicsQueuedForce) Vector(ValkyrienWarfareBase.API.Vector)

Aggregations

Explosion (net.minecraft.world.Explosion)9 List (java.util.List)2 CoreMultiBlockPipe (logisticspipes.pipes.basic.CoreMultiBlockPipe)2 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)2 LogisticsTileGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)2 Vector (ValkyrienWarfareBase.API.Vector)1 PhysicsQueuedForce (ValkyrienWarfareBase.Physics.PhysicsQueuedForce)1 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 IEExplosion (blusunrize.immersiveengineering.common.util.IEExplosion)1 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)1 BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)1 Tile (com.builtbroken.mc.prefab.tile.Tile)1 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)1 Block (net.minecraft.block.Block)1 BlockLiquid (net.minecraft.block.BlockLiquid)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ChatComponentText (net.minecraft.util.ChatComponentText)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1