Search in sources :

Example 31 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.

the class BlastEMP method doExplode.

@Override
public void doExplode() {
    if (!world().isRemote) {
        if (this.effectBlocks) {
            for (int x = (int) -this.getRadius(); x < (int) this.getRadius(); x++) {
                for (int y = (int) -this.getRadius(); y < (int) this.getRadius(); y++) {
                    for (int z = (int) -this.getRadius(); z < (int) this.getRadius(); z++) {
                        double dist = MathHelper.sqrt_double((x * x + y * y + z * z));
                        Pos searchPosition = new Pos(x, y, z).add(position);
                        if (dist > this.getRadius()) {
                            continue;
                        }
                        if (Math.round(position.x() + y) == position.yi()) {
                            world().spawnParticle("largesmoke", searchPosition.x(), searchPosition.y(), searchPosition.z(), 0, 0, 0);
                        }
                        Block block = searchPosition.getBlock(world());
                        TileEntity tileEntity = searchPosition.getTileEntity(world());
                        //TODO more EMP effect to UniversalEnergySystem to better support cross mod support
                        if (block != null) {
                            //}
                            if (block instanceof IEMPBlock) {
                                ((IEMPBlock) block).onEMP(world(), searchPosition.xi(), searchPosition.yi(), searchPosition.zi(), this);
                            }
                        }
                        if (tileEntity != null) {
                            //if (tileEntity instanceof IFortronStorage)
                            //{
                            //    ((IFortronStorage) tileEntity).provideFortron((int) world().rand.nextFloat() * ((IFortronStorage) tileEntity).getFortronCapacity(), true);
                            //}
                            UniversalEnergySystem.clearEnergy(tileEntity, true);
                        }
                    }
                }
            }
        }
        if (this.effectEntities) {
            // Drop all missiles
            List<Entity> entitiesNearby = RadarRegistry.getAllLivingObjectsWithin(world(), new Cube(position.sub(getRadius()), position.add(getRadius())), null);
            for (Entity entity : entitiesNearby) {
                if (entity instanceof IMissile && !entity.isEntityEqual(this.controller)) {
                    if (((IMissile) entity).getTicksInAir() > -1) {
                        ((IMissile) entity).dropMissileAsItem();
                    }
                }
            }
            int maxFx = 10;
            AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - this.getRadius(), position.y() - this.getRadius(), position.z() - this.getRadius(), position.x() + this.getRadius(), position.y() + this.getRadius(), position.z() + this.getRadius());
            List<Entity> entities = world().getEntitiesWithinAABB(Entity.class, bounds);
            for (Entity entity : entities) {
                if (entity instanceof EntityLivingBase) {
                    if (this.world().isRemote && maxFx > 0) {
                        ICBMClassic.proxy.spawnShock(this.world(), this.position, new Pos(entity), 20);
                        maxFx--;
                    }
                    if (entity instanceof EntityCreeper) {
                        if (!this.world().isRemote) {
                            try {
                                ((EntityCreeper) entity).getDataWatcher().updateObject(17, (byte) 1);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                    if (entity instanceof EntityPlayer) {
                        IInventory inventory = ((EntityPlayer) entity).inventory;
                        for (int i = 0; i < inventory.getSizeInventory(); i++) {
                            ItemStack itemStack = inventory.getStackInSlot(i);
                            if (itemStack != null) {
                                if (itemStack.getItem() instanceof IEMPItem) {
                                    ((IEMPItem) itemStack.getItem()).onEMP(itemStack, entity, this);
                                }
                                UniversalEnergySystem.clearEnergy(itemStack, true);
                            }
                        }
                    }
                } else if (entity instanceof EntityExplosive) {
                    entity.setDead();
                }
            }
        }
        VEProviderShockWave.spawnEffect(world(), position.x(), position.y(), position.z(), 0, 0, 0, 0, 0, 255, 1, 3);
        VEProviderShockWave.spawnEffect(world(), position.x(), position.y(), position.z(), 0, 0, 0, 0, 0, 255, 3, 3);
        VEProviderShockWave.spawnEffect(world(), position.x(), position.y(), position.z(), 0, 0, 0, 0, 0, 255, 5, 3);
        this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "emp", 4.0F, (1.0F + (world().rand.nextFloat() - world().rand.nextFloat()) * 0.2F) * 0.7F);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) IInventory(net.minecraft.inventory.IInventory) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) IEMPItem(resonant.api.explosion.IEMPItem) IEMPBlock(resonant.api.explosion.IEMPBlock) TileEntity(net.minecraft.tileentity.TileEntity) IMissile(resonant.api.explosion.IMissile) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) Pos(com.builtbroken.mc.imp.transform.vector.Pos) Cube(com.builtbroken.mc.imp.transform.region.Cube) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IEMPBlock(resonant.api.explosion.IEMPBlock) Block(net.minecraft.block.Block) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityExplosive(icbm.classic.content.entity.EntityExplosive) ItemStack(net.minecraft.item.ItemStack)

