@Override public double getMax(int dimension, ProtectedRegion region) { switch (dimension) { case 0: return region.getMaximumPoint().getBlockX(); case 1: return region.getMaximumPoint().getBlockY(); case 2: return region.getMaximumPoint().getBlockZ(); } return 0; }
/** * Add information about coordinates. */ public void appendBounds() { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); builder.append(Style.BLUE); builder.append("Bounds:"); builder.append(Style.YELLOW); builder.append(" (").append(min.getBlockX()).append(",").append(min.getBlockY()).append(",").append(min.getBlockZ()).append(")"); builder.append(" -> (").append(max.getBlockX()).append(",").append(max.getBlockY()).append(",").append(max.getBlockZ()).append(")"); newLine(); }
/** * Warn the sender if the dimensions of the given region are worrying. * * @param sender the sender to send the message to * @param region the region */ protected static void warnAboutDimensions(Actor sender, ProtectedRegion region) { int height = region.getMaximumPoint().getBlockY() - region.getMinimumPoint().getBlockY(); if (height <= 2) { sender.printDebug("(Warning: The height of the region was " + (height + 1) + " block(s).)"); } }
@Override public void applyIntersecting(ProtectedRegion region, Predicate<ProtectedRegion> consumer) { BlockVector3 min = region.getMinimumPoint().floor(); BlockVector3 max = region.getMaximumPoint().ceil(); Set<ProtectedRegion> candidates = new HashSet<>(); MBR pointMBR = new SimpleMBR(min.getX(), max.getX(), min.getY(), max.getY(), min.getZ(), max.getZ()); for (ProtectedRegion found : tree.find(pointMBR)) { candidates.add(found); } for (ProtectedRegion found : region.getIntersectingRegions(candidates)) { if (!consumer.test(found)) { break; } } }
if (pr != null) { Vector min = new Vector(pr.getMinimumPoint().getBlockX(), pr.getMinimumPoint().getBlockY(), pr.getMinimumPoint().getBlockZ()); Vector max = new Vector(pr.getMaximumPoint().getBlockX(), pr.getMaximumPoint().getBlockY(), pr.getMaximumPoint().getBlockZ()); tab.setMin(min); tab.setMax(max);
Vector max = new Vector(pr.getMaximumPoint().getBlockX(), pr.getMaximumPoint().getBlockY(), pr.getMaximumPoint().getBlockZ()); tab.setMin(min); tab.setMax(max);
/** * Checks if the bounding box of a region intersects with with the bounding * box of this region. * * @param region the region to check * @return whether the given region intersects */ protected boolean intersectsBoundingBox(ProtectedRegion region) { BlockVector3 rMaxPoint = region.getMaximumPoint(); BlockVector3 min = getMinimumPoint(); if (rMaxPoint.getBlockX() < min.getBlockX()) return false; if (rMaxPoint.getBlockY() < min.getBlockY()) return false; if (rMaxPoint.getBlockZ() < min.getBlockZ()) return false; BlockVector3 rMinPoint = region.getMinimumPoint(); BlockVector3 max = getMaximumPoint(); if (rMinPoint.getBlockX() > max.getBlockX()) return false; if (rMinPoint.getBlockY() > max.getBlockY()) return false; if (rMinPoint.getBlockZ() > max.getBlockZ()) return false; return true; }