Break up the monotony, suffer a little longer

- Soul particles last longer and loop
 - Randomly mirror the particles
This commit is contained in:
JozsefA 2021-06-26 11:52:28 -07:00
parent 5a7a35b3cc
commit 45fe9ba61c
3 changed files with 19 additions and 8 deletions

View file

@ -13,10 +13,18 @@ import net.minecraft.util.math.vector.Vector3f;
public class CustomRotationParticle extends SimpleAnimatedParticle { public class CustomRotationParticle extends SimpleAnimatedParticle {
protected boolean mirror;
protected int loopTicks;
public CustomRotationParticle(ClientWorld worldIn, double x, double y, double z, IAnimatedSprite spriteSet, float yAccel) { public CustomRotationParticle(ClientWorld worldIn, double x, double y, double z, IAnimatedSprite spriteSet, float yAccel) {
super(worldIn, x, y, z, spriteSet, yAccel); super(worldIn, x, y, z, spriteSet, yAccel);
} }
public void selectSpriteLoopingWithAge(IAnimatedSprite sprite) {
int loopFrame = age % loopTicks;
this.setSprite(sprite.get(loopFrame, loopTicks));
}
public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) { public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) {
Quaternion quaternion = new Quaternion(camera.getRotation()); Quaternion quaternion = new Quaternion(camera.getRotation());
if (this.particleAngle != 0.0F) { if (this.particleAngle != 0.0F) {
@ -44,8 +52,8 @@ public class CustomRotationParticle extends SimpleAnimatedParticle {
vertex.add(originX, originY, originZ); vertex.add(originX, originY, originZ);
} }
float minU = this.getMinU(); float minU = mirror ? this.getMaxU() : this.getMinU();
float maxU = this.getMaxU(); float maxU = mirror ? this.getMinU() : this.getMaxU();
float minV = this.getMinV(); float minV = this.getMinV();
float maxV = this.getMaxV(); float maxV = this.getMaxV();
int brightness = this.getBrightnessForRender(partialTicks); int brightness = this.getBrightnessForRender(partialTicks);

View file

@ -20,8 +20,9 @@ public class SoulBaseParticle extends CustomRotationParticle {
this.animatedSprite = spriteSet; this.animatedSprite = spriteSet;
this.particleScale = 0.5f; this.particleScale = 0.5f;
this.setSize(this.particleScale,this.particleScale); this.setSize(this.particleScale,this.particleScale);
this.maxAge = (int)(16.0F / (this.rand.nextFloat() * 0.36F + 0.64F)); this.loopTicks = 16 + (int) (this.rand.nextFloat() * 2f - 1f);
this.selectSpriteWithAge(animatedSprite); this.maxAge = (int)(64.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.selectSpriteLoopingWithAge(animatedSprite);
this.field_21507 = true; // disable movement this.field_21507 = true; // disable movement
} }
@ -30,7 +31,7 @@ public class SoulBaseParticle extends CustomRotationParticle {
if (this.age++ >= this.maxAge) { if (this.age++ >= this.maxAge) {
this.setExpired(); this.setExpired();
} else { } else {
this.selectSpriteWithAge(animatedSprite); this.selectSpriteLoopingWithAge(animatedSprite);
} }
} }

View file

@ -19,9 +19,11 @@ public class SoulParticle extends CustomRotationParticle {
this.animatedSprite = spriteSet; this.animatedSprite = spriteSet;
this.particleScale = 0.5f; this.particleScale = 0.5f;
this.setSize(this.particleScale,this.particleScale); this.setSize(this.particleScale,this.particleScale);
this.maxAge = (int)(16.0F / (this.rand.nextFloat() * 0.36F + 0.64F)); this.loopTicks = 16 + (int) (this.rand.nextFloat() * 4f - 2f);
this.selectSpriteWithAge(animatedSprite); this.maxAge = (int)(64.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.selectSpriteLoopingWithAge(animatedSprite);
this.field_21507 = true; // disable movement this.field_21507 = true; // disable movement
this.mirror = this.rand.nextBoolean();
} }
@Override @Override
@ -29,7 +31,7 @@ public class SoulParticle extends CustomRotationParticle {
if (this.age++ >= this.maxAge) { if (this.age++ >= this.maxAge) {
this.setExpired(); this.setExpired();
} else { } else {
this.selectSpriteWithAge(animatedSprite); this.selectSpriteLoopingWithAge(animatedSprite);
} }
} }