Snow Partikle

Discussion in 'Spigot Plugin Development' started by Elias177Dev, Dec 24, 2019.

  1. Hey,
    I created a snow particle plugin that created snow particles. But these go through blocks. how can i do it when a block is in the way that the particles don't fall through?

    My Code:
    Code (Java):
    public class SnowUtil {
        public static float strength = 0;
        public void startParticle() {
            List<String> worlds = FileManager.getList("Worlds");
            strength = Float.valueOf(FileManager.getInt("StormStrength"));
            Bukkit.getScheduler().runTaskTimerAsynchronously(Main.getPlugin(Main.class), () -> {
                Bukkit.getOnlinePlayers().forEach(all -> {
                    if(worlds.contains(all.getLocation().getWorld().getName())) {
                        sendParticle(all, all.getLocation(), strength, FileManager.getInt("Snow"));
            }, FileManager.getInt("Ticks"), FileManager.getInt("Ticks"));

        public void sendParticle(Player p, Location loc, float speed, int amount) {
            EnumParticle enumParticle = EnumParticle.FIREWORKS_SPARK;
            PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(enumParticle, true, (float)loc.getX(), (float)loc.getY(), (float)loc.getZ(), 20.0F, 20.0F, 20.0F, speed, amount, null);
            ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
  2. Once you send the packet, you have no control over its location anymore. Its speed takes it where it takes it and it's completely client-side at that point. A possible solution I can think of is spawning the particles at specific locations and reducing their speed. This will give you access over their locations, allowing you to check for blocks.
  3. How can I spawn so many particles at specific locations that I have the control?
  4. Use a loop to calculate all the locations and spawn the particle at each location.
  5. Why are you using packets when there is already a method in the api?
    • Agree Agree x 1
  6. Sending packets would be the better solution if he wants to send the same particle effects to a group of players. Calling sendEffect on all of them would create multiple packets
  7. I mean he's sending the packet to every player on the server, so that's exactly what the api does.
    • Like Like x 1