Delete Blocks With Location

Discussion in 'Plugin Development' started by MnMaxon, Jul 15, 2012.

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

    MnMaxon

    I'm attempting to make a plug-in for a pvp/survival map called TheWalls,
    and I need a plugin to change blocks at certain locations to air, or zero, or something.
    I tried to do it, but failed miserably, if anyone can help, I would extremely appreciate it.
     
  2. Offline

    bitWolfy

    If I remember correctly...

    Code:
    loc.getBlock().setType(Material.AIR);
    EDIT: I suppose that you also need a way to get all blocks in a certain area...
    Given that loc0 represents the corner with the largest X,Y,Z coordinates, loc1 represents the corner with the smallest X,Y,Z coordinates:

    Code:
    for(int x = loc1.getBlockX(); x < loc0.getBlockX; x++) {
      for(int z = loc1.getBlockZ(); z < loc0.getBlockZ; z++) {
        for(int y = loc1.getBlockY(); y < loc0.getBlockY; y++) {
          // do stuff here
        }
      }
    }
    That's pretty basic stuff here ;)
     
  3. Offline

    MnMaxon

    Thank you, this will help a lot.

    Is there a way to set the world in the location? I keep using player.getWorld, and it's not going to work for this.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  4. Offline

    Kodfod

    Depends on what you are doing and when. Can you post a snipit of your code where player.getWorld(); wouldnt work?
     
  5. Offline

    MnMaxon

    Code:
    while (xx<=409 && zz<=-731) {
                                    //TODO
                                    Location delPlanksXLocation = new Location(onlinePlayer.getWorld(), xx, 112,
                                            -409);
                                    Location delPlanksXLocation = new Location(onlinePlayer.getWorld(), 347, 112,
                                            zz);
                                    delPlanksXLocation.getBlock().setType(Material.AIR);
                                    delPlanksZLocation.getBlock().setType(Material.AIR);
                                    xx--;
                                    zz--;
                                }
    (ignore the //TODO)
     
  6. Offline

    dark navi

    You can create a new location by passing a different world, but the same coordinates of another location. Here is one constructor for Location:
    Code:
    public Location(World world,
            double x,
            double y,
            double z)
     
  7. Offline

    MnMaxon

    Thank you, dark navi, but when I posted that into my code I got a lot of errors, and I wasn't sure how to use it, is there another way, or could someone explain how to do it, or give me a link explaining it?
     
Thread Status:
Not open for further replies.

Share This Page