From 898e93d8b196ee43361917421ac856166ff8a1f6 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 21 Feb 2019 18:57:05 +0200 Subject: [PATCH] Gems will produce particles of the same colour as their magic --- .../particle/client/ParticleUnicornMagic.java | 39 +++++++++++++------ .../minelittlepony/unicopia/power/IPower.java | 4 +- .../unicopia/spell/GenericSpell.java | 2 +- .../unicopia/spell/ICaster.java | 4 +- .../unicopia/spell/SpellCharge.java | 2 +- .../unicopia/spell/SpellPortal.java | 2 +- .../unicopia/spell/SpellReveal.java | 4 +- .../unicopia/spell/SpellShield.java | 2 +- .../unicopia/spell/SpellVortex.java | 2 +- 9 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/particle/client/ParticleUnicornMagic.java b/src/main/java/com/minelittlepony/unicopia/particle/client/ParticleUnicornMagic.java index 10bcb5ee..91ef2804 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/client/ParticleUnicornMagic.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/client/ParticleUnicornMagic.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.particle.client; +import com.minelittlepony.util.render.Color; + import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.BufferBuilder; @@ -13,10 +15,10 @@ public class ParticleUnicornMagic extends Particle { private double portalPosZ; 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); motionX = vX; motionY = vY; @@ -29,17 +31,32 @@ public class ParticleUnicornMagic extends Particle { setParticleTextureIndex((int)(Math.random() * 8)); - particleRed = particleGreen = particleBlue = 1; - particleGreen *= 0.3F; + if (tint >= 0) { + 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; - if (rand.nextBoolean()) particleRed *= 0.9F; - if (rand.nextBoolean()) particleGreen += 0.5F; + particleGreen *= 0.3F; - if (rand.nextBoolean()) { - particleGreen *= 2F; - } else if (rand.nextBoolean()) { - particleRed *= 3.9F; + if (rand.nextBoolean()) { + particleBlue *= 0.4F; + } + if (rand.nextBoolean()) { + particleRed *= 0.9F; + } + if (rand.nextBoolean()) { + particleGreen += 0.5F; + } + + if (rand.nextBoolean()) { + particleGreen *= 2F; + } else if (rand.nextBoolean()) { + particleRed *= 3.9F; + } } } diff --git a/src/main/java/com/minelittlepony/unicopia/power/IPower.java b/src/main/java/com/minelittlepony/unicopia/power/IPower.java index 036582a9..0710ecec 100644 --- a/src/main/java/com/minelittlepony/unicopia/power/IPower.java +++ b/src/main/java/com/minelittlepony/unicopia/power/IPower.java @@ -42,7 +42,7 @@ public interface IPower extends IKeyBind { 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 middle = entity.getEntityBoundingBox().minY + halfDist; @@ -55,7 +55,7 @@ public interface IPower extends IKeyBind { entity.posX + point.x, middle + point.y, entity.posZ + point.z, - 0, 0, 0); + 0, 0, 0, args); } } diff --git a/src/main/java/com/minelittlepony/unicopia/spell/GenericSpell.java b/src/main/java/com/minelittlepony/unicopia/spell/GenericSpell.java index 2de6bce6..b93dc4aa 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/GenericSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/GenericSpell.java @@ -39,7 +39,7 @@ public class GenericSpell extends AbstractSpell { @Override public void render(ICaster source) { - source.spawnParticles(UParticles.UNICORN_MAGIC, 1); + source.spawnParticles(UParticles.UNICORN_MAGIC, 1, getTint()); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/spell/ICaster.java b/src/main/java/com/minelittlepony/unicopia/spell/ICaster.java index adf1b6dd..2e1204ba 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/ICaster.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/ICaster.java @@ -70,8 +70,8 @@ public interface ICaster extends IOwned, ILevelle return getEntity().getPositionVector(); } - default void spawnParticles(int particleId, int count) { - IPower.spawnParticles(particleId, getEntity(), count); + default void spawnParticles(int particleId, int count, int...args) { + IPower.spawnParticles(particleId, getEntity(), count, args); } default void spawnParticles(IShape area, int count, Consumer particleSpawner) { diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellCharge.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellCharge.java index e8647e64..2008750f 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellCharge.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellCharge.java @@ -49,7 +49,7 @@ public class SpellCharge extends AbstractAttachableSpell { IShape line = new Line(start, target.getPositionVector()); 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()); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellPortal.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellPortal.java index e5e6d3ce..e6ed2a24 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellPortal.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellPortal.java @@ -151,7 +151,7 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc @Override public void render(ICaster source) { 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()); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellReveal.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellReveal.java index 5f6b3162..69e64746 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellReveal.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellReveal.java @@ -44,10 +44,10 @@ public class SpellReveal extends AbstractSpell { IShape area = new Sphere(false, 15); 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 diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellShield.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellShield.java index a50de8aa..52b87857 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellShield.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellShield.java @@ -40,7 +40,7 @@ public class SpellShield extends AbstractSpell.RangedAreaSpell implements IAttac float radius = 4 + (source.getCurrentLevel() * 2); 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 diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellVortex.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellVortex.java index 1463c84d..c2cbd0de 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellVortex.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellVortex.java @@ -33,7 +33,7 @@ public class SpellVortex extends SpellShield { Vec3d pos = source.getOriginVector(); 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()); }); }