Example 32 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.

the class BlastAntiGravitational method doExplode.

@Override
public void doExplode() {
    int r = this.callCount;
    if (!this.world().isRemote && this.thread.isComplete) {
        if (r == 0) {
            Collections.sort(this.thread.results, new GravitationalBlockSorter(position));
        }
        int blocksToTake = 20;
        for (Pos targetPosition : this.thread.results) {
            double distance = targetPosition.distance(position);
            if (distance > r || distance < r - 2 || blocksToTake <= 0) {
                continue;
            }
            final Block block = targetPosition.getBlock(world());
            if (block != null) {
                float hardness = block.getBlockHardness(world(), targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
                if (hardness >= 0 && hardness < 1000) {
                    int metadata = world().getBlockMetadata(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
                    if (distance < r - 1 || world().rand.nextInt(3) > 0) {
                        //Remove block
                        this.world().setBlockToAir(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
                        blocksToTake--;
                        //Create flying block
                        EntityFlyingBlock entity = new EntityFlyingBlock(world(), targetPosition.add(0.5D), block, metadata, 0);
                        entity.yawChange = 50 * world().rand.nextFloat();
                        entity.pitchChange = 100 * world().rand.nextFloat();
                        entity.motionY += Math.max(0.15 * world().rand.nextFloat(), 0.1);
                        entity.noClip = true;
                        world().spawnEntityInWorld(entity);
                        //Track flying block
                        flyingBlocks.add(entity);
                    }
                }
            }
        }
    }
    int radius = (int) this.getRadius();
    AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - radius, position.y() - radius, position.z() - radius, position.y() + radius, 100, position.z() + radius);
    List<Entity> allEntities = world().getEntitiesWithinAABB(Entity.class, bounds);
    for (Entity entity : allEntities) {
        if (!(entity instanceof EntityFlyingBlock) && entity.posY < 100 + position.y()) {
            if (entity.motionY < 0.4) {
                entity.motionY += 0.15;
            }
        }
    }
    if (this.callCount > 20 * 120) {
        this.controller.endExplosion();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) Block(net.minecraft.block.Block) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock)

Example 33 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.

the class PoisonContagion method performEffect.

@Override
public void performEffect(EntityLivingBase entityLiving, int amplifier) {
    if (!(entityLiving instanceof EntityZombie) && !(entityLiving instanceof EntityPigZombie)) {
        entityLiving.attackEntityFrom(DamageSource.magic, 1);
    }
    if (entityLiving.worldObj.rand.nextFloat() > 0.8) {
        ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(entityLiving.worldObj, entityLiving.posX, entityLiving.posY, entityLiving.posZ, ExplosiveType.ALL, Explosives.CHEMICAL.handler);
        MinecraftForge.EVENT_BUS.post(evt);
        // Poison things around it
        if (!evt.isCanceled()) {
            int r = 13;
            AxisAlignedBB entitySurroundings = AxisAlignedBB.getBoundingBox(entityLiving.posX - r, entityLiving.posY - r, entityLiving.posZ - r, entityLiving.posX + r, entityLiving.posY + r, entityLiving.posZ + r);
            List<EntityLivingBase> entities = entityLiving.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, entitySurroundings);
            for (EntityLivingBase entity : entities) {
                if (entity != null && entity != entityLiving) {
                    if (entity instanceof EntityPig) {
                        EntityPigZombie newEntity = new EntityPigZombie(entity.worldObj);
                        newEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
                        if (!entity.worldObj.isRemote) {
                            entity.worldObj.spawnEntityInWorld(newEntity);
                        }
                        entity.setDead();
                    } else if (entity instanceof EntityVillager) {
                        EntityZombie newEntity = new EntityZombie(entity.worldObj);
                        newEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
                        newEntity.setVillager(true);
                        if (!entity.worldObj.isRemote) {
                            entity.worldObj.spawnEntityInWorld(newEntity);
                        }
                        entity.setDead();
                    }
                    ICBMClassic.contagios_potion.poisonEntity(new Pos(entity), entity);
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) EntityZombie(net.minecraft.entity.monster.EntityZombie) Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityPig(net.minecraft.entity.passive.EntityPig) EntityPigZombie(net.minecraft.entity.monster.EntityPigZombie) EntityVillager(net.minecraft.entity.passive.EntityVillager) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 34 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project SecurityCraft by Geforce132.

the class BlockPortableRadar method searchForPlayers.

public static void searchForPlayers(World par1World, int par2, int par3, int par4, double searchRadius) {
    if (!par1World.isRemote) {
        double d0 = (searchRadius);
        AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(par2, par3, par4, par2 + 1, par3 + 1, par4 + 1).expand(d0, d0, d0);
        axisalignedbb.maxY = par1World.getHeight();
        List<?> list = par1World.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
        Iterator<?> iterator = list.iterator();
        EntityPlayer entityplayer;
        if (list.isEmpty()) {
            if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE) && par1World.getBlockMetadata(par2, par3, par4) == 1) {
                togglePowerOutput(par1World, par2, par3, par4, false);
                return;
            }
        }
        while (iterator.hasNext()) {
            EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().func_152612_a(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getOwner().getName());
            entityplayer = (EntityPlayer) iterator.next();
            if (par1World.getTileEntity(par2, par3, par4) == null || !(par1World.getTileEntity(par2, par3, par4) instanceof CustomizableSCTE)) {
                continue;
            }
            if (((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(par1World, par2, par3, par4, EnumCustomModules.WHITELIST).contains(entityplayermp.getCommandSenderName().toLowerCase())) {
                continue;
            }
            if (PlayerUtils.isPlayerOnline(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getOwner().getName())) {
                if (!((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).shouldSendMessage(entityplayer)) {
                    continue;
                }
                PlayerUtils.sendMessageToPlayer(entityplayermp, StatCollector.translateToLocal("tile.portableRadar.name"), ((INameable) par1World.getTileEntity(par2, par3, par4)).hasCustomName() ? (StatCollector.translateToLocal("messages.portableRadar.withName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#n", EnumChatFormatting.ITALIC + ((INameable) par1World.getTileEntity(par2, par3, par4)).getCustomName() + EnumChatFormatting.RESET)) : (StatCollector.translateToLocal("messages.portableRadar.withoutName").replace("#p", EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET).replace("#l", Utils.getFormattedCoordinates(par2, par3, par4))), EnumChatFormatting.BLUE);
                ((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).setSentMessage();
            }
            if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE)) {
                togglePowerOutput(par1World, par2, par3, par4, true);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) INameable(net.geforcemods.securitycraft.api.INameable) TileEntityPortableRadar(net.geforcemods.securitycraft.tileentity.TileEntityPortableRadar) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 35 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project SecurityCraft by Geforce132.

the class TileEntityClaymore method updateEntity.

public void updateEntity() {
    if (getWorldObj().isRemote) {
        return;
    } else {
        if (getWorldObj().getBlock(xCoord, yCoord, zCoord) == mod_SecurityCraft.claymoreDefused) {
            return;
        }
        if (cooldown > 0) {
            cooldown--;
            return;
        }
        if (cooldown == 0) {
            BlockUtils.destroyBlock(getWorldObj(), xCoord, yCoord, zCoord, false);
            getWorldObj().createExplosion((Entity) null, entityX, entityY + 0.5F, entityZ, 3.5F, true);
            return;
        }
        int meta = getWorldObj().getBlockMetadata(xCoord, yCoord, zCoord);
        AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
        if (meta == 3) {
            axisalignedbb = axisalignedbb.addCoord(0, 0, -mod_SecurityCraft.configHandler.claymoreRange);
        } else if (meta == 1) {
            axisalignedbb = axisalignedbb.addCoord(0, 0, mod_SecurityCraft.configHandler.claymoreRange);
        } else if (meta == 2) {
            axisalignedbb = axisalignedbb.addCoord(mod_SecurityCraft.configHandler.claymoreRange, 0, 0);
        } else if (meta == 4) {
            axisalignedbb = axisalignedbb.addCoord(-mod_SecurityCraft.configHandler.claymoreRange, 0, 0);
        }
        List<?> list = getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
        Iterator<?> iterator = list.iterator();
        EntityLivingBase entityliving;
        while (iterator.hasNext()) {
            entityliving = (EntityLivingBase) iterator.next();
            entityX = entityliving.posX;
            entityY = entityliving.posY;
            entityZ = entityliving.posZ;
            cooldown = 20;
            getWorldObj().playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.click", 0.3F, 0.6F);
            break;
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Aggregations

AxisAlignedBB (net.minecraft.util.AxisAlignedBB)74 Entity (net.minecraft.entity.Entity)24 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)18 ItemStack (net.minecraft.item.ItemStack)15 TileEntity (net.minecraft.tileentity.TileEntity)14 ArrayList (java.util.ArrayList)13 Vec3 (net.minecraft.util.Vec3)13 List (java.util.List)11 EntityItem (net.minecraft.entity.item.EntityItem)11 Block (net.minecraft.block.Block)10 EntityLivingBase (net.minecraft.entity.EntityLivingBase)9 Pos (com.builtbroken.mc.imp.transform.vector.Pos)7 SideOnly (cpw.mods.fml.relauncher.SideOnly)7 Iterator (java.util.Iterator)4 LPPositionSet (logisticspipes.utils.LPPositionSet)4 World (net.minecraft.world.World)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)4 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)3