Library EffectLib - Manage your effects the nice way. (Text/Image in Particles)

Discussion in 'Resources' started by Slikey, Apr 21, 2014.

Thread Status:
Not open for further replies.
  1. If I do the tutorial I got a error:

    @Override
    public void onRun() {
    // Create 10 particles per iteration
    for (int i = 0; i < 10; i++) {
    // Location of effect
    Location location = entity.getLocation();
    // Randomize the location within a circle from 0 to 0.6 radius
    location.add(RandomUtil.getRandomCircleVector().multiply(RandomUtil.random.nextDouble() * 0.6d));
    // Randomize height
    location.add(0, RandomUtil.random.nextFloat() * 2, 0);
    // Create packet, to send to the player
    PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(ParticleType.FLAME.getParticleName(), (float) location.getX(), (float) location.getY(), (float) location.getZ(), 0, 0, 0, 0, 0);
    // Sends the effect to every player within "visibleRadiusSquared" radius
    sendPacket(packet, location, visibleRadiusSquared);
    }

    }

    So can you help me because particletype, visibleradiussquared and randomutil give me a error.
     
  2. Offline

    Slikey

  3. Hey Slikey,
    Thank you for the new code, I have got a theme park server and there we make a watershow with effects and we want to make our own effects.

    Thank you!
     
  4. Offline

    TheNoim

    Slikey
    I Have this Error:
    Code:java
    1. [22:25:16] [Server thread/INFO]: TheNoim: Reload complete.
    2. [22:25:21] [Server thread/INFO]: TheNoim issued server command: /start
    3. [22:25:21] [Server thread/INFO]: [Brolaf] Der Countdown ist gestartet !
    4. [22:25:30] [Server thread/WARN]: [Effect Library] Task #3 for EffectLib vv1.4 generated an exception
    5. at de.slikey.effectlib.util.ParticleEffect.getPlayers(ParticleEffect.java:273) ~[?:?]
    6. at de.slikey.effectlib.util.ParticleEffect.display(ParticleEffect.java:466) ~[?:?]
    7. at de.slikey.effectlib.util.ParticleEffect.display(ParticleEffect.java:470) ~[?:?]
    8. at de.slikey.effectlib.effect.TextLocationEffect.onRun(TextLocationEffect.java:91) ~[?:?]
    9. at de.slikey.effectlib.Effect.run(Effect.java:77) ~[?:?]
    10. at org.bukkit.craftbukkit.v1_7_R2.scheduler.CraftTask.run(CraftTask.java:53) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-14-g8f8716c-b3039jnks]
    11. at org.bukkit.craftbukkit.v1_7_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:345) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-14-g8f8716c-b3039jnks]
    12. at net.minecraft.server.v1_7_R2.MinecraftServer.v(MinecraftServer.java:590) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-14-g8f8716c-b3039jnks]
    13. at net.minecraft.server.v1_7_R2.DedicatedServer.v(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-14-g8f8716c-b3039jnks]
    14. at net.minecraft.server.v1_7_R2.MinecraftServer.u(MinecraftServer.java:548) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-14-g8f8716c-b3039jnks]
    15. at net.minecraft.server.v1_7_R2.MinecraftServer.run(MinecraftServer.java:459) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-14-g8f8716c-b3039jnks]
    16. at net.minecraft.server.v1_7_R2.ThreadServerApplication.run(SourceFile:618) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-14-g8f8716c-b3039jnks]


    This is my Code:
    https://bitbucket.org/TheNoim/brolaf/src
    I have ask in a othe Forum ([DE]http://postcrafter.de/viewtopic.php?f=18&t=1448) and they say that is a error from the lib and not from me. Sry for my bad English i'm German...
    I hope i get help

    MFG Nils
     
  5. Offline

    coco5843

    why you put it every time :

    EffectLib lib = EffectLib.instance();
    EffectManager em = new EffectManager(lib);
     
  6. Offline

    TheNoim

  7. Offline

    Slikey

    Please tag me next time. coco5843 is right here. Dont make a new EffectManager for each Effect. Try to instantiate as few objects as possible.

    This is not an issue with my library. It's just your code:
    Code:java
    1. World w = Bukkit.getWorld("projekt");

    Is null, I think.

    And something additionally in German:
    Sag den Leuten im PostCrafter Forum, dass sie besser in deinen Code h├Ątten schauen sollen.
     
  8. Offline

    TheNoim

  9. Offline

    MrRump

    It is also possible to send an affect not to all players within a certain radius, but only to a single player? :)
     
  10. Offline

    Slikey

    Please send me a link to the exact source. Not only the project.

    Yes, just look at line 466:
    https://github.com/Slikey/EffectLib.../de/slikey/effectlib/util/ParticleEffect.java


    Okay, I found it. But please send good links next time.

    Try this:
    Code:java
    1. package Brolaf;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.World;
    7. import org.bukkit.entity.Player;
    8.  
    9. import de.slikey.effectlib.EffectLib;
    10. import de.slikey.effectlib.EffectManager;
    11. import de.slikey.effectlib.effect.TextLocationEffect;
    12.  
    13. public class Countdown {
    14.  
    15. private int time = 20;
    16. private final Brolaf plugin;
    17. private final Set s;
    18.  
    19. public Countdown(Brolaf plugin, Set s) {
    20. this.plugin = plugin;
    21. this.s = s;
    22. }
    23.  
    24. public void countDown(final Player p) {
    25. Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&b[&4Brolaf&b] &6Der Countdown ist gestartet !"));
    26. plugin.count = true;
    27.  
    28. World w = p.getWorld();
    29. double x = s.cfg.getDouble("x");
    30. double y = s.cfg.getDouble("y");
    31. double z = s.cfg.getDouble("z");
    32. Location loc = new Location(w, y, z, x);
    33.  
    34. EffectLib lib = EffectLib.instance();
    35. EffectManager em = new EffectManager(lib);
    36.  
    37. final TextLocationEffect effect = new TextLocationEffect(em, loc);
    38. effect.text = String.valueOf(time);
    39. effect.period = 10;
    40. effect.infinite();
    41. effect.start();
    42. em.disposeOnTermination();
    43.  
    44. final int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
    45.  
    46. @Override
    47. public void run() {
    48. time--;
    49.  
    50. if (time > 0) {
    51. effect.text = String.valueOf(time);
    52. } else if (time == 0) {
    53. effect.text = "START";
    54. effect.cancel();
    55. plugin.count = false;
    56. }
    57. }
    58.  
    59. }, 20L, 20L);
    60.  
    61. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    62.  
    63. @Override
    64. public void run() {
    65. Bukkit.getScheduler().cancelTask(task);
    66. }
    67.  
    68. }, time * 20L);
    69. }
    70.  
    71. }


    I didn't test. And i wrote it on notepad, so there might be some compiler errors

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

    valentinp72

    @Slikey, I actually have a problem.
    I'm preparing a event (a concert), and I used your library to add some effects, but, the particles are not shown when I am further than 16 blocks of the particles ... I open the librairie with Eclipse, and I change some thing in ParticlePacket (range's value, and I removed if(inRange(p.getLocation(),squared))), that not work. I also tried to modify the value of visibleRange in Effect.java, but I am always not able to see the particles when I am further than 16 blocks of them.

    How do I do to be able to see the particles further than 16 blocks ?

    Excuse-me for my bad English, I'm French. :p
     
  12. Offline

    Iroh

    Particle rendering distance is client side.
     
  13. Offline

    valentinp72

    Arf ... :/
    That's was what I thought, but, someone told me that was managed by the plugin.
    In a trailer of his server, we see that the particles were further than 16 blocs, and he don't use any mod :
     
  14. Offline

    LCastr0

    Depends of the particle. Fireworks particles can be edited in server side

    You can only see particles further than 16 blocks if the particles are the Fireworks one, and, if I'm not wrong, the smoke one (or explosion one... not sure)

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

    Slikey

    this :) valentinp72
     
    LCastr0 likes this.
  16. Offline

    PlusMCPKBPK

    Can you create mega wall shield effect ?
     
  17. Offline

    valentinp72


    Okay ...


    Does you know any mod, which allow to change the render distance of the particles ?
     
  18. Offline

    LCastr0

    I don't think there's any mod that changes it
     
  19. Offline

    ItsOneAndTwo

    Now that is just pure epic.
    Definately gonna use that :p
     
  20. Offline

    rotm987

    I want The Code :)
    look amazing
     
  21. Offline

    coco5843

    yours I see that my videos are successful for what is rendered, the trick is to approach the particles and move away ... if slikey happens to these effects where I publish all my sources
     
  22. Offline

    surferdude999

    How would you make the particle effects above head, like on The Hypixel Network.
     
  23. Offline

    Slikey

    Hey,

    take a look at the MusicEntityEffect. :) This is a replica of the Hypixel effect.
     
  24. Offline

    ChipDev

    Lets start now!
    Packet one.
    Packet two.
    Packet three
    Packet four..
    ehh
    Packet nine hundred ninety nine
    This took me 393 ticks.
     
    bigteddy98 likes this.
  25. Offline

    $c0p3rZ'z

    Hi,
    How do you stop an effect from an entity ?
    like :
    Effect.stop(Player);
    Thanks !

    EDIT:

    I got it :

    Code:java
    1. public class Main extends JavaPlugin implements CommandExecutor, Listener {
    2.  
    3. private EffectManager effectManager;
    4. private ArrayList<Player> pp = new ArrayList<Player>();
    5. private HashMap<Player, Effect> ppp = new HashMap<Player, Effect>();
    6. private HashMap<Player, Effect2> pppp = new HashMap<Player, Effect2>();
    7.  
    8. public void onEnable() {
    9. Bukkit.getPluginManager().registerEvents(this, this);
    10. getCommand("test").setExecutor(this);
    11. getCommand("test2").setExecutor(this);
    12. EffectLib lib = EffectLib.instance();
    13. effectManager = new EffectManager(lib);
    14. }
    15.  
    16. public void onDisable() {
    17. effectManager.dispose();
    18. }
    19.  
    20. @EventHandler
    21. public void onQuit(PlayerQuitEvent e) {
    22. Player p = e.getPlayer();
    23. if (pp.contains(p)) {
    24. ppp.get(p).cancel(false);
    25. pppp.get(p).cancel(false);
    26. pppp.remove(p);
    27. ppp.remove(p);
    28. pp.remove(p);
    29. }
    30. }
    31.  
    32. public boolean onCommand(CommandSender sender,org.bukkit.command.Command cmd, String label, String[] args) {
    33. if (sender instanceof Player) {
    34. Player p = (Player) sender;
    35. if (cmd.getName().equalsIgnoreCase("test")) {
    36. if (!pp.contains(p)) {
    37. Effect effect = new Effect(effectManager, p);
    38. effect.delay = 5;
    39. effect.infinite();
    40. effect.start();
    41. Effect2 effect2 = new Effect2(effectManager, p);
    42. effect2.delay = 5;
    43. effect2.infinite();
    44. effect2.radius = 0.7f;
    45. effect2.start();
    46. ppp.put(p, effect);
    47. pppp.put(p, effect2);
    48. pp.add(p);
    49. }
    50. if (cmd.getName().equalsIgnoreCase("test2")) {
    51. if (pp.contains(p)) {
    52. ppp.get(p).cancel(false);
    53. pppp.get(p).cancel(false);
    54. pppp.remove(p);
    55. ppp.remove(p);
    56. pp.remove(p);
    57. }
    58. }
    59. }
    60.  
    61. }
    62. return true;
    63. }
    64. }
     
  26. Offline

    Slikey

    $c0p3rZ'z You should really use better variable names :/
     
    LCastr0 likes this.
  27. Offline

    LCastr0

    ;-; If he misses a p, all the work will be gone ;-;
     
    Slikey likes this.
  28. Offline

    $c0p3rZ'z

    Slikey
    Hi,
    I have a request:
    May you add a cylinder (not hollow) and we can configure the radius, the height and the amount of particle !
    It will be great !
    Thanks !
     
  29. Maybe you can do a little text tutorial on how to do all the calculations? I find them pretty confusing ;)
     
  30. Offline

    Nuskel


    It do not work for me...
    Do I have another version?

    I looked for your code:
    Show Spoiler
    Code:text
    1. public class ConeLocationEffect extends LocationEffect
    2. {
    3. public ParticleEffect particle = ParticleEffect.FLAME;
    4.  
    5. public float lenghtGrow = 0.05F;
    6.  
    7. public double angularVelocity = 0.1963495408493621D;
    8.  
    9. public int particles = 10;
    10.  
    11. public float radiusGrow = 0.006F;
    12.  
    13. public int particlesCone = 180;
    14.  
    15. public double rotation = 0.0D;
    16.  
    17. public boolean randomize = false;
    18.  
    19. protected int step = 0;
    20.  
    21. public ConeLocationEffect(EffectManager effectManager, Location location) {
    22. super(effectManager, location);
    23. this.type = EffectType.REPEATING;
    24. this.period = 1;
    25. this.iterations = 200;
    26. }
    27.  
    28. public void onRun()
    29. {
    30. for (int x = 0; x < this.particles; x++) {
    31. if (this.step > this.particlesCone)
    32. this.step = 0;
    33. if ((this.randomize) && (this.step == 0))
    34. this.rotation = RandomUtils.getRandomAngle();
    35. double angle = this.step * this.angularVelocity + this.rotation;
    36. float radius = this.step * this.radiusGrow;
    37. float lenght = this.step * this.lenghtGrow;
    38. Vector v = new Vector(Math.cos(angle) * radius, lenght, Math.sin(angle) * radius);
    39. VectorUtils.rotateAroundAxisX(v, (this.location.getPitch() + 90.0F) * 0.01745329F);
    40. VectorUtils.rotateAroundAxisY(v, -this.location.getYaw() * 0.01745329F);
    41.  
    42. this.location.add(v);
    43. this.particle.display(this.location, this.visibleRange, 0.0F, 0.0F, 0.0F, 0.0F, 0);
    44. this.location.subtract(v);
    45. this.step += 1;
    46. }
    47. }
    48. }


    (This is the download from date: june 28 2014)

    I tryed this:
    Show Spoiler
    Code:text
    1. ConeLocationEffect e = new ConeLocationEffect(em, p.getLocation());
    2. e.run();

    ... but there is only one particle under me! :(
     
Thread Status:
Not open for further replies.

Share This Page