"Shooting" Particles to another entity.

Discussion in 'Plugin Development' started by q8minecraft, Oct 18, 2015.

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

    q8minecraft

    The title may be a bit confused, I honestly can't find a better title but hopefully it'll do..

    So I want to kind of "shoot" particles from the player to all nearby entities and damaging them, I know I could shoot an arrow and spawn particles on its location but is there a more efficient way of doing it ? For example without spawning the arrow ?

    This is my code.
    Code:
    public static Inspiration getInstance() {
            return instance;
        }
        public double r = 0.5;
        public int inc = 1;
       
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents(this,this);
            instance = this;
        }
        @EventHandler
        public void blank(PlayerToggleSneakEvent event){
                final Player player = event.getPlayer();
                new BukkitRunnable(){
                    double t = 2*Math.PI;
                        public void run(){
                            Location loc = player.getLocation();
                            t = t + Math.PI/8;
                            for(double phi = 0; phi <= 2*Math.PI; phi = phi + Math.PI/16) {
                                double x = 2*Math.cos(phi) * r;
                                double y = t*Math.exp(t) * Math.sin(t);
                                double z = 2*Math.sin(phi) * r;
                                loc.add(x,y,z);
                                ParticleEffect.FLAME.display(0, 0, 0,0,5,loc,10);
                                loc.subtract(x,y,z);
                            }
                                    double y2 = 0.1;
                                    player.teleport(player.getLocation().add(0,y2,0));
                                if (t > 30){
                                        this.cancel();
                                        player.sendMessage("stopped");
                                        double radius = 3D;
                                        List<Entity> near = player.getLocation().getWorld().getEntities();
                                        for(Entity e : near) {
                                            if(e.getLocation().distance(player.getLocation()) <= radius) {
                                                double x2 = e.getLocation().getX();
                                                double y21 = e.getLocation().getY();
                                                double z2 = e.getLocation().getZ();
                                            }
                                        }
                                }
                        }
                                              
                }.runTaskTimer(Inspiration.getInstance(), 1, 1);
        }
     
  2. Offline

    Scimiguy

    @q8minecraft
    Actually the arrow is probably the most efficient way to do it
     
  3. Offline

    q8minecraft

    @Scimiguy
    Hmm.. Alright, I'll try it, thanks!

    The only problem is that I've seen a video on it a while ago and wanted to shoot that beam, and I didn't notice an arrow being spawned.


    And I have another problem, is there any other way or teleporting the player without affecting their movements? Because teleport(); kinda screws up moving my head :p
     
  4. Offline

    Scimiguy

    @q8minecraft
    As far as I'm personally aware, the look location is handled by the client.
    I may be wrong though -- try playing with the pitch/yaw of the player on teleport
     
Thread Status:
Not open for further replies.

Share This Page