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

    It is not possible, the only color you can define is red for red dust and i think green for note by setting speed to 0. Nothing else can be defined besides the crack particles.
     
    DarkBladee12 likes this.
  2. Offline

    pookeythekid

    Apologies for being a bit off topic but...

    @DarkBladee12 I can't thank you enough for this amazing library. In my time of deepest despair (yes, I'm exaggerating; there were other [harder] ways to do this) this library provided a way for me to complete the explosion effects in my plugin that I've been dying to make. So thanks. :)
     
    DarkBladee12 likes this.
  3. Offline

    Olof Larsson

    @DarkBladee12 - The lack of cauldron support actually seems to be something that matters. Here is an issue I got reported on GitHub: https://github.com/MassiveCraft/MassiveCore/issues/200

    Anyways, could you not add Cauldron support? It's shouldn't be that hard right? Maybe take some inspiration from that Effect-lib-thingy people were talking about?
     
  4. Offline

    AdamQpzm

  5. Offline

    DarkBladee12

    @AdamQpzm Yes it is actually, but I don't think it's bad that I add compatibility for other server software ;)
     
  6. Offline

    jjssman

    Since the update I can't get it to work:
    Code:
    ParticleEffect.BLOCK_CRACK.display(new ParticleData(Material.WOOD, (byte) 0), 0.7F, 0.7F, 0.7F, 0.6F, 30, finalChestLoc.clone().add(0.5D, 0.7D, 0.5D), 30D);
    "Cannot instantiate the type ParticleEffect.ParticleData"
    Any idea about how to fix that?
     
    sander_blaadjes likes this.
  7. Offline

    DarkBladee12

    @jjssman You have to use BlockData if you want to play the BLOCK_CRACK or BLOCK_DUST effect!
     
    jjssman likes this.
  8. Offline

    jjssman

    That worked. Thanks! :D
     
  9. Offline

    MinecraftMart

    How to download those files? I press open in github for windows but nothing happens, yes i do have Git
     
  10. Offline

    RingOfStorms

    Turns out you can actually change the color of redstone, mobSpell, and mobSpellAmbient. So I was wrong about that.

    @DarkBladee12 In order to support colors and make it easy on developers it will require some work on your end. While it is an RGB format, it is not on the normal 0-255 scale, but instead does some bull crap percentage by decimal point. And to make it even harder, red defaults at 1, so you must always set the red part or 1 will be used. Another thing you will need to worry about is the fact that the speed will need to be a value of 1. From 1, as it approaches 0 it will turn black, and as it approaches 100 it will turn white.

    The packet values are multipliers that are sent from 0-1 as a float. This value is multiplied by 255 on the client.

    So lets say you want to make this ugly shade of blueish green on the client:
    [​IMG]
    RGB(76,194,172) you would have to do the following:

    Set count to 0
    Set speed to 1
    Set location to the location

    Then set offsetX (corresponds to the Red part) to
    Code:java
    1.  
    2. 76F/255F //about .298
    3.  


    Same for each of the other values where offsetY corresponds to G and offsetZ corresponds to B

    the final values approx.
    (.298,.761,.675)

    Then send the packet and observe the ugly shade of blue/green:
    [​IMG]
     
    mung3r and DarkBladee12 like this.
  11. Offline

    MinecraftMart

    How to use this library? Like import it?

    K well ive got it working, but how would i add a particle effect to a arrow?

    I use this code in 1.7 but it since i am using this library i cant send it as a packet.. or can i?
    Code:
     for(Player player : Bukkit.getOnlinePlayers()) {
                                         ((CraftPlayer) player).getHandle().playerConnection.sendPacket(ParticleEffect.SPELL_WITCH.display( (float) l.getX(), (float) l.getY(), (float) l.getZ(), 100f, 0, l , 30D));
                                    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 29, 2015
  12. Offline

    DarkBladee12

    @MinecraftMart This library sends also packets, but it's easier to use and has some extra features! If you wan to add a particle effect to an arrow, just make a runnable which calls the ParticleEffect#display method with the location of the arrow as long as it is in the air.

    @RingOfStorms Thanks for sharing this information with me, I'm going to implement methods for this soon!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 29, 2015
  13. Offline

    MinecraftMart

    @DarkBladee12

    I have no idea how to do that... can you give me an example?
     
  14. Offline

    mung3r

    @RingOfStorms as a quick test, I modified @DarkBladee12 's ParticleDemo to allow the lower limit for count to be zero instead of one. So far, no particles appear. If I set the count to 1, then a single particle of random color appears.

    Below is the method that sends the packet. I checked the values of the parameters that are set in the packet and everything seems to be in order. Any idea what could be going wrong?

    Code:
            public void sendTo(Location center, Player player) throws PacketInstantiationException, PacketSendingException {
                if (packet == null) {
                    try {
                        packet = packetConstructor.newInstance();
                        Object id;
                        if (version < 8) {
                            id = effect.getName();
                            if (data != null) {
                                id += data.getPacketDataString();
                            }
                        } else {
                            id = enumParticle.getEnumConstants()[effect.getId()];
                        }
                        ReflectionUtils.setValue(packet, true, "a", id);
                        ReflectionUtils.setValue(packet, true, "b", (float) center.getX());
                        ReflectionUtils.setValue(packet, true, "c", (float) center.getY());
                        ReflectionUtils.setValue(packet, true, "d", (float) center.getZ());
                        ReflectionUtils.setValue(packet, true, "e", offsetX);
                        ReflectionUtils.setValue(packet, true, "f", offsetY);
                        ReflectionUtils.setValue(packet, true, "g", offsetZ);
                        ReflectionUtils.setValue(packet, true, "h", speed);
                        ReflectionUtils.setValue(packet, true, "i", amount);
                        if (version > 7) {
                            ReflectionUtils.setValue(packet, true, "j", longDistance);
                            ReflectionUtils.setValue(packet, true, "k", data == null ? new int[0] : data.getPacketData());
                        }
                    } catch (Exception exception) {
                        throw new PacketInstantiationException("Packet instantiation failed", exception);
                    }
                }
                try {
                    sendPacket.invoke(playerConnection.get(getHandle.invoke(player)), packet);
                } catch (Exception exception) {
                    throw new PacketSendingException("Failed to send the packet to player '" + player.getName() + "'", exception);
                }
            }
     
  15. Offline

    RingOfStorms

    I haven't read the code snippet yet but Dark already made methods that allow for count 0 for directional particles that I explained in a previous thread. I personally don't actually use Dark's library and use my own so there isn't a whole lot I will be able to help you with on the code part from his classes, haven't really looked at how he is doing things. All I can say is that it does work and I've tested it on my system thoroughly.

    If all you did was modify the demo then chances are the lower limit is set back to 1 possibly depending on the method in the library you are using. He said he would be adding in support for this so it should be out soon and you won't have to worry about it!

    Edit: Just as a little spoiler as to what made me look into colors again is the new Mizzle 2 adventure map. It is pretty dang cool and I noticed he used colored red dust in one of his bonus levels. I investigated and discovered that is was similar to the directional particles and count 0 trick, just never really got to it before.

    @DarkBladee12 Since you already did the directional vector particles, you probably have all the code already there, you just need to make a method that accepts an RGB color and then set the vector x,y,z to the decimal percentages.
     
  16. Offline

    SkyLegion

    Hey,

    I am using your library and everything works great. However I have one problem. The particles literally shoot 40 blocks away from the character and I only want them to go 5 away, or else it makes the player look overly important and too crowded of an effect. I'm not sure how I do that, I have tried to edit all parts of parameters, mainly the distance and offsets. Would you please explain how to make the particles only appear so far from the character?

    Code:
    for (String s: PEManager.flame){
                        ParticleEffect.FLAME.display(0, 0, 0, 2, 50, Bukkit.getPlayer(s).getLocation().add(0, 1, 0), 20);
                    }    
     
  17. Offline

    RingOfStorms

    On another note, it would be awesome if DarkBlade could make a little special something so that I don't have to.

    After realizing the colored red dust is possible, and now that we have a render distance over-ride, it is a very clear possibility to do simple shapes with color.

    A while back I made a twitter post about the 3D models I was importing and displaying with particles:
    [​IMG]

    Now I've come up with another idea, which is to be able to import a 3D model with it's textures. We can read the texture's colors and turn the color into an RGB and then display that color of red dust at that corresponding part of the model in 3d space.

    Heck, if we really wanted to get crazy then we could support model animations and play back moving models within minecraft, with color.

    The only flaw with this system is the particle limit, which is something that can't be changed server side, and so objects will have to have minimal complexity as to not breach that cap.

    @DarkBladee12 it would be cool if you take some inspiration from this idea and totally make it. Hint hint nudge nudge.
     
    PDKnight and ChipDev like this.
  18. Offline

    MinecraftMart

    So i got this code:
    Code:
    final Arrow ar = p.launchProjectile(Arrow.class);
                            final ArrayList<Projectile> arrow = new ArrayList<Projectile>();
                            arrow.add((Projectile) ar);
                           
                            BukkitTask task = new BukkitRunnable() {
                                @Override
                                public void run() {
                                    Location l = ar.getLocation();
                                    if(ar.isOnGround()){
                                        return;
                                    }
                                    else if(ar.isDead()){
                                        return;
                                    }
                                    else{
                                        for(Player player : Bukkit.getOnlinePlayers()) {
                                            ParticleEffect.FLAME.display( 0, 0, 0, 0f, 100, l, player);
                                        }
                                    }
                                  
                                }
                            }.runTaskTimer(main, 0, 0);
                            arrowTasks.put(ar.getEntityId(), task.getTaskId());
                   
                            ar.setShooter(p);
                            ar.setVelocity(p.getLocation().getDirection().multiply(3));
    How would i set it so the flame particle appears every movement it makes, now i can clearly see a gap between the particles.
     
    Last edited: Dec 28, 2014
  19. Offline

    mung3r

    I did account for the check in the lib. You kinda have to, since it throws an IllegalArgumentException.

    I guess I'll play with it a bit more until it works or @DarkBladee12 does his update; whichever comes first.
     
  20. Offline

    MinecraftMart

    So i tried this with SPELL_MOB, there are lots of random colors when i have this:
    Code:
    ParticleEffect.SPELL_MOB.display( 255F/255F, 0, 0, 1f, 1, l, player);
    @RingOfStorms
     
  21. Offline

    ChipDev

    You cannot change the colors of them. They are random with speed.
     
  22. Offline

    MinecraftMart

    @ChipDev
    But he just explained it could...
     
  23. Offline

    RingOfStorms

    The amount must be set to 0. When the amount of particles is set to 0 it unlocks several different features like setting the velocity, or changing the color in these three particles.

    It is indeed possible, scroll up to the post I made explaining it. I may just make another thread for it, but it is pretty much the same exact thing as directional ones but with mob/mobaura/red dust and a value between 0-1 for the vector 3.
     
  24. Offline

    MinecraftMart

    So would this work?
    Code:
    ParticleEffect.SPELL_MOB.display( 255F/255F, 255F/255F, 0, 0f, 0, l, player);
     
  25. Offline

    ChipDev

    Oh.. Oops ^_^

    For me, setting the count to zero does nothing - Meaning.. nothing... no particles etc

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 29, 2015
  26. Offline

    DarkBladee12

    @ChipDev

    That's strange, it works perfectly for me. Did you use my library and set the amount to zero? Because there's a check which doesn't allow an amount of zero.

    @RingOfStorms

    It seems that the speed value controls the brightness of the color. I also noticed that setting the red part to 0 works for the SPELL_MOB and SPELL_MOB_AMBIENT effects. (I tested it with RGB(0, 185, 24) which is normally green and would be orange if the red part is set to 255) It only appears that the REDSTONE effect will set the red part to 1 if set to 0! Moreover the brightness of the color varies when using this effect.
     
    Last edited: Dec 30, 2014
  27. Offline

    ChipDev

    Oh, so NMS only allows it? I had a usage of your lib.
     
  28. Offline

    DarkBladee12

    @ChipDev

    This check doesn't allow an amount lower than 1. You could easily remove it and test it then ;)
     
  29. Offline

    guitargun

    @RingOfStorms well that is great news. now the hardest part is indeed to use the right color. time for some method's and classes for color.
     
  30. Offline

    Olof Larsson

Thread Status:
Not open for further replies.

Share This Page