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();
}
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);
}
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);
}
}
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;
}
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);
}
Aggregations