Change rainbow trails to not default to the client player once bound

This commit is contained in:
Sollace 2023-01-21 23:15:14 +00:00
parent 598f4273da
commit 47e8995ad8
3 changed files with 14 additions and 6 deletions

View file

@ -6,6 +6,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.effect.*;
import com.minelittlepony.unicopia.block.data.ModificationType; import com.minelittlepony.unicopia.block.data.ModificationType;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.ParticleHandle; import com.minelittlepony.unicopia.particle.ParticleHandle;
import com.minelittlepony.unicopia.particle.ParticleHandle.Attachment;
import com.minelittlepony.unicopia.particle.UParticles; import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Shape;
@ -46,11 +47,13 @@ public class RainboomAbilitySpell extends AbstractSpell {
return false; return false;
} }
if (source.isClient()) { particlEffect.update(getUuid(), source, spawner -> {
particlEffect.update(getUuid(), source, spawner -> { spawner.addParticle(UParticles.RAINBOOM_TRAIL, source.getOriginVector(), Vec3d.ZERO);
spawner.addParticle(UParticles.RAINBOOM_TRAIL, source.getOriginVector(), Vec3d.ZERO); }).ifPresent(attachment -> {
}); attachment.setAttribute(Attachment.ATTR_BOUND, 1);
});
if (source.isClient()) {
// source.addParticle(new OrientedBillboardParticleEffect(UParticles.RAINBOOM_RING, source.getPhysics().getMotionAngle()), source.getOriginVector(), Vec3d.ZERO); // source.addParticle(new OrientedBillboardParticleEffect(UParticles.RAINBOOM_RING, source.getPhysics().getMotionAngle()), source.getOriginVector(), Vec3d.ZERO);
} }

View file

@ -27,6 +27,8 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
private Optional<Link> link = Optional.empty(); private Optional<Link> link = Optional.empty();
private boolean bound;
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)));
@ -55,7 +57,9 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
@Override @Override
public void setAttribute(int key, Number value) { public void setAttribute(int key, Number value) {
if (key == Attachment.ATTR_COLOR) {
bound = value.intValue() == 1;
}
} }
@Override @Override
@ -96,7 +100,7 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
if (link.isPresent()) { if (link.isPresent()) {
age = 0; age = 0;
link.flatMap(Link::get).ifPresent(this::follow); link.flatMap(Link::get).ifPresent(this::follow);
} else if (!dead) { } else if (!dead && !bound) {
follow(Pony.of(MinecraftClient.getInstance().player)); follow(Pony.of(MinecraftClient.getInstance().player));
} }

View file

@ -90,6 +90,7 @@ public class ParticleHandle {
int ATTR_OPACITY = 2; int ATTR_OPACITY = 2;
int ATTR_PITCH = 3; int ATTR_PITCH = 3;
int ATTR_YAW = 4; int ATTR_YAW = 4;
int ATTR_BOUND = 5;
boolean isStillAlive(); boolean isStillAlive();