Hey,
ich habe eine Methode zum spawnen von Blöcken im Rechteck um eine Location.
Jedoch wenn eine der Koordinaten z.B.: x oder z im negativen Bereich ist, wird mir anstelle des negativen Werts nur eine 0 ausgegeben.
Wie kann ich die Methode so verändern, dass sie auch ins negative rechnen kann?
Code
private void highlightIslandBorders(Location loc) {
World world = loc.getWorld();
int sx = loc.getBlockX();
sx -= sx % islandSize;
int sz = loc.getBlockZ();
sz -= sz % islandSize;
if ((sx < 0) || (sz < 0)) {
return;
}
int ex = sx + islandSize - 1;
int ez = sz + islandSize - 1;
int y = loc.getBlockY() - 1;
Material cornerMat = Material.GLOWSTONE;
world.getBlockAt(sx, y, sz).setType(cornerMat);
world.getBlockAt(ex, y, sz).setType(cornerMat);
world.getBlockAt(sx, y, ez).setType(cornerMat);
world.getBlockAt(ex, y, ez).setType(cornerMat);
}
Alles anzeigen