The great particle refactoring part 2: Splitting and Streamlining!
- Splits all particle textures into individual files intead of sprite sheets - Replaces arc and lightning pulse entities with particles - Pulls particle code up to the general ParticleWizardry so behaviours such as spin can be applied to all particle types - Renames a few ParticleBuilder methods for conciseness. - Adds a few new particle effects to various spells and entities, with a slight tweak to EntityMagicArrow#onBlockHit to facilitate impact effects
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
package electroblob.wizardry.client.particle;
|
||||
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ParticleSparkle extends ParticleCustomTexture {
|
||||
@Mod.EventBusSubscriber(Side.CLIENT)
|
||||
public class ParticleSparkle extends ParticleWizardry {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(Wizardry.MODID,
|
||||
"textures/particle/sparkle_particles.png");
|
||||
|
||||
// Implementation of colour fading (perhaps these belong in ParticleWizardry?)
|
||||
private float initialRed;
|
||||
private float initialGreen;
|
||||
private float initialBlue;
|
||||
private static final ResourceLocation[] TEXTURES = generateTextures("sparkle", 11);
|
||||
|
||||
public ParticleSparkle(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
|
||||
super(world, x, y, z, TEXTURES); // This time the textures are all one long animation
|
||||
|
||||
this.setRBGColorF(1, 1, 1);
|
||||
this.particleMaxAge = 48 + this.rand.nextInt(12);
|
||||
this.particleScale *= 0.75f;
|
||||
@@ -27,30 +26,6 @@ public class ParticleSparkle extends ParticleCustomTexture {
|
||||
this.shaded = false;
|
||||
}
|
||||
|
||||
// Overridden to set the initial colour values
|
||||
@Override
|
||||
public void setRBGColorF(float r, float g, float b){
|
||||
super.setRBGColorF(r, g, b);
|
||||
initialRed = r;
|
||||
initialGreen = g;
|
||||
initialBlue = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(){
|
||||
return TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getXFrames(){
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getYFrames(){
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(){
|
||||
|
||||
@@ -58,24 +33,14 @@ public class ParticleSparkle extends ParticleCustomTexture {
|
||||
|
||||
// Fading
|
||||
if(this.particleAge > this.particleMaxAge / 2){
|
||||
this.setAlphaF(
|
||||
1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge);
|
||||
this.setAlphaF(1 - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onTextureStitchEvent(TextureStitchEvent.Pre event){
|
||||
for(ResourceLocation texture : TEXTURES){
|
||||
event.getMap().registerSprite(texture);
|
||||
}
|
||||
|
||||
// Colour fading
|
||||
float ageFraction = (float)this.particleAge / (float)this.particleMaxAge;
|
||||
// No longer uses setRBGColorF because that method now also sets the initial values
|
||||
this.particleRed = this.initialRed + (this.fadeRed - this.initialRed)*ageFraction;
|
||||
this.particleGreen = this.initialGreen + (this.fadeGreen - this.initialGreen)*ageFraction;
|
||||
this.particleBlue = this.initialBlue + (this.fadeBlue - this.initialBlue)*ageFraction;
|
||||
|
||||
this.setParticleTextureIndex((this.particleAge * 11)/this.particleMaxAge);
|
||||
}
|
||||
|
||||
/* As a side note, I see a lot of magic mods with fancy-looking particle effects that really seem to 'glow'. It's
|
||||
* actually not that hard - you simply create a reasonably high-res texture with translucency and then set the
|
||||
* OpenGL blend function to something like SRC_ALPHA, SRC_ALPHA or ONE, ONE. The thing is... they're not very
|
||||
* Minecraft-y. I still maintain that part of wizardry's appeal is that it stays true to the game's pixelated charm,
|
||||
* rather than trying to make it something it's not. Still, the newer textures are much better than the defaults I
|
||||
* used to use. */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user