use of am2.particles.ParticleColorShift in project ArsMagica2 by Mithion.
the class EntityThrownRock method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (this.target != null && this.posY > this.target.y) {
double deltaX = this.posX - target.x;
double deltaY = this.posY - target.y;
double deltaZ = this.posZ - target.z;
double angle = Math.atan2(deltaZ, deltaX);
double hDist = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
double vAngle = Math.atan2(deltaY, hDist);
motionX = -Math.cos(angle) * 0.2;
motionZ = -Math.sin(angle) * 0.2;
motionY = -Math.sin(vAngle) * 2.5;
}
if (!getIsMoonstoneMeteor() && !getIsShootingStar()) {
if (!worldObj.isRemote && (throwingEntity == null || throwingEntity.isDead)) {
setDead();
} else {
ticksExisted++;
int maxTicksToLive = maxTicksToExist > -1 ? maxTicksToExist : 100;
if (ticksExisted >= maxTicksToLive && !worldObj.isRemote) {
setDead();
return;
}
}
}
if (getIsShootingStar()) {
motionY -= 0.1f;
if (motionY < -2f)
motionY = -2f;
}
if (worldObj.isRemote) {
if (getIsMoonstoneMeteor()) {
AMParticle fire = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "explosion_2", posX, posY, posZ);
if (fire != null) {
fire.setMaxAge(20);
fire.setRGBColorF(1, 1, 1);
fire.setParticleScale(2.0f);
fire.AddParticleController(new ParticleHoldPosition(fire, 20, 1, false));
fire.AddParticleController(new ParticleColorShift(fire, 1, false).SetShiftSpeed(0.1f).SetColorTarget(0.01f, 0.01f, 0.01f).SetEndOnReachingTargetColor().setKillParticleOnFinish(false));
}
} else if (getIsShootingStar()) {
int color = -1;
if (getSpellStack() != null) {
if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, getSpellStack(), 0)) {
ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(getSpellStack(), 0);
int ordinalCount = 0;
for (ISpellModifier mod : mods) {
if (mod instanceof Colour) {
byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(getSpellStack(), mod, 0, ordinalCount++);
color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
}
}
}
}
for (float i = 0; i < Math.abs(motionY); i += 0.1f) {
AMParticle star = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "ember", posX + motionX * i, posY + motionY * i, posZ + motionZ * i);
if (star != null) {
star.setMaxAge(22);
float clr = rand.nextFloat();
float clrMod = Minecraft.getMinecraft().theWorld.rand.nextFloat();
int finalColor = -1;
if (color == -1)
finalColor = MathUtilities.colorFloatsToInt(0.24f * clrMod, 0.58f * clrMod, 0.71f * clrMod);
else {
float[] colors = MathUtilities.colorIntToFloats(color);
for (int c = 0; c < colors.length; ++c) colors[c] = colors[c] * clrMod;
finalColor = MathUtilities.colorFloatsToInt(colors[0], colors[1], colors[2]);
}
star.setRGBColorI(finalColor);
star.AddParticleController(new ParticleHoldPosition(star, 20, 1, false));
star.AddParticleController(new ParticleChangeSize(star, 0.5f, 0.05f, 20, 1, false));
}
}
}
}
Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
vec3d = Vec3.createVectorHelper(posX, posY, posZ);
vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (movingobjectposition != null) {
vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d = 0.0D;
for (int j = 0; j < list.size(); j++) {
Entity entity1 = (Entity) list.get(j);
if (!entity1.canBeCollidedWith() || entity1.isEntityEqual(throwingEntity) && ticksExisted < 25) {
continue;
}
float f2 = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (movingobjectposition1 == null) {
continue;
}
double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
if (d1 < d || d == 0.0D) {
entity = entity1;
d = d1;
}
}
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null) {
HitObject(movingobjectposition);
}
posX += motionX;
posY += motionY;
posZ += motionZ;
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
for (rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {
}
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {
}
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {
}
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {
}
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f1 = 0.95F;
setPosition(posX, posY, posZ);
}
use of am2.particles.ParticleColorShift in project ArsMagica2 by Mithion.
the class ItemFrameWatcher method spawnCompendiumCompleteParticles.
@SideOnly(Side.CLIENT)
public void spawnCompendiumCompleteParticles(EntityItemFrame frame) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(frame.worldObj, "radiant", frame.posX, frame.posY, frame.posZ);
if (particle != null) {
particle.setIgnoreMaxAge(false);
particle.setMaxAge(40);
particle.setParticleScale(0.3f);
// particle.AddParticleController(new ParticleApproachEntity(particle, frame, 0.02f, 0.04f, 1, false).setKillParticleOnFinish(true));
particle.AddParticleController(new ParticleHoldPosition(particle, 40, 1, false));
particle.AddParticleController(new ParticleColorShift(particle, 1, false).SetShiftSpeed(0.2f));
}
}
Aggregations