Library [1.8] ParticleEffect v1.7

Discussion in 'Resources' started by DarkBladee12, Jun 20, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    RingOfStorms

    I don't think this is reasonable at all. The best you'd be able to do is put it near where the bottom of the hand is, but the swinging of the arm is all client side and there would be no reasonable way to sync the animation of the client with the server to keep it at the top of the hand perfectly.
     
  2. Offline

    metmad22

    @BuyMeDrink Like @RingOfStorms said. I doubt there is a way you can achieve the full result you expect. Most particles are also big. If you add 1 to the Y location, that would spawn it in the middle of the player. Get the direction they are looking at, if it's NW for example, add the correct amount (0.5 - 1) to that direction. That might be the closest you can get of achieving that from what I can see.
     
    ChipDev likes this.
  3. Offline

    uksspy

    Is it possible to display particles to players who are 16+ blocks away from the source of the particle?

    I ask because CrateKeys uses this lib and it can display particles even when the player is over 16 blocks away.
    The issue is when I attempt to do this the particles cut off after 16 blocks.
    Code:
    ParticleEffect.SUSPENDED_DEPTH.display(0, 0, 0, 0, 1, l, 128);
     
  4. Offline

    BuyMeDrink

    Thanks for the answer guys. It works a little better right now.
    Code:
    loc.add((Math.cos(Math.toRadians(loc.getYaw()))/-2), 1.2, (Math.sin(Math.toRadians(loc.getYaw()))+Math.cos(Math.toRadians(loc.getYaw()))/-2)/-2);
    loc variable is the location of the player. Of course fire particles spawn a litte bit off but its okey. ;)
     
    metmad22, DarkBladee12 and ChipDev like this.
  5. How would I get the particle effect of Mycelium? I am having trouble getting the ParticleData of Mycelium with the library. Thanks
     
  6. Offline

    RingOfStorms

    I think it is called town aura or one of those weird ones, assuming you mean the particle that is emitted from Mycelium. Otherwise it is the block crack one and you jus tput in mycelium's block id.
     
  7. Didn't know there was an official particle for that. Thanks.

    And if I were to use the Block_Crack method, this:
    ParticleEffect.BLOCK_CRACK.display(new ParticleData(Material.MYCEL, (byte) 0), r(), r(), r(), 0.05F, 3, p.getLocation().add(0D, 1D, 0D), 20D);
    returns the error I have don't have the right server version. Aren't block id's... gone?
     
  8. Offline

    DarkBladee12

    @HeyAwesomePeople

    You'd have to create a new BlockData object instead of ParticleData!
     
  9. Offline

    567legodude

    @DarkBladee12 I used this before and I didn't get this error, but my IDE says that PackageType cannot be resolved, do you know how to fix that?

    EDIT: nvm, I found it.
     
    Last edited: Feb 2, 2015
  10. Offline

    LCastr0

    I can't wait for the day when we will be able to do a colored firework sparks :D
     
  11. Offline

    LCastr0

    @DarkBladee12 You should do a little improvement for the REDSTONE color, when it's black, it spawns a red particle because the speed is 0. Black is actually offset 000, speed .05f (I think it's the only color that has a different thing than the others... And also all the other particles work with black)
     
  12. Having an issue, I am doing this on my plugin, but getting a null pointer exception on the same line.

    Code:
    ParticleEffect.fromName(effect).display(r(0.01F, 0.05F), r(0.01F, 0.05F), r(0.01F, 0.05F), 0.05F, 1, p.getLocation().add(0D, 1D, 0D), 20D);
    I have printed all my variables, all do not return null. I am almost certain the cause is using ParticleEffect.fromName. The 'effect' variable is equal to SMOKE_LARGE, a legitimate effect in the lib. Any help? Thanks
    EDIT: nvm, particle effect.fromName wants the effect name in minecraft. Got it
     
    Last edited: Feb 6, 2015
  13. Offline

    bronzzze

    Code:
        double radius = 2;
            double maxHeight = 5;
           
            for(double y= 0; y< maxHeight; y += 0.05){
                double x = Math.sin(y * radius);
                double z = Math.cos(y * radius);
    Code:
    if (flame.contains(e.getPlayer().getUniqueId())) {
                ParticleEffect.FLAME.display((float) (l.getX() + x), (float) (l.getY() + y), (float) (l.getZ() + z), 1, 1, p.getLocation(), 15);



    Anyone knows what is wrong there i want to make look like this:
    [​IMG]
     
  14. Offline

    DarkBladee12

    @bronzzze
    Could you explain to us what doesn't work with your code?
     
  15. Offline

    bronzzze

    there is no error but it just do weird particles
    i want to make like this
    [​IMG]

    But this code is like this(only 1 flame on few seconds):
    [​IMG]
     
  16. Offline

    LCastr0

    Can you post your full code? With that lines it's pretty hard to discover what you're doing wrong...
     
  17. Offline

    bronzzze

    Code:
    package me.bronzzze.particles;
    
    import java.util.ArrayList;
    import java.util.UUID;
    import java.util.Vector;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.DyeColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import com.darkblade12.particleeffect.ParticleEffect;
    import com.darkblade12.particleeffect.ParticleEffect.ParticleColor;
    
    public class Main extends JavaPlugin implements Listener{
     
        ArrayList<UUID> cloud = new ArrayList<UUID>();
        ArrayList<UUID> heart = new ArrayList<UUID>();
        ArrayList<UUID> flame = new ArrayList<UUID>();
        ArrayList<UUID> note = new ArrayList<UUID>();
     
     
     
        @Override
        public void onEnable() {
            ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            console.sendMessage(ChatColor.RED + "-------------------------");
            console.sendMessage(ChatColor.BLUE + "SimpleParticlePlugin enabled");
            console.sendMessage(ChatColor.RED + "-------------------------");
    
    
             
                     
             
         
    
            }
         
     
     
     
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            Player p = (Player) sender;
            if (label.equalsIgnoreCase("particles")) {
            p.sendMessage(ChatColor.GREEN + "ParticleList Opened!");
            openInventory(p);
         
    
     
             
            }
            return false;
        }
     
     
    
     
     
     
    
         
     
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
            Inventory inv;
    
        public void openInventory(Player p){
            Inventory inv = Bukkit.getServer().createInventory(null, 27, "Particles");
         
            ItemStack item1 = new ItemStack(Material.WOOL, 1, DyeColor.RED.getData());
            ItemMeta itemM1 = item1.getItemMeta();
            itemM1.setDisplayName(ChatColor.AQUA + "Cloud Particle");
            item1.setItemMeta(itemM1);
         
            ItemStack item2 = new ItemStack(Material.WOOL, 1, DyeColor.ORANGE.getData());
            ItemMeta itemM2 = item2.getItemMeta();
            itemM2.setDisplayName(ChatColor.RED + "Heart Particle");
            item2.setItemMeta(itemM2);
         
            ItemStack item3 = new ItemStack(Material.WOOL, 1, DyeColor.YELLOW.getData());
            ItemMeta itemM3 = item3.getItemMeta();
            itemM3.setDisplayName(ChatColor.YELLOW + "Flame Particle");
            item3.setItemMeta(itemM3);
         
            ItemStack item4= new ItemStack(Material.WOOL, 1, DyeColor.GREEN.getData());
            ItemMeta itemM4 = item4.getItemMeta();
            itemM4.setDisplayName(ChatColor.GRAY + "Note Particle");
            item4.setItemMeta(itemM4);
         
            ItemStack item5 = new ItemStack(Material.WOOL, 1, DyeColor.LIGHT_BLUE.getData());
            ItemMeta itemM5 = item5.getItemMeta();
            itemM5.setDisplayName(ChatColor.GOLD + "Barrier Particle");
            item5.setItemMeta(itemM5);
         
            ItemStack item6 = new ItemStack(Material.WOOL, 1, DyeColor.BLUE.getData());
            ItemMeta itemM6 = item6.getItemMeta();
            itemM6.setDisplayName("cloud");
            item6.setItemMeta(itemM6);
         
            ItemStack item7 = new ItemStack(Material.WOOL, 1, DyeColor.PURPLE.getData());
            ItemMeta itemM7 = item7.getItemMeta();
            itemM7.setDisplayName("cloud");
            item7.setItemMeta(itemM7);
    
         
            ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.BLACK.getData());
            ItemMeta glassm = glass.getItemMeta();
            glassm.setDisplayName(ChatColor.BLACK + "/");
            glass.setItemMeta(glassm);
         
         
    
    
    
         
         
    
            inv.setItem(0, glass);
            inv.setItem(1, glass);
            inv.setItem(2, glass);
            inv.setItem(3, glass);
            inv.setItem(4, glass);
            inv.setItem(5, glass);
            inv.setItem(6, glass);
            inv.setItem(7, glass);
            inv.setItem(8, glass);
            inv.setItem(9, glass);
            inv.setItem(10, item1);
            inv.setItem(11, item2);
            inv.setItem(12, item3);
            inv.setItem(13, item4);
            inv.setItem(14, item5);
            inv.setItem(15, item6);
            inv.setItem(16, item7);
            inv.setItem(17, glass);
            inv.setItem(18, glass);
            inv.setItem(19, glass);
            inv.setItem(20, glass);
            inv.setItem(21, glass);
            inv.setItem(22, glass);
            inv.setItem(23, glass);
            inv.setItem(24, glass);
            inv.setItem(25, glass);
            inv.setItem(26, glass);
            p.openInventory(inv);
         
         
    
         
         
    
         
         
         
         
    
    
    
         
    }
        @EventHandler
        public void onInventoryClick(InventoryClickEvent event){
            if(event.getInventory().getName().equalsIgnoreCase("Particles")){
                if(event.getCurrentItem() == null){
                    return;
                
             
            }
                event.setCancelled(true);
                if(event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatColor.AQUA + "Cloud Particle")){
                    Player p = (Player) event.getWhoClicked();
                    if(cloud.contains(p.getUniqueId())){
                    cloud.remove(p.getUniqueId());
                    p.sendMessage(ChatColor.GREEN + "Cloud turned off");
                    p.closeInventory();
                 
                }else{
                    cloud.add(p.getUniqueId());
                    heart.remove(p.getUniqueId());
                    flame.remove(p.getUniqueId());
                    note.remove(p.getUniqueId());
                    p.sendMessage(ChatColor.GREEN + "Cloud turned on");
                    p.closeInventory();
                }
                }
                 
                if(event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatColor.RED + "Heart Particle")){
                    Player p = (Player) event.getWhoClicked();
                        if(heart.contains(p.getUniqueId())){
                        heart.remove(p.getUniqueId());
     
                        p.sendMessage(ChatColor.GREEN + "Heart turned off");
                        p.closeInventory();
                     
                    }else{
                        heart.add(p.getUniqueId());
                        cloud.remove(p.getUniqueId());
                        flame.remove(p.getUniqueId());
                        note.remove(p.getUniqueId());
                        p.sendMessage(ChatColor.GREEN + "Heart turned on");
                        p.closeInventory();
                    }
                }
                        if(event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatColor.YELLOW + "Flame Particle")){
                    Player p = (Player) event.getWhoClicked();
                        if(flame.contains(p.getUniqueId())){
                        flame.remove(p.getUniqueId());
     
                        p.sendMessage(ChatColor.GREEN + "Flame turned off");
                        p.closeInventory();
                     
                    }else{
                        flame.add(p.getUniqueId());
                        cloud.remove(p.getUniqueId());
                        heart.remove(p.getUniqueId());
                        note.remove(p.getUniqueId());
                        p.sendMessage(ChatColor.GREEN + "Flame turned on");
                        p.closeInventory();
                     
                 
                    }
                        }
                        if(event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatColor.GRAY + "Note Particle")){
                            Player p = (Player) event.getWhoClicked();
                                if(note.contains(p.getUniqueId())){
                                note.remove(p.getUniqueId());
             
                                p.sendMessage(ChatColor.GREEN + "Note turned off");
                                p.closeInventory();
                             
                            }else{
                                note.add(p.getUniqueId());
                                cloud.remove(p.getUniqueId());
                                flame.remove(p.getUniqueId());
                                heart.remove(p.getUniqueId());
                                p.sendMessage(ChatColor.GREEN + "Note turned on");
                                p.closeInventory();
            }
                        }
                     
                        }
                     
            }
     
     
     
        @EventHandler
        public void onMove(PlayerMoveEvent e){
            double radius = 2;
            double maxHeight = 100;
         
            for(double y= 0; y < maxHeight; y += 0.05){
                double x = Math.sin(y * radius);
                double z = Math.cos(y * radius);
                Player p = e.getPlayer();
                Location l = (Location) p.getLocation();
             
     
             
         
     
    
            if (cloud.contains(e.getPlayer().getUniqueId())) {
                ParticleEffect.CLOUD.display(0, 0, 0, 1, 10, l, 15);
             
             
            }
            if (heart.contains(e.getPlayer().getUniqueId())) {
                ParticleEffect.HEART.display(0, 0, 0, 1, 10, l, 15);
             
             
     
             
            }
         
         
             
             
            if (flame.contains(e.getPlayer().getUniqueId())) {
                ParticleEffect.FLAME.display((float) (l.getX() + x), (float) (l.getY() + y), (float) (l.getZ() + z), 1, 1, p.getLocation(), 15);
            }
         
            if (note.contains(e.getPlayer().getUniqueId())) {
                ParticleEffect.NOTE.display(0, 0, 0, 1, 100, l, 15);
    
             
    
         
            }
             
            }
    
    
             
            }
     
     
            }
    
    
    
    
     
        
     
  18. Offline

    Abdalion

    Hi. Im using the -- ParticleEffect.CLOUD.display(direction, speed, center, range); --
    But it only sends 1 particle at a time. How would i set it to send more?

    btw, really usefull library.
     
  19. Offline

    RingOfStorms

    When using direction you can only send 1 per call, so make a for loop to send more than 1.
     
  20. Offline

    RickPlayingPL

    Pls help meh

    Code:
    Code:
    ParticleEffect.SMOKE_LARGE.display(0.3f, 0.5f, 0.3f, 0.2f, 30, player.getLocation(), 20);
    Error:
    [​IMG]
     
  21. Offline

    RingOfStorms

    I doubt anyone will be able to accurately help you when you post only one line of code that has actually nothing to do with the error that you screen shot. In the future, post ALL relevant code, and paste the error in code tags as that screen shot is horrible to look at.
     
  22. Offline

    BagduFagdu

    What's an example to color a particle?
     
  23. Offline

    ChocoCraft

    @BagduFagdu > I try also to made colored particles.
    Only some particles could work with colors, like SPELL_MOB, NOTE, SPELL_MOB_AMBIENT

    ParticleEffect.<Particle>.display(new ParticleEffect.OrdinaryColor(RED, BLUE, GREEN), player.getLocation(), 1);

    I've try this to show colored particles:
    ParticleEffect.NOTE.display(new ParticleEffect.OrdinaryColor(030, 140, 150), player.getLocation().add(0, 0.7, 0), 1);

    But it doesn't work :(
     
  24. Offline

    guitargun

    if I am correct the note only changes color with the set speed
     
  25. Offline

    DarkBladee12

    @ChocoCraft
    You have to create an instance of NoteColor instead of OrdinaryColor for the NOTE effect!
     
  26. Offline

    RickPlayingPL

    This is my code and Im getting error.

    Code:
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
    ParticleEffect.SMOKE_LARGE.display(0.3f, 0.5f, 0.3f, 0.2f, 30, event.getPlayer().getLocation(), 20);
    }
     
  27. Offline

    VortexGmer

    Code:
    if (commandLabel.equalsIgnoreCase("particles")){
                Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                    public void run() {
                        ParticleEffect.CLOUD.display(0,0,0,0,0,1,0);
                    }
                }, 0, 20);
    should it work?
    for me it generates an error in the .display part
    The error is The method display(float, float, float, float, int, Location, double) in the type ParticleEffect is not applicable for the arguments (int, int, int, int, int, int, int)
    How would I fix this?
     
  28. Offline

    RingOfStorms

    I think the error is VERY self explanatory, you're trying to pass integers in for a Location object. The method requires 4 floats, an int, then a location then a double. Int can be used for all the numbers in this case, but you can't just say location "1"
     
  29. Offline

    VortexGmer

    ok thanks! got it working!
     
  30. Offline

    MrDplugins

    @DarkBladee12 Hi How would I change your code to allow for doubles? I need them for a special particle effect I'm making to have the effect swirl around the players head.

    EDT: Nevermind I found another way :)
     
    Last edited: Mar 9, 2015
Thread Status:
Not open for further replies.

Share This Page