[Help]About Generate effect

Discussion in 'Spigot Plugin Development' started by Absolutefield, Apr 30, 2017.

  1. I want to produce some effect around the player,But I do not know what to do
    The effect I generated was uncontrolled,I do not know why
    [​IMG]

    This is all my code, the comment part is what I retained in the experiment
    Code (Text):
    import org.bukkit.Bukkit;
    import org.bukkit.Effect;
    import org.bukkit.Location;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin implements Listener {

    public void onEnable(){
        getServer().getPluginManager().registerEvents(this, this);
        Bukkit.getConsoleSender().sendMessage("test");
    }
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event){
        Player player = event.getPlayer();
         double angle = 10;
         double radius = 1.0D;
         for (int i = 0; i < 360; i += angle){
         double x = Math.cos(Math.toRadians(i)) * radius;
          double z = Math.sin(Math.toRadians(i)) * radius;
       
         //Location playerLoc = player.getLocation();
         //Location l = new Location(playerLoc.getWorld(), x + playerLoc.getX(), 1.0D, z + playerLoc.getZ());
         //player.getWorld().playEffect(l, Effect.FLAME , 5);
          Location playerloc = player.getLocation();
          Location l = new Location(player.getWorld(), x+playerloc.getX(), 1.0D+playerloc.getY(), z+playerloc.getZ());
         player.getWorld().playEffect(l,Effect.FLAME,1);
        player.sendMessage("§fDetect that you are moving, giving effect");
         }
    }
    }
    /*public void createeffect(Player player){
         double angle = 10;
         double radius = 1.0D;
         for (int i = 0; i < 360; i += angle){
         double x = Math.cos(Math.toRadians(i)) * radius;
          double z = Math.sin(Math.toRadians(i)) * radius;
       
         Location playerLoc = player.getLocation();
         Location l = new Location(playerLoc.getWorld(), x + playerLoc.getX(), 1.0D, z + playerLoc.getZ());
         player.getWorld().playEffect(l, Effect.FLAME , 5);
         }
    }
    }
    */

    The correct thing should look like this
    [​IMG]

    please help me
     
    #1 Absolutefield, Apr 30, 2017
    Last edited: May 1, 2017
  2. Please don't type in full bold, full italic.
    Is the issue solved? If it is, please post the solution. If it's not, please don't mark the thread as solved.

    Flame effects are deprecated, use World#spawnParticle (with the "count" set to 1, "extra" (speed) set to 0 and use the offsetX, offsetY, offsetZ).
     
  3. Sorry for my fault,I did not notice it,The problem is not resolved
     
  4. Have you tried using particles, as I have recommended?
     
  5. I don't think it's a particle problem,Particles are generated in the round but not controlled
    [​IMG]