0

I'm working on a plugin for the minecraft server api known as Bukkit.

My issues are getting the blocks as I don't know how to achieve this.

At the moment, I have the following:

public boolean loadSigns(Location loc1, Location loc2){
    Selection selection = new Selection(loc1, loc2);
    if(selection.getMax().getBlockY() - selection.getMin().getBlockY() != 0){
        return false;
    }
    if ((selection.getMax().getBlockX() - selection.getMin().getBlockX()) != 0 && (selection.getMin().getBlockZ() - selection.getMax().getBlockZ() != 0)) {
        return false;
    }       
    World w = loc1.getWorld();
    Integer x1 = loc1.getBlockX();
    Integer y1 = loc1.getBlockY();
    Integer z1 = loc1.getBlockZ();
    Integer x2 = loc2.getBlockX();
    Integer z2 = loc2.getBlockZ();
    @SuppressWarnings("deprecation")
    int dir = new Location(w, x1, y1, z1).getBlock().getData();
    if (x1 - x2 == 0) {
        for (int a = Math.max(x1, x2); a >= Math.min(x1, x2); a--) {
            Location l = new Location(w, a, y1, z1);
            BlockState b = l.getBlock().getState();
            if (b instanceof Sign) {
                signs.add((Sign) b);
            } else {
                return false;
            }
        }
    } else {
        for (int a = Math.min(z1, z2); a <= Math.max(z1, z2); a++) {
            Location l = new Location(w, x1, y1, a);
            BlockState b = l.getBlock().getState();
            if (b instanceof Sign) {
                signs.add((Sign) b);
            } else {
                return false;
            }
        }
    }
    if (dir == 3 || dir == 5) {
        Collections.reverse(signs);
    }
    update();
    return true;
}

loc1 is the left/start of the sign row; loc2 is the end/right of the sign row.

The problem with this is that any sign facing east or west only gets the first/start sign and not any of the others. If you need to see any other code, please say so.

P.S. new Selection(Location, Location); is just a cuboid region.

Kondax Design
  • 175
  • 1
  • 1
  • 15
  • What exactly are you trying to achieve with this plugin? Are you trying to set blocks to signs? Are you trying to get all the signs in an area? Are you trying to set the text of the signs? – Jojodmo Mar 01 '14 at 20:08
  • @Jojodmo2010 I need to get all signs within a 2 dimensional line and add them to an array list. – Kondax Design Mar 01 '14 at 20:11
  • Add the locations, or the actual block to the list? – Jojodmo Mar 01 '14 at 23:45
  • @Jojodmo2010 Add the Sign block to the list, I already know how to do that.. What I'm having problems with is getting the signs in a row; it only loops the first sign if the sign is facing east/west. – Kondax Design Mar 02 '14 at 09:36

1 Answers1

0

Instead of posting here where most of the people have no idea how the Bukkit api works, ask here --> https://forums.bukkit.org/forums/plugin-development.5/ Because here the community is WAY nicer, and all questions are answered, even the ones that are just one sentence

user3269516
  • 59
  • 1
  • 1
  • 4