use of am2.particles.ParticleMoveOnHeading in project ArsMagica2 by Mithion.
the class ParticleManagerClient method spawnAuraParticles.
@Override
public void spawnAuraParticles(EntityLivingBase ent) {
if (!ent.worldObj.isRemote)
return;
int particleIndex = 15;
int particleBehaviour = 0;
float particleScale = 0;
float particleAlpha = 0;
boolean particleDefaultColor = true;
boolean particleRandomColor = true;
int particleColor = 0xFFFFFF;
int particleQuantity = 2;
float particleSpeed = 0.02f;
if (Minecraft.getMinecraft().thePlayer == ent) {
particleIndex = AMCore.config.getAuraIndex();
particleBehaviour = AMCore.config.getAuraBehaviour();
particleScale = AMCore.config.getAuraScale() / 10;
particleAlpha = AMCore.config.getAuraAlpha();
particleDefaultColor = AMCore.config.getAuraColorDefault();
particleRandomColor = AMCore.config.getAuraColorRandom();
particleColor = AMCore.config.getAuraColor();
particleQuantity = AMCore.config.getAuraQuantity();
particleSpeed = AMCore.config.getAuraSpeed() / 10;
} else {
ExtendedProperties entProperties = ExtendedProperties.For(ent);
particleIndex = entProperties.getAuraIndex();
particleBehaviour = entProperties.getAuraBehaviour();
particleScale = entProperties.getAuraScale() / 10;
particleAlpha = entProperties.getAuraAlpha();
particleDefaultColor = entProperties.getAuraColorDefault();
particleRandomColor = entProperties.getAuraColorRandomize();
particleColor = entProperties.getAuraColor();
particleQuantity = entProperties.getAuraQuantity();
particleSpeed = entProperties.getAuraSpeed() / 10;
}
if (//fix radiant particle's scaling issues...
particleIndex == 31)
particleScale /= 10;
if (ent.worldObj.isRemote && ent instanceof EntityPlayer && AMCore.proxy.playerTracker.hasAA((EntityPlayer) ent)) {
if (Minecraft.getMinecraft().thePlayer != ent || Minecraft.getMinecraft().gameSettings.thirdPersonView > 0) {
if (AMParticle.particleTypes[particleIndex].startsWith("lightning_bolts")) {
int type = Integer.parseInt(new String(new char[] { AMParticle.particleTypes[particleIndex].charAt(AMParticle.particleTypes[particleIndex].length() - 1) }));
if (ent.worldObj.rand.nextInt(100) < 90) {
BoltFromPointToPoint(ent.worldObj, ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - ent.height + (ent.worldObj.rand.nextFloat() * ent.height), ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f), ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - ent.height + (ent.worldObj.rand.nextFloat() * ent.height), ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f), type, -1);
} else {
BoltFromPointToPoint(ent.worldObj, ent.posX, ent.posY + ent.getEyeHeight() - 0.4, ent.posZ, ent.posX + (ent.worldObj.rand.nextFloat() * 10 - 5), ent.posY + (ent.worldObj.rand.nextFloat() * 10 - 5), ent.posZ + (ent.worldObj.rand.nextFloat() * 10 - 5), type, -1);
}
} else {
int offset = 0;
for (int i = 0; i < particleQuantity; ++i) {
AMParticle effect = spawn(ent.worldObj, AMParticle.particleTypes[particleIndex], ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - 0.5f + offset - (ent.worldObj.rand.nextFloat() * 0.5), ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f));
if (effect != null) {
effect.setIgnoreMaxAge(false);
effect.setMaxAge(40);
effect.setParticleScale(particleScale);
effect.SetParticleAlpha(particleAlpha);
effect.noClip = false;
if (!particleDefaultColor) {
if (particleRandomColor) {
effect.setRGBColorF(ent.worldObj.rand.nextFloat(), ent.worldObj.rand.nextFloat(), ent.worldObj.rand.nextFloat());
} else {
effect.setRGBColorI(particleColor);
}
}
switch(particleBehaviour) {
case //fade
0:
effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(particleSpeed));
break;
case //float
1:
effect.AddParticleController(new ParticleFloatUpward(effect, 0.2f, particleSpeed, 1, false));
break;
case //sink
2:
effect.AddParticleController(new ParticleFloatUpward(effect, 0.2f, -particleSpeed, 1, false));
break;
case //orbit
3:
effect.AddParticleController(new ParticleOrbitEntity(effect, ent, particleSpeed, 1, false));
break;
case //arc
4:
effect.AddParticleController(new ParticleArcToEntity(effect, 1, ent, false).generateControlPoints().SetSpeed(particleSpeed));
break;
case //flee
5:
effect.AddParticleController(new ParticleFleeEntity(effect, ent, particleSpeed, 2D, 1, false));
break;
case //forward
6:
effect.AddParticleController(new ParticleMoveOnHeading(effect, ent.rotationYaw + 90, ent.rotationPitch, particleSpeed, 1, false));
break;
case //pendulum
7:
effect.AddParticleController(new ParticlePendulum(effect, 0.2f, particleSpeed, 1, false));
break;
case //grow
8:
effect.AddParticleController(new ParticleGrow(effect, particleSpeed, 1, false));
break;
}
}
}
}
}
}
}
use of am2.particles.ParticleMoveOnHeading in project ArsMagica2 by Mithion.
the class Knockback method spawnParticles.
@Override
public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier) {
for (int i = 0; i < 25; ++i) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, "sparkle", x, y, z);
if (particle != null) {
particle.addRandomOffset(1, 2, 1);
double dx = caster.posX - target.posX;
double dz = caster.posZ - target.posZ;
double angle = Math.toDegrees(Math.atan2(-dz, -dx));
particle.AddParticleController(new ParticleMoveOnHeading(particle, angle, 0, 0.1 + rand.nextDouble() * 0.5, 1, false));
particle.AddParticleController(new ParticleFadeOut(particle, 1, false).setFadeSpeed(0.05f));
particle.setMaxAge(20);
if (colorModifier > -1) {
particle.setRGBColorF(((colorModifier >> 16) & 0xFF) / 255.0f, ((colorModifier >> 8) & 0xFF) / 255.0f, (colorModifier & 0xFF) / 255.0f);
}
}
}
}
use of am2.particles.ParticleMoveOnHeading in project ArsMagica2 by Mithion.
the class EntityManaVortex method onUpdate.
@Override
public void onUpdate() {
this.ticksExisted++;
this.rotation += 5;
if (!this.worldObj.isRemote && (this.isDead || this.ticksExisted >= getTicksToExist())) {
this.setDead();
return;
}
if (this.getTicksToExist() - this.ticksExisted <= 20) {
this.scale -= 1f / 20f;
} else if (this.scale < 0.99f) {
this.scale = (float) (Math.sin((float) this.ticksExisted / 50));
}
if (getTicksToExist() - this.ticksExisted <= 5 && !hasGoneBoom) {
hasGoneBoom = true;
if (!worldObj.isRemote) {
List players = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(3 + Math.floor(this.ticksExisted / 50), 2, 3 + Math.floor(this.ticksExisted / 50)));
float damage = this.dataWatcher.getWatchableObjectFloat(DW_MANA_STOLEN) * 0.005f;
if (damage > 100)
damage = 100;
Object[] playerArray = players.toArray();
for (Object o : playerArray) {
EntityLivingBase e = (EntityLivingBase) o;
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(Vec3.createVectorHelper(this.posX, this.posY, this.posZ), Vec3.createVectorHelper(e.posX, e.posY + e.getEyeHeight(), e.posZ), false);
if (mop == null)
e.attackEntityFrom(DamageSources.causeEntityPhysicalDamage(this), damage);
}
} else {
for (int i = 0; i < 360; i += AMCore.config.FullGFX() ? 5 : AMCore.config.LowGFX() ? 10 : 20) {
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "ember", this.posX, this.posY, this.posZ);
if (effect != null) {
effect.setIgnoreMaxAge(true);
effect.AddParticleController(new ParticleMoveOnHeading(effect, i, 0, 0.7f, 1, false));
effect.setRGBColorF(0.24f, 0.24f, 0.8f);
effect.noClip = false;
effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
effect.AddParticleController(new ParticleLeaveParticleTrail(effect, "ember", false, 5, 1, false).addControllerToParticleList(new ParticleMoveOnHeading(effect, i, 0, 0.1f, 1, false)).addControllerToParticleList(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.1f).setKillParticleOnFinish(true)).setParticleRGB_F(0.24f, 0.24f, 0.8f).addRandomOffset(0.2f, 0.2f, 0.2f));
}
}
}
}
if (getTicksToExist() - this.ticksExisted > 30) {
//get all players within 5 blocks
List<EntityLivingBase> players = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(3 + Math.floor(this.ticksExisted / 50), 2, 3 + Math.floor(this.ticksExisted / 50)));
Object[] playerArray = players.toArray();
Vec3 thisPos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
for (Object o : playerArray) {
EntityLivingBase e = (EntityLivingBase) o;
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(Vec3.createVectorHelper(this.posX, this.posY, this.posZ), Vec3.createVectorHelper(e.posX, e.posY + e.getEyeHeight(), e.posZ), false);
if (mop != null)
continue;
Vec3 playerPos = Vec3.createVectorHelper(e.posX, e.posY + e.getEyeHeight(), e.posZ);
if (worldObj.isRemote) {
if (AMCore.config.NoGFX()) {
break;
}
if (AMCore.config.LowGFX() && (this.ticksExisted % 4) != 0) {
break;
}
AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "ember", e.posX, e.posY + (e.getEyeHeight() / 2), e.posZ);
if (effect != null) {
effect.AddParticleController(new ParticleArcToEntity(effect, 1, this, false).generateControlPoints().setKillParticleOnFinish(true));
effect.setRGBColorF(0.24f, 0.24f, 0.8f);
effect.setIgnoreMaxAge(true);
}
}
float manaStolen = ExtendedProperties.For(e).getMaxMana() * 0.01f;
float curMana = ExtendedProperties.For(e).getCurrentMana();
if (manaStolen > curMana)
manaStolen = curMana;
this.dataWatcher.updateObject(DW_MANA_STOLEN, this.dataWatcher.getWatchableObjectFloat(DW_MANA_STOLEN) + manaStolen);
ExtendedProperties.For(e).setCurrentMana(ExtendedProperties.For(e).getCurrentMana() - manaStolen);
AMVector3 movement = MathUtilities.GetMovementVectorBetweenEntities(e, this);
float speed = -0.075f;
e.addVelocity(movement.x * speed, movement.y * speed, movement.z * speed);
}
}
}
use of am2.particles.ParticleMoveOnHeading in project ArsMagica2 by Mithion.
the class EntityFlicker method flick.
private void flick() {
if (this.worldObj.isRemote) {
for (int i = 0; i < 10 * AMCore.config.getGFXLevel(); ++i) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "radiant", posX, posY, posZ);
if (particle != null) {
particle.AddParticleController(new ParticleMoveOnHeading(particle, worldObj.rand.nextDouble() * 360, worldObj.rand.nextDouble() * 360, worldObj.rand.nextDouble() * 0.3f + 0.01f, 1, false));
particle.setRGBColorI(getFlickerAffinity().color);
particle.AddParticleController(new ParticleFadeOut(particle, 1, false).setFadeSpeed((float) (worldObj.rand.nextDouble() * 0.1 + 0.05)).setKillParticleOnFinish(true));
particle.setIgnoreMaxAge(true);
particle.setParticleScale(0.1f);
}
}
} else {
this.setDead();
}
}
use of am2.particles.ParticleMoveOnHeading in project ArsMagica2 by Mithion.
the class Beam method beginStackStage.
@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) {
boolean shouldApplyEffect = useCount % 10 == 0;
double range = SpellUtils.instance.getModifiedDouble_Add(SpellModifiers.RANGE, stack, caster, target, world, 0);
boolean targetWater = SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, range, true, targetWater);
SpellCastResult result = null;
Vec3 beamHitVec = null;
Vec3 spellVec = null;
if (mop == null) {
beamHitVec = MathUtilities.extrapolateEntityLook(world, caster, range);
spellVec = beamHitVec;
} else if (mop.typeOfHit == MovingObjectType.ENTITY) {
if (shouldApplyEffect) {
Entity e = mop.entityHit;
if (e instanceof EntityDragonPart && ((EntityDragonPart) e).entityDragonObj instanceof EntityLivingBase)
e = (EntityLivingBase) ((EntityDragonPart) e).entityDragonObj;
result = SpellHelper.instance.applyStageToEntity(stack, caster, world, e, 0, giveXP);
if (result != SpellCastResult.SUCCESS) {
return result;
}
}
float rng = (float) mop.hitVec.distanceTo(Vec3.createVectorHelper(caster.posX, caster.posY, caster.posZ));
beamHitVec = MathUtilities.extrapolateEntityLook(world, caster, rng);
spellVec = beamHitVec;
} else {
if (shouldApplyEffect) {
result = SpellHelper.instance.applyStageToGround(stack, caster, world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 0, giveXP);
if (result != SpellCastResult.SUCCESS) {
return result;
}
}
beamHitVec = mop.hitVec;
spellVec = Vec3.createVectorHelper(mop.blockX, mop.blockY, mop.blockZ);
}
if (world.isRemote && beamHitVec != null) {
AMBeam beam = (AMBeam) beams.get(caster.getEntityId());
double startX = caster.posX;
double startY = caster.posY + caster.getEyeHeight() - 0.2f;
double startZ = caster.posZ;
Affinity affinity = SpellUtils.instance.mainAffinityFor(stack);
int color = -1;
if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, stack, 0)) {
ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(stack, 0);
int ordinalCount = 0;
for (ISpellModifier mod : mods) {
if (mod instanceof Colour) {
byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(stack, mod, 0, ordinalCount++);
color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
}
}
}
if (beam != null) {
if (beam.isDead || beam.getDistanceSqToEntity(caster) > 4) {
beams.remove(caster.getEntityId());
} else {
beam.setBeamLocationAndTarget(startX, startY, startZ, beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord);
}
} else {
if (affinity == Affinity.LIGHTNING) {
AMCore.instance.proxy.particleManager.BoltFromEntityToPoint(world, caster, beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord, 1, color == -1 ? affinity.color : color);
} else {
beam = (AMBeam) AMCore.instance.proxy.particleManager.BeamFromEntityToPoint(world, caster, beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord, color == -1 ? affinity.color : color);
if (beam != null) {
if (AMCore.instance.proxy.getProxyUtils().isLocalPlayerInFirstPerson())
beam.setFirstPersonPlayerCast();
beams.put(caster.getEntityId(), beam);
}
}
}
for (int i = 0; i < AMCore.config.getGFXLevel() + 1; ++i) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(world, AMParticleIcons.instance.getParticleForAffinity(affinity), beamHitVec.xCoord, beamHitVec.yCoord, beamHitVec.zCoord);
if (particle != null) {
particle.setMaxAge(2);
particle.setParticleScale(0.1f);
particle.setIgnoreMaxAge(false);
if (color != -1)
particle.setRGBColorI(color);
particle.AddParticleController(new ParticleMoveOnHeading(particle, world.rand.nextDouble() * 360, world.rand.nextDouble() * 360, world.rand.nextDouble() * 0.2 + 0.02f, 1, false));
}
}
}
if (result != null && spellVec != null && shouldApplyEffect) {
ItemStack newItemStack = SpellUtils.instance.popStackStage(stack);
return SpellHelper.instance.applyStackStage(newItemStack, caster, target, spellVec.xCoord, spellVec.yCoord, spellVec.zCoord, mop != null ? mop.sideHit : 0, world, true, giveXP, 0);
} else {
return SpellCastResult.SUCCESS_REDUCE_MANA;
}
}
Aggregations