mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-11-22 11:35:16 +01:00
parent
e7a77bf2a1
commit
a9fedeab32
@ -36,6 +36,7 @@ public class BarrelBody {
|
||||
if (bounds == null || bounds.area() > 64 ) {
|
||||
// If loading from old data, or block locations are missing, or other error, regenerate BoundingBox
|
||||
// This will only be done in those extreme cases.
|
||||
P.p.log("Regenerating Barrel BoundingBox: " + (bounds == null ? "was null" : "area=" + bounds.area()));
|
||||
Block broken = getBrokenBlock(true);
|
||||
if (broken != null) {
|
||||
barrel.remove(broken, null, true);
|
||||
|
@ -298,6 +298,10 @@ public class P extends JavaPlugin {
|
||||
metrics.addCustomChart(new Metrics.SimplePie("v2_mc_version", () -> {
|
||||
String mcv = Bukkit.getBukkitVersion();
|
||||
mcv = mcv.substring(0, mcv.indexOf('.', 2));
|
||||
int index = mcv.indexOf('-');
|
||||
if (index > -1) {
|
||||
mcv = mcv.substring(0, index);
|
||||
}
|
||||
if (mcv.matches("^\\d\\.\\d{1,2}$")) {
|
||||
// Start, digit, dot, 1-2 digits, end
|
||||
return mcv;
|
||||
@ -309,6 +313,10 @@ public class P extends JavaPlugin {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>(3);
|
||||
String mcv = Bukkit.getBukkitVersion();
|
||||
mcv = mcv.substring(0, mcv.indexOf('.', 2));
|
||||
int index = mcv.indexOf('-');
|
||||
if (index > -1) {
|
||||
mcv = mcv.substring(0, index);
|
||||
}
|
||||
if (mcv.matches("^\\d\\.\\d{1,2}$")) {
|
||||
// Start, digit, dot, 1-2 digits, end
|
||||
mcv = "MC " + mcv;
|
||||
|
@ -337,7 +337,11 @@ public class BData {
|
||||
System.arraycopy(wo, 0, points, st.length, woLength);
|
||||
}
|
||||
int[] locs = ArrayUtils.toPrimitive(Arrays.stream(points).map(s -> P.p.parseInt(s)).toArray(Integer[]::new));
|
||||
box = BoundingBox.fromPoints(locs);
|
||||
try {
|
||||
box = BoundingBox.fromPoints(locs);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Barrel b;
|
||||
|
@ -28,8 +28,8 @@ public class BoundingBox {
|
||||
return contains(block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public int area() {
|
||||
return (x2 - x1 + 1) * (y2 - y1 + 1) * (z2 - z1 + 1);
|
||||
public long area() {
|
||||
return ((long) (x2 - x1 + 1)) * ((long) (y2 - y1 + 1)) * ((long) (z2 - z1 + 1));
|
||||
}
|
||||
|
||||
public String serialize() {
|
||||
@ -39,14 +39,15 @@ public class BoundingBox {
|
||||
public static BoundingBox fromPoints(int[] locations) {
|
||||
if (locations.length % 3 != 0) throw new IllegalArgumentException("Locations has to be pairs of three");
|
||||
|
||||
int length = locations.length / 3;
|
||||
int length = locations.length - 2;
|
||||
|
||||
int minx = Integer.MAX_VALUE,
|
||||
miny = Integer.MAX_VALUE,
|
||||
minz = Integer.MAX_VALUE,
|
||||
maxx = Integer.MIN_VALUE,
|
||||
maxy = Integer.MIN_VALUE,
|
||||
maxz = Integer.MIN_VALUE;
|
||||
for (int i = 0; i < length; i++) {
|
||||
for (int i = 0; i < length; i += 3) {
|
||||
minx = Math.min(locations[i], minx);
|
||||
miny = Math.min(locations[i + 1], miny);
|
||||
minz = Math.min(locations[i + 2], minz);
|
||||
|
Loading…
Reference in New Issue
Block a user