mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Polish up the rainboom trail particle
This commit is contained in:
parent
33b3eec4cb
commit
f537079b1b
2 changed files with 7 additions and 5 deletions
|
@ -27,6 +27,7 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
|
||||||
public RainbowTrailParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
|
public RainbowTrailParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
|
||||||
super(world, x, y, z, velocityX, velocityY, velocityZ);
|
super(world, x, y, z, velocityX, velocityY, velocityZ);
|
||||||
segments.add(new Segment(new Vec3d(x, y, z)));
|
segments.add(new Segment(new Vec3d(x, y, z)));
|
||||||
|
setMaxAge(300);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +37,7 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStillAlive() {
|
public boolean isStillAlive() {
|
||||||
return age < (maxAge - 1);
|
return age < getMaxAge() && (!dead || !segments.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,6 +57,8 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderQuads(Tessellator te, BufferBuilder buffer, float x, float y, float z, float tickDelta) {
|
protected void renderQuads(Tessellator te, BufferBuilder buffer, float x, float y, float z, float tickDelta) {
|
||||||
|
float alpha = 1 - (float)age / maxAge;
|
||||||
|
|
||||||
for (int i = 0; i < segments.size() - 1; i++) {
|
for (int i = 0; i < segments.size() - 1; i++) {
|
||||||
Vector3f[] corners = segments.get(i).getPlane(segments.get(i + 1));
|
Vector3f[] corners = segments.get(i).getPlane(segments.get(i + 1));
|
||||||
float scale = getScale(tickDelta);
|
float scale = getScale(tickDelta);
|
||||||
|
@ -66,7 +69,7 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
|
||||||
corner.add(x, y, z);
|
corner.add(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderQuad(te, buffer, corners, segments.get(i).getAlpha(), tickDelta);
|
renderQuad(te, buffer, corners, segments.get(i).getAlpha() * alpha, tickDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,11 +89,11 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
age = 0;
|
|
||||||
|
|
||||||
if (link.linked()) {
|
if (link.linked()) {
|
||||||
|
age = 0;
|
||||||
link.ifAbsent(() -> {}).ifPresent(this::follow);
|
link.ifAbsent(() -> {}).ifPresent(this::follow);
|
||||||
} else {
|
} else if (!dead) {
|
||||||
follow(Pony.of(MinecraftClient.getInstance().player));
|
follow(Pony.of(MinecraftClient.getInstance().player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,6 @@ public class ParticleHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void detach() {
|
public void detach() {
|
||||||
linked = false;
|
|
||||||
caster = Optional.empty();
|
caster = Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue