public static Object particlesPacket(String name, boolean longRange, Vector pos, Vector offset, float data, int count, int... extra) { return new PacketPlayOutWorldParticles(EnumParticle.valueOf(EnumParticle.class, name), longRange, (float) pos.getX(), (float) pos.getY(), (float) pos.getZ(), (float) offset.getX(), (float) offset.getY(), (float) offset.getZ(), data, count, extra); }
private void sendParticles() { Location loc = picker != null ? picker.getLocation() : getCurrentFlagLocation(); Long time = System.currentTimeMillis(); if ((isOnPost() || isDropped()) && lastParticle < time - 500) { lastParticle = time; PacketPlayOutWorldParticles portalPacket = new PacketPlayOutWorldParticles(EnumParticle.PORTAL, false, (float)loc.getX(), (float)loc.getY() + 1f, (float)loc.getZ(), 0f, 0f, 0f, 1f, 8); PacketUtils.broadcastPacket(portalPacket); } if (beam) { loc.add(0, 56.0, 0); PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(EnumParticle.ITEM_CRACK, true, (float)loc.getX(), (float)loc.getY(), (float)loc.getZ(), 0.15f, 24.0f, 0.15f, 0.0f, 40, 35, (int)color.getWoolData()); PacketUtils.broadcastPacket(packet); } }
public static void sendArrowParticle(Projectile arrow, float x, float y, float z) { Location loc = arrow.getLocation(); PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(EnumParticle.REDSTONE, true, (float)loc.getX(), (float)loc.getY(), (float)loc.getZ(), x, y, z, 1f, 0); PacketUtils.broadcastPacketByUUID(packet, allArrows); if (arrow.getShooter() instanceof Player && selfArrows.contains(((Player) arrow.getShooter()).getUniqueId())) PacketUtils.sendPacket((Player) arrow.getShooter(), packet); }
@Test public void verifyMapping() { for (Particle bukkit : Particle.values()) { Assert.assertNotNull("Missing Bukkit->NMS particle mapping", CraftParticle.toNMS(bukkit)); } for (EnumParticle nms : EnumParticle.values()) { Assert.assertNotNull("Missing NMS->Bukkit particle mapping", CraftParticle.toBukkit(nms)); } }
public static EnumParticle toNMS(Particle bukkit) { return EnumParticle.valueOf(bukkit.name()); }
public static Particle toBukkit(EnumParticle nms) { return Particle.valueOf(nms.name()); }