Solved Replace blocks with coordinate from file

Discussion in 'Plugin Development' started by shadow5353, Jun 23, 2014.

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

    shadow5353

    Hello,

    How can I replace a block with air if I only have the coordinates in a file?
     
  2. Offline

    ferrago

    If you know how configs work load in world name, x loc, y loc, z loc.
    Location loc = new Location(world, x, y, z);
    loc.getBlock().setType(Material.AIR);
     
  3. Offline

    MineCrashKoen

    You get the world, X, Y and Z.
    Then create a location out of that.
    Get the block.
    Set the type to air
    Code:java
    1. new Location(gottenWorldFromConfig, gottenXFromConfig, gottenYFromConfig, gottenZFromConfig).getBlock().setType(Material.AIR);


    Hope it helps :)

    Also, if the block already was air, you'll need to check if that block is not null first!
     
  4. Offline

    xTigerRebornx

    shadow5353 You'd want to save the world in that file too.
    World#getBlockAt() can get a Block from coordinates, and Bukkit#getWorld() can get a World from a String
     
  5. Offline

    shadow5353

    ferrago MineCrashKoen When I have put in the information from config I get a red line under it.

    xTigerRebornx I have the world saved. Should it be like this? Bukkit.getWorld(settings.getData().getString("tents." + uuid + ".world")).getBlockAt(x, y, z);

    xTigerRebornx After a few hours of trying, I finally got it working and I used your method. Thank you :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page