Gems will produce particles of the same colour as their magic

This commit is contained in:
Sollace 2019-02-21 18:57:05 +02:00
parent a1da66272b
commit 898e93d8b1
9 changed files with 39 additions and 22 deletions

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.particle.client; package com.minelittlepony.unicopia.particle.client;
import com.minelittlepony.util.render.Color;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
@ -13,10 +15,10 @@ public class ParticleUnicornMagic extends Particle {
private double portalPosZ; private double portalPosZ;
public ParticleUnicornMagic(int id, World w, double x, double y, double z, double vX, double vY, double vZ, int... args) { public ParticleUnicornMagic(int id, World w, double x, double y, double z, double vX, double vY, double vZ, int... args) {
this(w, x, y, z, vX, vY, vZ); this(w, x, y, z, vX, vY, vZ, args.length > 0 ? args[0] : -1);
} }
public ParticleUnicornMagic(World w, double x, double y, double z, double vX, double vY, double vZ) { public ParticleUnicornMagic(World w, double x, double y, double z, double vX, double vY, double vZ, int tint) {
super(w, x, y, z, vX, vY, vZ); super(w, x, y, z, vX, vY, vZ);
motionX = vX; motionX = vX;
motionY = vY; motionY = vY;
@ -29,17 +31,32 @@ public class ParticleUnicornMagic extends Particle {
setParticleTextureIndex((int)(Math.random() * 8)); setParticleTextureIndex((int)(Math.random() * 8));
particleRed = particleGreen = particleBlue = 1; if (tint >= 0) {
particleGreen *= 0.3F; particleRed = Color.r(tint);
particleGreen = Color.g(tint);
particleBlue = Color.b(tint);
} else {
particleRed = 1;
particleGreen = 1;
particleBlue = 1;
if (rand.nextBoolean()) particleBlue *= 0.4F; particleGreen *= 0.3F;
if (rand.nextBoolean()) particleRed *= 0.9F;
if (rand.nextBoolean()) particleGreen += 0.5F;
if (rand.nextBoolean()) { if (rand.nextBoolean()) {
particleGreen *= 2F; particleBlue *= 0.4F;
} else if (rand.nextBoolean()) { }
particleRed *= 3.9F; if (rand.nextBoolean()) {
particleRed *= 0.9F;
}
if (rand.nextBoolean()) {
particleGreen += 0.5F;
}
if (rand.nextBoolean()) {
particleGreen *= 2F;
} else if (rand.nextBoolean()) {
particleRed *= 3.9F;
}
} }
} }

View file

@ -42,7 +42,7 @@ public interface IPower<T extends IData> extends IKeyBind {
return player.posY + player.getEyeHeight() - 1; return player.posY + player.getEyeHeight() - 1;
} }
static void spawnParticles(int particleId, Entity entity, int count) { static void spawnParticles(int particleId, Entity entity, int count, int...args) {
double halfDist = entity.getEyeHeight() / 1.5; double halfDist = entity.getEyeHeight() / 1.5;
double middle = entity.getEntityBoundingBox().minY + halfDist; double middle = entity.getEntityBoundingBox().minY + halfDist;
@ -55,7 +55,7 @@ public interface IPower<T extends IData> extends IKeyBind {
entity.posX + point.x, entity.posX + point.x,
middle + point.y, middle + point.y,
entity.posZ + point.z, entity.posZ + point.z,
0, 0, 0); 0, 0, 0, args);
} }
} }

View file

@ -39,7 +39,7 @@ public class GenericSpell extends AbstractSpell {
@Override @Override
public void render(ICaster<?> source) { public void render(ICaster<?> source) {
source.spawnParticles(UParticles.UNICORN_MAGIC, 1); source.spawnParticles(UParticles.UNICORN_MAGIC, 1, getTint());
} }
@Override @Override

View file

@ -70,8 +70,8 @@ public interface ICaster<E extends EntityLivingBase> extends IOwned<E>, ILevelle
return getEntity().getPositionVector(); return getEntity().getPositionVector();
} }
default void spawnParticles(int particleId, int count) { default void spawnParticles(int particleId, int count, int...args) {
IPower.spawnParticles(particleId, getEntity(), count); IPower.spawnParticles(particleId, getEntity(), count, args);
} }
default void spawnParticles(IShape area, int count, Consumer<Vec3d> particleSpawner) { default void spawnParticles(IShape area, int count, Consumer<Vec3d> particleSpawner) {

View file

@ -49,7 +49,7 @@ public class SpellCharge extends AbstractAttachableSpell {
IShape line = new Line(start, target.getPositionVector()); IShape line = new Line(start, target.getPositionVector());
source.spawnParticles(line, (int)line.getVolumeOfSpawnableSpace(), pos -> { source.spawnParticles(line, (int)line.getVolumeOfSpawnableSpace(), pos -> {
Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos.add(start), 0, 0, 0); Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos.add(start), 0, 0, 0, getTint());
}); });
} }

View file

@ -151,7 +151,7 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc
@Override @Override
public void render(ICaster<?> source) { public void render(ICaster<?> source) {
source.spawnParticles(getPortalZone(), 10, pos -> { source.spawnParticles(getPortalZone(), 10, pos -> {
Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos, 0, 0, 0); Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos, 0, 0, 0, getTint());
}); });
} }

View file

@ -44,10 +44,10 @@ public class SpellReveal extends AbstractSpell {
IShape area = new Sphere(false, 15); IShape area = new Sphere(false, 15);
source.spawnParticles(area, 5, pos -> { source.spawnParticles(area, 5, pos -> {
Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos, 0, 0, 0); Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos, 0, 0, 0, getTint());
}); });
source.spawnParticles(UParticles.UNICORN_MAGIC, 5); source.spawnParticles(UParticles.UNICORN_MAGIC, 5, getTint());
} }
@Override @Override

View file

@ -40,7 +40,7 @@ public class SpellShield extends AbstractSpell.RangedAreaSpell implements IAttac
float radius = 4 + (source.getCurrentLevel() * 2); float radius = 4 + (source.getCurrentLevel() * 2);
source.spawnParticles(new Sphere(true, radius), (int)(radius * 6), pos -> { source.spawnParticles(new Sphere(true, radius), (int)(radius * 6), pos -> {
Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos, 0, 0, 0); Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos, 0, 0, 0, getTint());
}); });
particlEffect particlEffect

View file

@ -33,7 +33,7 @@ public class SpellVortex extends SpellShield {
Vec3d pos = source.getOriginVector(); Vec3d pos = source.getOriginVector();
source.spawnParticles(new Sphere(false, range), range * 9, p -> { source.spawnParticles(new Sphere(false, range), range * 9, p -> {
Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, p, p.subtract(pos)); Particles.instance().spawnParticle(UParticles.UNICORN_MAGIC, false, p, p.subtract(pos), getTint());
}); });
} }