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. Offline

    iMurder

    You have created something amazing, and shared it with the community, the LEAST we could do, is show our simple appreciation :)
     
  2. Slikey This lib is the best thing i've ever seen!!!!!
    My request:
    Minecraft mobs and evtl. a statue builder for skins would be nice.
    That'll give you some work xD
     
  3. Offline

    coco5843

    I need help :D

    I would like to create laser effects with only random location
    But I use your code like this : player.getEyeLocation(), player.getEyeLocation().add(7.0D, 6.0D, -5.0D)
    And the lasers follow me whith random distance ..
    I want like just random location without player.geteyelocation

    Video demonstration:



    My source:

    Show Spoiler

    Code:
     
    package Laser;
     
    import java.util.Random;
     
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.HandlerList;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
    import de.slikey.effectlib.EffectLib;
    import de.slikey.effectlib.EffectManager;
    import de.slikey.effectlib.effect.LineLocationEffect;
    import de.slikey.effectlib.util.ParticleEffect;
     
    public class Laser extends JavaPlugin implements Listener {
     
    private FileConfiguration cfg;
    private EffectManager effectManager;
     
    @Override
    public void onEnable() {
     
    Bukkit.getPluginManager().registerEvents(this, this);
    cfg = getConfig();
    EffectLib lib = EffectLib.instance();
            effectManager = new EffectManager(lib);
    }
     
    @Override
    public void onDisable() {
     
    HandlerList.unregisterAll((Listener) this);
     
    }
     
    //Method to spawn disco floor
     
    public void Disco (final Player p ,  final World w , final int x , final int y , final int z ) {
     
     
    //Variable to create / delete and start scheduler
     final int id = Bukkit.getServer().getScheduler().runTaskTimer(this, new Runnable() {
     
     //start scheduler
                  public void run() {
                
                
                //define location
                  Location l = new Location(w , x , y ,z);
                  
                  //random method
                      Random r = new Random();
                      double d = 1 + r.nextInt(9 - 1);
                      double d1 = 1 + r.nextInt(9 - 1);
                      double d2 = 1 + r.nextInt(9 - 1);
                      double d3 = 1 + r.nextInt(9 - 1);
                       
                      
                      //Create variable LineLocationEffect
                      final LineLocationEffect effect = new LineLocationEffect(effectManager, l,  p.getEyeLocation().add(d, -6.0D, d1)); //Here I want to define random location direction ; and not geteyelocation
                      final LineLocationEffect effect2 = new LineLocationEffect(effectManager, l, p.getEyeLocation().add(d1, -6.0D, d));
                      final LineLocationEffect effect3 = new LineLocationEffect(effectManager, l, p.getEyeLocation().add(d2, -6.0D, d1));
                      final LineLocationEffect effect4 = new LineLocationEffect(effectManager, l, p.getEyeLocation().add(d3, -6.0D, d2 ));
                      
                      //define effect
                      effect.particle = ParticleEffect.RED_DUST;
                      effect2.particle = ParticleEffect.RED_DUST;
                      effect3.particle = ParticleEffect.RED_DUST;
                      effect4.particle = ParticleEffect.RED_DUST;
                      
                      
                      //start effect
                 effect.start();
                 effect2.start();
                 effect3.start();
                 effect4.start();
                 
                  }
              }, 15L, 15L).getTaskId();
               
     //stop scheduler with 500 ticks countdown
     
     Bukkit.getServer().getScheduler().runTaskLater(this , new Runnable() {
                  public void run() {
                      Bukkit.getServer().getScheduler().cancelTask(id);
                  }
              }, 500L);
     
    }
     
    //when player place diamondblock
     
    @EventHandler
    public void BlockPlaceEvent(BlockPlaceEvent e) {
     
     
    Material block = e.getBlock().getType();
     
    if (block == Material.DIAMOND_BLOCK) {
     
     
    Player p = e.getPlayer();
    String worldname = p.getWorld().getName();
     
    //Get position and variable
    int x = e.getBlock().getX();
    int y = e.getBlock().getY();
    int z = e.getBlock().getZ();
     
    //create save position in config.yml
     
    cfg.set(worldname + "." + p.getName() + "." + "X", x);
            cfg.set(worldname + "." + p.getName() + "." + "Y", y);
            cfg.set(worldname + "." + p.getName() + "." + "Z", z);
            saveConfig();
    }
     
     
     
    }
     
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label,
    String[] args) {
     
    final Player p = (Player) sender;
    final World w = p.getWorld();
     
     
     
     
    if (cmd.getName().equalsIgnoreCase("bloc")) {
     
    if (args.length == 0) {
     
     
    //define Material
    final int x = cfg.getInt(p.getWorld().getName() + "." + p.getName() + "." + "X", p.getWorld().getSpawnLocation().getBlockX());
               final int y = cfg.getInt(p.getWorld().getName() + "." + p.getName() + "." + "Y", p.getWorld().getSpawnLocation().getBlockY());
               final int z = cfg.getInt(p.getWorld().getName() + "." + p.getName() + "." + "Z", p.getWorld().getSpawnLocation().getBlockZ());
               
               //Calling method
                    this.Disco(p, w, x, y, z);
                    
                    
                   
                   
     
    }
    }
     
    return false;
     
    }
     
    }
     
    
    Code:
    
    
     
  4. Offline

    Slikey

    jofkos Hey, thank you very much :) I don't have time at the moment, but I will work on all requests, if I am back to EffectLib!

    coco5843 But do you exactly mean? Do you want a random direction for the Laser? Maybe you want to create your own Effect on the basis of LineLocationEffect? And if you want to laser on an entity. Maybe make the LineLocationEffect to a LineEntityEffect (you have to create it).
    You can get a Vector with random direction and lenght 1 from RandomUtils.getRandomVector().
     
  5. Offline

    coco5843

    Just create random direction , but when i create
    That, the distance between flame effect is big
    [Resolved] Thank's for private help slikey !
     
  6. Offline

    HeavyMine13

    A wrecking ball?! Lawl no jk
     
  7. Offline

    cast

    What do you mean bye // period * iterations = time of effect.
    Please help @gerSlikey
     
  8. Offline

    SoThatsIt

    period is the amount of ticks every time the effect iterates and iterations is the amount of iterations the effect does before it stops. So multiplying them would give you the total time in ticks that the effect is going for.
     
  9. Offline

    Slikey

  10. Offline

    jusjus112

    Slikey
    Nice lib. I love it
    But is there an way, when you shoot like an cone. how to damage the player that is hit by the cone?
     
  11. Offline

    Slikey

    jusjus112 Maybe if you spawn a particle, check the position and compare if a player is near.. I didn't implement collision stuff
     
  12. Offline

    LCastr0

    jusjus112 @Slikeyif there's a way to get the last position of the cone, you can do this:
    (Let's say you'll put someone on fire when it's close to the cone)
    Code:java
    1. for(Player online : Bukkit.getOnlinePlayers()){
    2. if(online.getLocation().distance(<last location of the cone>) <= 5){
    3. //Set player on fire here
    4. }
    5. }
     
  13. Offline

    SoThatsIt

    some problems with this:

    firstly, you have to check to make sure the player is in the same world as the cone or it will throw an error. Probably would be more efficient to get the players from the world. world.getPlayers() or something.

    secondly, use distanceSquared! the square root function is very resource intensive and doing it to every player online will cause lag. just use distanceSquared(<last location of the cone>) <= 5 * 5
     
    LCastr0 likes this.
  14. Offline

    LCastr0

    glen3b and SoThatsIt like this.
  15. Offline

    Slikey

    yeah, but just checking for a radius is pretty unsafe. the result might be correct in only 1/4 of the cases.. :/
     
  16. Offline

    jusjus112

    SoThatsIt Slikey
    i have tried that with using distanceSquared, but only the shooter is getting hurt!
    I have replaced tge < with >, but thats not working!
     
  17. Offline

    LCastr0

    Use an if to check if the player is the shooter or not
     
  18. Offline

    jusjus112

    LCastr0
    How do i check that, in an playerInterActEvent?
    I have tried it was an hashmap and an arraylist without succes!
     
  19. Offline

    TheGamblingMan

    Hey is it possible that i make a item and if the player right clicks that he enables the effect and when he clicks again that it disables the effect?
     
  20. Offline

    Pitazzo

  21. Offline

    Slikey

    Just call on the effect:
    effect.infinite();
    effect.type = EffectType.REPEATING;
    effect.start();

    Then save the Effect in a HashMap to a Player and if the player want's to cancel the effect, just call:
    effect.cancel();
     
  22. Offline

    TheGamblingMan

  23. Offline

    TheGamblingMan

    I have tried now a long time to start a event in another class with a effect but i can't figure out how it works i got it working in the main class but not in another
     
  24. Offline

    Slikey

    I think this is not an EffectLib related problem. :/
     
  25. Slikey Could you add something like this? I dont mean the whole grenade, just like the electric effect coming out from certain location ;) didnt find good picture for example...
     
  26. Offline

    LCastr0

    Someone_Like_You likes this.
  27. Offline

    surferdude999

    I am confused with the text thing. Could I have an example on how I would go forth making my own text effect thing. Thanks!
     
  28. Offline

    Slikey

    surferdude999 Have a look at GithUb. There is a Test Plugin as Project with all commands :)
     
  29. Offline

    Debels

    Slikey a suggestion for the lib which I'm currently implementing, add a method that we can listen to that will trigger every time there is a new iteration so the developer can do code there, like if we are using BleedEntityEffect we can remove half a heart each iteration (this is just an example of how it could be used).
     
  30. Offline

    Slikey

    Hey,
    i thought that you'd just recreate the effect from GitHub to do so.. Or just extend the Effect and run
    Code:java
    1. @Override
    2. public void run() {
    3. super.run();
    4. // remove hearts
    5. }

    Cause I hate instatiating objects^^
     
Thread Status:
Not open for further replies.

Share This Page