Creating Fire At Crosshair

Discussion in 'Plugin Development' started by lethaltactics, Nov 5, 2012.

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

    lethaltactics

    Okay so I've got a plugin and I was planning on adding fire at a radius configurable from my config.yml, the fire would either be created where the player's cross hair was or around a player of choice. So such as /FSmite [Player].
    Here is the code I have so far.

    Code:
           if(commandLabel.equalsIgnoreCase("fsmite")&&player.hasPermission("smite.fsmite")) {
                if(args.length == 0)  {
                    Block targetblock = player.getTargetBlock(null,  100);
                    Location location = targetblock.getLocation();
                    player.sendMessage(ChatColor.GRAY + "Lightning with fire at Crosshair");
                    world.strikeLightning(location);  
                } else if (args.length == 1) {
                    if(player.getServer().getPlayer(args[0]) != null) {
                        Player targetplayer = player.getServer().getPlayer(args[0]);
                        Location location = targetplayer.getLocation();
                        world.strikeLightning(location);
                        
                        
                        player.sendMessage(ChatColor.GRAY + "Creating lightning with fire at " + targetplayer.getDisplayName());
                    } else {
                        player.sendMessage(ChatColor.RED + "Error: That player is offline.");
                    }
                } else if (args.length > 1) {
                    player.sendMessage(ChatColor.RED + "Error: Too many arguements!");
                }
                return false;
        }
    Any help at all would be very appreciated. Thanks!
     
  2. Offline

    lethaltactics

    any help would be appreciated
     
  3. Offline

    cman1885

    All of what you need is in your code?
     
  4. Offline

    lethaltactics

    no I don't not know what code to use for creating a radius of fire above the ground around the player or at crosshair
     
  5. Offline

    fireblast709

    Use the mathematical formula for a circle: x^2+y^2 = r^2
    Code:java
    1. // Get the origin of your circle (your players x and z)
    2. int ox = p.getLocation().getBlockX();
    3. int oz = p.getLocation().getBlockX();
    4. // define radius yourself
    5. int radius = 10;
    6. double radiusSquared = Math.pow(radius, 2);
    7. for(int x = 0; x <= radius;x++)
    8. {
    9. for(int z = 0; z <= radius; z++)
    10. {
    11. if(Math.pow(x,2)+Math.pow(z, 2) <= radiusSquared)
    12. {
    13. Block b = p.getWorld().getHighestBlockAt(ox+x, oz+z);
    14. Block up = b.getRelative(BlockFace.UP, 1);
    15. up.setType(Material.FIRE);
    16. }
    17. }
    18. }

    [EDIT] forgot the translation, sorry :3
     
Thread Status:
Not open for further replies.

Share This Page