From 29af8f173d637176cc6ba76bd8e329271bfdd9c7 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 3 Feb 2019 19:59:11 +0200 Subject: [PATCH] Added a changeling magic particle effect --- .../minelittlepony/unicopia/UParticles.java | 3 ++ .../client/ParticleChanglingMagic.java | 33 +++++++++++++++++++ .../unicopia/power/PowerDisguise.java | 4 +-- .../unicopia/spell/SpellDisguise.java | 1 - 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/particle/client/ParticleChanglingMagic.java diff --git a/src/main/java/com/minelittlepony/unicopia/UParticles.java b/src/main/java/com/minelittlepony/unicopia/UParticles.java index 7f845f95..c2fccbdb 100644 --- a/src/main/java/com/minelittlepony/unicopia/UParticles.java +++ b/src/main/java/com/minelittlepony/unicopia/UParticles.java @@ -3,6 +3,7 @@ package com.minelittlepony.unicopia; import com.minelittlepony.unicopia.particle.Particles; import com.minelittlepony.unicopia.particle.client.EntityMagicFX; import com.minelittlepony.unicopia.particle.client.EntityRaindropFX; +import com.minelittlepony.unicopia.particle.client.ParticleChanglingMagic; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -11,10 +12,12 @@ public class UParticles { public static int MAGIC_PARTICLE; public static int RAIN_PARTICLE; + public static int CHANGELING_MAGIC; @SideOnly(Side.CLIENT) static void init() { MAGIC_PARTICLE = Particles.instance().registerParticle(EntityMagicFX::new); RAIN_PARTICLE = Particles.instance().registerParticle(EntityRaindropFX::new); + CHANGELING_MAGIC = Particles.instance().registerParticle(ParticleChanglingMagic::new); } } diff --git a/src/main/java/com/minelittlepony/unicopia/particle/client/ParticleChanglingMagic.java b/src/main/java/com/minelittlepony/unicopia/particle/client/ParticleChanglingMagic.java new file mode 100644 index 00000000..bec88f1c --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/particle/client/ParticleChanglingMagic.java @@ -0,0 +1,33 @@ +package com.minelittlepony.unicopia.particle.client; + +import net.minecraft.client.particle.ParticlePortal; +import net.minecraft.world.World; + +public class ParticleChanglingMagic extends ParticlePortal { + + private int baseTextureIndex = 128; + + public ParticleChanglingMagic(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); + } + + public ParticleChanglingMagic(World world, double x, double y, double z, double dx, double dy, double dz) { + super(world, x, y, z, dx, dy, dz); + + float intensity = rand.nextFloat() * 0.6F + 0.4F; + + particleRed = intensity * 0.5F; + particleGreen = intensity; + particleBlue = intensity * 0.4f; + + setParticleTextureIndex((int)(Math.random() * 8.0D)); + } + + @Override + public void onUpdate() { + setParticleTextureIndex(baseTextureIndex + (7 - particleAge * 8 / particleMaxAge)); + + super.onUpdate(); + } + +} diff --git a/src/main/java/com/minelittlepony/unicopia/power/PowerDisguise.java b/src/main/java/com/minelittlepony/unicopia/power/PowerDisguise.java index 8f66b29c..97e2bf2a 100644 --- a/src/main/java/com/minelittlepony/unicopia/power/PowerDisguise.java +++ b/src/main/java/com/minelittlepony/unicopia/power/PowerDisguise.java @@ -54,12 +54,12 @@ public class PowerDisguise extends PowerFeed { @Override public void preApply(IPlayer player) { player.addEnergy(2); - IPower.spawnParticles(UParticles.MAGIC_PARTICLE, player, 5); + IPower.spawnParticles(UParticles.CHANGELING_MAGIC, player, 5); } @Override public void postApply(IPlayer player) { player.setEnergy(0); - IPower.spawnParticles(UParticles.MAGIC_PARTICLE, player, 5); + IPower.spawnParticles(UParticles.CHANGELING_MAGIC, player, 5); } } diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellDisguise.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellDisguise.java index c5b2092c..958089a0 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellDisguise.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellDisguise.java @@ -11,7 +11,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.passive.EntityChicken; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.nbt.NBTTagCompound;