use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class EntitySpellEffect method blizzardUpdate.
private void blizzardUpdate() {
float radius = this.dataWatcher.getWatchableObjectFloat(WATCHER_RADIUS);
if (worldObj.isRemote) {
if (spellStack == null) {
spellStack = this.dataWatcher.getWatchableObjectItemStack(22);
if (spellStack == null) {
return;
}
}
int color = 0xFFFFFF;
if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, spellStack, 0)) {
ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(spellStack, 0);
int ordinalCount = 0;
for (ISpellModifier mod : mods) {
if (mod instanceof Colour) {
byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(spellStack, mod, 0, ordinalCount++);
color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
}
}
}
for (int i = 0; i < 20; ++i) {
double x = this.posX - radius + (rand.nextDouble() * radius * 2);
double z = this.posZ - radius + (rand.nextDouble() * radius * 2);
double y = this.posY + 10;
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "snowflakes", x, y, z);
if (particle != null) {
particle.setMaxAge(20);
particle.setParticleScale(0.1f);
particle.addVelocity(rand.nextDouble() * 0.2f - 0.1f, 0, rand.nextDouble() * 0.2f - 0.1f);
particle.setAffectedByGravity();
particle.setRGBColorI(color);
particle.setDontRequireControllers();
particle.noClip = false;
}
}
double x = this.posX - radius + (rand.nextDouble() * radius * 2);
double z = this.posZ - radius + (rand.nextDouble() * radius * 2);
double y = this.posY + rand.nextDouble();
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "smoke", x, y, z);
if (particle != null) {
particle.setParticleScale(2.0f);
particle.setMaxAge(20);
// particle.setRGBColorF(0.5f, 0.92f, 0.92f);
particle.setRGBColorF(0.5098f, 0.7843f, 0.7843f);
particle.SetParticleAlpha(0.6f);
particle.AddParticleController(new ParticleFleePoint(particle, new AMVector3(x, y, z), 0.1f, 3f, 1, false));
}
// TODO: SoundHelper.instance.loopSound(worldObj, (float)posX, (float)posY, (float)posZ, "arsmagica2:spell.loop.air", 1.0f);
} else {
List<Entity> possibleTargets = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(posX - radius, posY - 1, posZ - radius, posX + radius, posY + 3, posZ + radius));
for (Entity e : possibleTargets) {
if (e != dummycaster) {
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
if (e instanceof EntityLivingBase)
((EntityLivingBase) e).addPotionEffect(new BuffEffectFrostSlowed(80, 3));
float damage = 1 * this.dataWatcher.getWatchableObjectFloat(WATCHER_DAMAGEBONUS);
double lastVelX = e.motionX;
double lastVelY = e.motionY;
double lastVelZ = e.motionZ;
if (SpellHelper.instance.attackTargetSpecial(null, e, DamageSources.causeEntityFrostDamage(dummycaster), damage) && !(e instanceof EntityPlayer))
e.hurtResistantTime = 15;
e.addVelocity(-(e.motionX - lastVelX), -(e.motionY - lastVelY), -(e.motionZ - lastVelZ));
}
}
if (rand.nextInt(10) < 2) {
int pX = (int) (posX - radius + rand.nextInt((int) Math.ceil(radius) * 2));
int pY = (int) posY + rand.nextInt(2);
int pZ = (int) (posZ - radius + rand.nextInt((int) Math.ceil(radius) * 2));
if (worldObj.isAirBlock(pX, pY, pZ) && !worldObj.isAirBlock(pX, pY - 1, pZ) && worldObj.getBlock(pX, pY, pZ).isOpaqueCube())
worldObj.setBlock(pX, pY, pZ, Blocks.snow);
}
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class EntitySpellProjectile method findHomingTarget.
private void findHomingTarget() {
List<EntityLivingBase> entities = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(this.posX - 15, this.posY - 15, this.posZ - 15, this.posX + 15, this.posY + 15, this.posZ + 15));
EntityLivingBase closest = null;
double curShortestDistance = 900;
AMVector3 me = new AMVector3(this);
for (EntityLivingBase e : entities) {
if (e == this.getShootingEntity())
continue;
double distance = new AMVector3(e).distanceSqTo(me);
if (distance < curShortestDistance) {
curShortestDistance = distance;
closest = e;
}
}
if (closest != null) {
setHomingTarget(closest);
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class EntityFlicker method updateEntityActionState.
@Override
protected void updateEntityActionState() {
super.updateEntityActionState();
AMVector3 me = new AMVector3(this);
boolean needsNewPath = targetPosition == null || this.ticksExisted % DIRECTION_CHANGE_TIME == 0;
if (needsNewPath && worldObj.rand.nextDouble() < 0.1f)
pickNewTargetPosition();
if (// this represents the pause state in between picking new waypoints
targetPosition == null)
return;
if (me.distanceSqTo(targetPosition) < 1f) {
targetPosition = null;
return;
}
this.rotationYaw = AMVector3.anglePreNorm(me, targetPosition);
normalizedMovementVector = me.copy().sub(targetPosition).normalize();
if (normalizedMovementVector.y > 0)
rotatePitchTowards(-70 * normalizedMovementVector.y, 30);
else
rotatePitchTowards(0, 30);
float speed = 0.2f;
this.addVelocity(-normalizedMovementVector.x * speed, -normalizedMovementVector.y * speed, -normalizedMovementVector.z * speed);
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class EntityAIPickup method checkStuck.
private boolean checkStuck() {
AMVector3 loc = new AMVector3(host);
if (lastLocation == null) {
lastLocation = loc;
return false;
}
if (lastLocation.distanceSqTo(loc) < 1) {
stuckTicks++;
if (stuckTicks > 40) {
return true;
}
}
lastLocation = loc;
return false;
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class PowerNodePathfinder method generateSuccessors.
@Override
protected List<AMVector3> generateSuccessors(AMVector3 node) {
IPowerNode powerNode = getPowerNode(world, node);
if (powerNode == null)
return new ArrayList<AMVector3>();
IPowerNode[] candidates = PowerNodeRegistry.For(world).getAllNearbyNodes(world, node, powerType);
ArrayList<AMVector3> prunedCandidates = new ArrayList<AMVector3>();
for (IPowerNode candidate : candidates) {
if (verifyCandidate(candidate)) {
prunedCandidates.add(new AMVector3((TileEntity) candidate));
}
}
return prunedCandidates;
}
Aggregations