Solved Particles

Discussion in 'Plugin Development' started by IIxUnderWorldxII, Feb 18, 2015.

Thread Status:
Not open for further replies.
  1. Code:
    package me.mrconnn.AG;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    public class ParticleTimer implements Runnable {
            @SuppressWarnings("deprecation")
            @Override
            public void run() {
                    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
                            if (Main.playersonEffect1.contains(p.getName())) {
                                    ParticleEffect.LAVA.display(1f, 1f, 1f, 2f, 3, p.getLocation(), 3);
                                   
                                    runTaskTimer();
                            }
                    }   
            }
    
            private void runTaskTimer() {
               
            }
    }
    I've been trying to get particles for a hub server I'm working on & I can't seem to get it working, I've tried this for the particletimer class, I've also never messed with particles so don't be so judgemental.
     
  2. Offline

    Skionz

  3. @Skionz Yes, in my main class when they click the item, add them to the arraylist.
     
  4. Offline

    Skionz

  5. @Skionz Never done that, but I'll try

    @Skionz I don't really get it. Did that code look about right tho?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  6. Do you actually run the Runnable?
     
  7. I've never really worked with runnables, I always messed with commands.

    What I'm trying to do is when they click the item in the inventory there added to a arraylist which plays an effect until they log out.
     
    Last edited by a moderator: Feb 20, 2015
  8. Offline

    Skionz

  9. Offline

    Funergy

    @IIxUnderWorldxII
    Why use an library if you can do it yourself?
    ((CraftPlayer) p).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldParticles("reddust", (float) loc.getX(), (float) loc.getY(), (float) loc.getZ(), offsetX, offsetY, offsetZ, speed, amount)
     
  10. @Skionz When I tried Funergy's way I got a NoClassDefFoundError: net/minecraft/server/1_7_R4/Packet
     
  11. Offline

    Skionz

    @IIxUnderWorldxII Probably because that class doesn't exist. Use craftbukkit 1.7.10
     
  12. @Skionz THANK YOU SO MUCH MAN! Fungery as well. Skionz why aren't you staff on bukkit?!? & 1 more thing. How do I make it run until they leave.
     
  13. Offline

    Skionz

  14. Code:
    package me.mrconnn.AG;
    import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.scheduler.BukkitRunnable;
    
    public class ParticleRunner extends BukkitRunnable {
    
    
        private final Main plugin;
    
        public ParticleRunner(Main plugin) {
            this.plugin = plugin;
        }
    
        @SuppressWarnings("deprecation")
        public void run() {
            for (Player p : Bukkit.getServer().getOnlinePlayers()) {
               
                if (Main.playersonEffect1.contains(p.getName())) {
                    Location loc = (Location) p.getLocation();
                    ((CraftPlayer) p).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldParticles("reddust", (float) loc.getX(), (float) loc.getY(), (float) loc.getZ(), 1, 1, 1, 1, 8));
                }
            }runTaskLater(this.plugin, 20);
        }
    
    }
    
    Is there anything wrong, I tried my best to follow it.
     
  15. Offline

    Skionz

  16. Offline

    BurnerDiamond

  17. Offline

    Skionz

  18. Last edited by a moderator: Feb 20, 2015
  19. Offline

    crolemol

    @IIxUnderWorldxII
    is that a client error or a server error? seems like a client
    edit nevermind saw craftbukkit

    with the runnable you are using now you run it 1 time with a delay of 20 ticks try to use .runTaskTimer() with a delay of 0ticks and 20 ticks as third parameter

    second edit: try this
    Code:
                    ((CraftPlayer) p).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldParticles("reddust", (float) loc.getX(), (float) loc.getY(), (float) loc.getZ(), 1F, 1F, 1F, 1F, 8));
    
    all the paramaters are float except of the last. this sometimes give me some problems without any errors because when it is not a float it just returns 0
     
    Last edited: Feb 19, 2015
  20. Offline

    Funergy

    Last edited by a moderator: Feb 20, 2015
  21. Offline

    crolemol

    @Funergy
    I have just casted everytihng to float in your line. When you give a double as a float it returns just 0 if it isnt casted I think 0 speed would be the problem
     
  22. Offline

    jimbo8

    The most important question of all; did you remember to enable particles in your client? :)
     
  23. I'm completely lost :/ @Skionz you got any idea?
     
    Last edited: Feb 20, 2015
Thread Status:
Not open for further replies.

Share This Page