Sebi_zocer
Entwickler
- Beigetreten
- Nov. 30, 2019
- Beiträge
- 15
Hay,
das ist eine Aufgabe an alle Leute, die mit Java programmieren können.
Diese Methode soll überprüfen, ob eine Base (Eckpunkte sind lowx, highx, lowz und highz) (Im Baserand sind noch 3 Blöcke in jede Richtung extra drin, um Abstand zur anderen Base zu haben) mit dem äußerem Rand eine andere Region (region) überschneidet.
Beide Regionen sind 9x9 groß.
Das Ergebnis: Man kann überall seine Base hinsetzen, aber in den Eckpunkten der bestehenden Region geht das nicht.
Was hat Sebi falsch gemacht?
Tipp: Es gibt keine Schreibfehler. Der Code würde funktionieren...
das ist eine Aufgabe an alle Leute, die mit Java programmieren können.
Diese Methode soll überprüfen, ob eine Base (Eckpunkte sind lowx, highx, lowz und highz) (Im Baserand sind noch 3 Blöcke in jede Richtung extra drin, um Abstand zur anderen Base zu haben) mit dem äußerem Rand eine andere Region (region) überschneidet.
Beide Regionen sind 9x9 groß.
Java:
public static boolean isSomehowInRegion(Region region, int lowx, int highx, int lowz, int highz){
int currentlowx = 1;
int currenthighx = 2;
int currentlowz = 3;
int currenthighz = 4;
Bukkit.getConsoleSender().sendMessage("Checking §e" + region.getName());
if(region.isBase()){
Base b = RegionManager.getBase(region);
currentlowx = b.getCoreX() - b.getRange();
currenthighx = b.getCoreX() + b.getRange();
currentlowz = b.getCoreZ() - b.getRange();
currenthighz = b.getCoreZ() + b.getRange();
} else if(region.isCube()) {
Cube c = RegionManager.getCube(region);
currentlowx = c.getLowloc().getBlockX();
currenthighx = c.getHighloc().getBlockX();
currentlowz = c.getLowloc().getBlockZ();
currenthighz = c.getHighloc().getBlockZ();
} else if(region.isSpawn()) {
//not working properly
if(isInSpawn(new Location(RegionManager.getSpawn().getSpawn().getWorld(), lowx + ((highx - lowx) / 2), 0, lowz + ((highz - lowz) / 2)))) {
return true;
} else if(isNearSpawn(lowx, highx, lowz, highz)) {
return true;
}
}
if(currentlowx + currenthighx + currentlowz + currenthighz != 10) {
boolean xcord = false;
boolean zcord = false;
boolean b1 = highx >= currentlowx;
boolean b2 = highx <= currenthighx;
boolean b3 = lowx >= currentlowx;
boolean b4 = lowx <= currenthighx;
boolean b5 = highz >= currentlowz;
boolean b6 = highz <= currenthighz;
boolean b7 = lowz >= currentlowz;
boolean b8 = lowz <= currenthighz;
if((b1 && b2) || (b3 && b4)) {
xcord = true;
}
Bukkit.getConsoleSender().sendMessage((b1 ? "§a" : "§c") + highx + " >= " + currentlowx + " §7&& " + (b2 ? "§a" : "§c") + highx + " <= " + currenthighx);
Bukkit.getConsoleSender().sendMessage((b3 ? "§a" : "§c") + lowx + " >= " + currentlowx + " §7&& " + (b4 ? "§a" : "§c") + lowx + " <= " + currenthighx);
if((b5 && b6) || (b7 && b8)) {
zcord = true;
}
Bukkit.getConsoleSender().sendMessage((b5 ? "§a" : "§c") + highz + " >= " + currentlowz + " §7&& " + (b6 ? "§a" : "§c") + highz + " <= " + currenthighz);
Bukkit.getConsoleSender().sendMessage((b7 ? "§a" : "§c") + lowz + " >= " + currentlowz + " §7&& " + (b8 ? "§a" : "§c") + lowz + " <= " + currenthighz);
if(xcord && zcord) {
return true;
}
}
return false;
}
Was hat Sebi falsch gemacht?
Tipp: Es gibt keine Schreibfehler. Der Code würde funktionieren...
Zuletzt bearbeitet: