Skip to content

Commit

Permalink
Break up the monotony, suffer a little longer
Browse files Browse the repository at this point in the history
 - Soul particles last longer and loop
 - Randomly mirror the particles
  • Loading branch information
Jozufozu committed Jun 26, 2021
1 parent 5a7a35b commit 45fe9ba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@

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) {
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) {
Quaternion quaternion = new Quaternion(camera.getRotation());
if (this.particleAngle != 0.0F) {
Expand Down Expand Up @@ -44,8 +52,8 @@ public void buildGeometry(IVertexBuilder builder, ActiveRenderInfo camera, float
vertex.add(originX, originY, originZ);
}

float minU = this.getMinU();
float maxU = this.getMaxU();
float minU = mirror ? this.getMaxU() : this.getMinU();
float maxU = mirror ? this.getMinU() : this.getMaxU();
float minV = this.getMinV();
float maxV = this.getMaxV();
int brightness = this.getBrightnessForRender(partialTicks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public SoulBaseParticle(ClientWorld worldIn, double x, double y, double z, doubl
this.animatedSprite = spriteSet;
this.particleScale = 0.5f;
this.setSize(this.particleScale,this.particleScale);
this.maxAge = (int)(16.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.selectSpriteWithAge(animatedSprite);
this.loopTicks = 16 + (int) (this.rand.nextFloat() * 2f - 1f);
this.maxAge = (int)(64.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.selectSpriteLoopingWithAge(animatedSprite);
this.field_21507 = true; // disable movement
}

Expand All @@ -30,7 +31,7 @@ public void tick() {
if (this.age++ >= this.maxAge) {
this.setExpired();
} else {
this.selectSpriteWithAge(animatedSprite);
this.selectSpriteLoopingWithAge(animatedSprite);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ public SoulParticle(ClientWorld worldIn, double x, double y, double z, double vx
this.animatedSprite = spriteSet;
this.particleScale = 0.5f;
this.setSize(this.particleScale,this.particleScale);
this.maxAge = (int)(16.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.selectSpriteWithAge(animatedSprite);
this.loopTicks = 16 + (int) (this.rand.nextFloat() * 4f - 2f);
this.maxAge = (int)(64.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.selectSpriteLoopingWithAge(animatedSprite);
this.field_21507 = true; // disable movement
this.mirror = this.rand.nextBoolean();
}

@Override
public void tick() {
if (this.age++ >= this.maxAge) {
this.setExpired();
} else {
this.selectSpriteWithAge(animatedSprite);
this.selectSpriteLoopingWithAge(animatedSprite);
}
}

Expand Down

0 comments on commit 45fe9ba

Please sign in to comment.