#1279: Back Particle by a minecraft registry

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2023-10-21 13:42:09 +11:00
parent 17c30fd4e2
commit e84271b31b
6 changed files with 456 additions and 230 deletions

View File

@@ -121,7 +121,12 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
@Override
public <T> void setParticle(Particle particle, T data) {
getHandle().setParticle(CraftParticle.toNMS(particle, data));
particle = CraftParticle.convertLegacy(particle);
data = CraftParticle.convertLegacy(data);
if (data != null) {
Preconditions.checkArgument(particle.getDataType().isInstance(data), "data (%s) should be %s", data.getClass(), particle.getDataType());
}
getHandle().setParticle(CraftParticle.createParticleParam(particle, data));
}
@Override

View File

@@ -2080,10 +2080,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
particle = CraftParticle.convertLegacy(particle);
data = CraftParticle.convertLegacy(data);
if (data != null) {
Preconditions.checkArgument(particle.getDataType().isInstance(data), "data (%s) should be %s", data.getClass(), particle.getDataType());
}
PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.toNMS(particle, data), true, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count);
PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.createParticleParam(particle, data), true, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count);
getHandle().connection.send(packetplayoutworldparticles);
}