Search in sources :

Example 66 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class EntityWhirlwind method onUpdate.

@Override
public void onUpdate() {
    if (currentTarget == null || new AMVector3(this).distanceSqTo(currentTarget) < 2)
        generateNewTarget();
    nav.tryMoveFlying(worldObj, this);
    if (this.ticksExisted > 140 && !this.worldObj.isRemote)
        this.setDead();
    tickCooldowns();
    super.onUpdate();
}
Also used : AMVector3(am2.api.math.AMVector3)

Example 67 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class EntityWhirlwind method generateNewTarget.

private void generateNewTarget() {
    EntityPlayer closest = null;
    for (Object player : this.worldObj.playerEntities) {
        if (closest == null || ((EntityPlayer) player).getDistanceSqToEntity(this) < this.getDistanceSqToEntity(closest)) {
            closest = (EntityPlayer) player;
        }
    }
    if (closest != null && this.getDistanceSqToEntity(closest) < 64D)
        currentTarget = new AMVector3(closest);
    else
        currentTarget = new AMVector3(this).add(new AMVector3(worldObj.rand.nextInt(10) - 5, 0, worldObj.rand.nextInt(10) - 5));
    nav.SetWaypoint(worldObj, (int) currentTarget.x, (int) currentTarget.y, (int) currentTarget.z, this);
}
Also used : AMVector3(am2.api.math.AMVector3) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 68 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class EntityAIPickup method updateTask.

@Override
public void updateTask() {
    Entity target = ExtendedProperties.For(host).getInanimateTarget();
    if (target == null)
        return;
    if (checkStuck()) {
        ExtendedProperties.For(host).setInanimateTarget(null);
        double x = host.posX + host.worldObj.rand.nextInt(8) - 4;
        double y = host.posY;
        double z = host.posZ + host.worldObj.rand.nextInt(8) - 4;
        while (host.worldObj.isAirBlock((int) x, (int) y, (int) z) && y > 5) {
            y--;
        }
        host.getNavigator().tryMoveToXYZ(x, y, z, 0.4f);
        resetTask();
        return;
    }
    if (lastLocation.distanceSqTo(new AMVector3(target)) > 4) {
        if (!host.getNavigator().tryMoveToEntityLiving(target, 0.4f) || !host.getEntitySenses().canSee(target)) {
            ExtendedProperties.For(host).setInanimateTarget(null);
            resetTask();
        }
    } else {
        host.addItemStackToInventory(((EntityItem) target).getEntityItem());
        target.setDead();
        ExtendedProperties.For(host).setInanimateTarget(null);
    }
}
Also used : Entity(net.minecraft.entity.Entity) AMVector3(am2.api.math.AMVector3)

Example 69 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class Attract method getClosestEntityToPointWithin.

private EntityLivingBase getClosestEntityToPointWithin(EntityLivingBase caster, World world, AMVector3 point, double radius) {
    AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(point.x - radius, point.y - radius, point.z - radius, point.x + radius, point.y + radius, point.z + radius);
    List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, bb);
    EntityLivingBase closest = null;
    for (EntityLivingBase e : entities) {
        if (e == caster)
            continue;
        if (closest == null || point.distanceSqTo(new AMVector3(e)) < point.distanceSqTo(new AMVector3(closest)))
            closest = e;
    }
    return closest;
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) AMVector3(am2.api.math.AMVector3) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 70 with AMVector3

use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.

the class BlockCrystalMarker method breakBlock.

@Override
public void breakBlock(World world, int x, int y, int z, Block oldBlock, int oldMeta) {
    TileEntityCrystalMarker crystalMarkerTE = GetTileEntity(world, x, y, z);
    TileEntityFlickerHabitat elementalAttunerTE = null;
    if (crystalMarkerTE != null) {
        AMVector3 elementalAttunerVector = crystalMarkerTE.getElementalAttuner();
        if (elementalAttunerVector != null) {
            elementalAttunerTE = GetElementalAttunerTileEntity(world, (int) elementalAttunerVector.x, (int) elementalAttunerVector.y, (int) elementalAttunerVector.z);
            if (elementalAttunerTE != null) {
                int operandType = world.getBlockMetadata(x, y, z);
                if (operandType == META_IN) {
                    elementalAttunerTE.removeInMarkerLocation(x, y, z);
                } else if (isOutputMarker(operandType)) {
                    elementalAttunerTE.removeOutMarkerLocation(x, y, z);
                }
            }
        }
    }
    super.breakBlock(world, x, y, z, oldBlock, oldMeta);
}
Also used : AMVector3(am2.api.math.AMVector3) TileEntityCrystalMarker(am2.blocks.tileentities.TileEntityCrystalMarker) TileEntityFlickerHabitat(am2.blocks.tileentities.TileEntityFlickerHabitat)

Aggregations

AMVector3 (am2.api.math.AMVector3)113 TileEntity (net.minecraft.tileentity.TileEntity)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)16 EntityLivingBase (net.minecraft.entity.EntityLivingBase)15 ArrayList (java.util.ArrayList)11 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)11 IPowerNode (am2.api.power.IPowerNode)10 Block (net.minecraft.block.Block)9 Entity (net.minecraft.entity.Entity)9 ItemStack (net.minecraft.item.ItemStack)9 NBTTagList (net.minecraft.nbt.NBTTagList)9 IInventory (net.minecraft.inventory.IInventory)8 PowerTypes (am2.api.power.PowerTypes)6 AMParticle (am2.particles.AMParticle)5 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)5 TileEntityCrystalMarker (am2.blocks.tileentities.TileEntityCrystalMarker)4 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)4 TileEntityFlickerHabitat (am2.blocks.tileentities.TileEntityFlickerHabitat)3 AMDataWriter (am2.network.AMDataWriter)3 ParticleFloatUpward (am2.particles.ParticleFloatUpward)3