2020-10-14 21:07:36 +02:00
|
|
|
package com.minelittlepony.unicopia.particle;
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
import com.mojang.brigadier.StringReader;
|
|
|
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
|
|
|
|
|
|
import net.minecraft.particle.ParticleEffect;
|
|
|
|
import net.minecraft.particle.ParticleType;
|
|
|
|
import net.minecraft.network.PacketByteBuf;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
import net.minecraft.util.registry.Registry;
|
|
|
|
|
|
|
|
public class OrientedBillboardParticleEffect implements ParticleEffect {
|
2021-12-23 23:38:02 +01:00
|
|
|
@SuppressWarnings("deprecation")
|
2021-12-22 12:10:45 +01:00
|
|
|
public static final ParticleEffect.Factory<OrientedBillboardParticleEffect> FACTORY = ParticleFactoryHelper.of(OrientedBillboardParticleEffect::new, OrientedBillboardParticleEffect::new);
|
2020-10-14 21:07:36 +02:00
|
|
|
|
|
|
|
private final boolean fixed;
|
|
|
|
private final float yaw;
|
|
|
|
private final float pitch;
|
|
|
|
|
|
|
|
private final ParticleType<OrientedBillboardParticleEffect> type;
|
|
|
|
|
2021-12-22 12:10:45 +01:00
|
|
|
protected OrientedBillboardParticleEffect(ParticleType<OrientedBillboardParticleEffect> type, StringReader reader) throws CommandSyntaxException {
|
|
|
|
this(type, ParticleFactoryHelper.readBoolean(reader), ParticleFactoryHelper.readFloat(reader), ParticleFactoryHelper.readFloat(reader));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected OrientedBillboardParticleEffect(ParticleType<OrientedBillboardParticleEffect> particleType, PacketByteBuf buf) {
|
|
|
|
this(particleType, buf.readBoolean(), buf.readFloat(), buf.readFloat());
|
|
|
|
}
|
|
|
|
|
2020-10-14 21:07:36 +02:00
|
|
|
public OrientedBillboardParticleEffect(ParticleType<OrientedBillboardParticleEffect> type, Vec3d orientation) {
|
|
|
|
this(type, (float)orientation.getX(), (float)orientation.getY());
|
|
|
|
}
|
|
|
|
|
|
|
|
public OrientedBillboardParticleEffect(ParticleType<OrientedBillboardParticleEffect> type, float yaw, float pitch) {
|
|
|
|
this(type, true, yaw, pitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
private OrientedBillboardParticleEffect(ParticleType<OrientedBillboardParticleEffect> type, boolean fixed, float yaw, float pitch) {
|
|
|
|
this.fixed = fixed;
|
|
|
|
this.yaw = yaw;
|
|
|
|
this.pitch = pitch;
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAngleFixed() {
|
|
|
|
return fixed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getYaw() {
|
|
|
|
return yaw;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getPitch() {
|
|
|
|
return pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ParticleType<?> getType() {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void write(PacketByteBuf buf) {
|
|
|
|
buf.writeBoolean(fixed);
|
|
|
|
buf.writeFloat(yaw);
|
|
|
|
buf.writeFloat(pitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String asString() {
|
|
|
|
return String.format(Locale.ROOT, "%s %b %.2f %.2f", Registry.PARTICLE_TYPE.getId(getType()), fixed, yaw, pitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|