diff --git a/core/src/main/java/tc/oc/pgm/regions/RegionParser.java b/core/src/main/java/tc/oc/pgm/regions/RegionParser.java index 8d145221d3..6153d24110 100644 --- a/core/src/main/java/tc/oc/pgm/regions/RegionParser.java +++ b/core/src/main/java/tc/oc/pgm/regions/RegionParser.java @@ -296,10 +296,12 @@ public MirroredRegion parseMirror(Element el) throws InvalidXMLException { @MethodParser("resize") public ResizedRegion parseResize(Element el) throws InvalidXMLException { + Region child = this.parseChildren(el); Vector min = parser.vector(el, "min").attr().required(); Vector max = parser.vector(el, "max").attr().required(); boolean relative = parser.parseBool(el, "relative").attr().orFalse(); - return new ResizedRegion(this.parseChildren(el), min, max, relative); + validate(child, BlockBoundedValidation.INSTANCE, new Node(el)); + return new ResizedRegion(child, min, max, relative); } @MethodParser("everywhere") diff --git a/core/src/main/java/tc/oc/pgm/regions/ResizedRegion.java b/core/src/main/java/tc/oc/pgm/regions/ResizedRegion.java index 41c6a9d831..f2d7fb81e4 100644 --- a/core/src/main/java/tc/oc/pgm/regions/ResizedRegion.java +++ b/core/src/main/java/tc/oc/pgm/regions/ResizedRegion.java @@ -39,6 +39,12 @@ private void ensureInitialized() { if (matrix != null) return; var oldBounds = region.getBounds(); + if (oldBounds.isEmpty() || !oldBounds.isBlockFinite()) { + this.bounds = oldBounds; + this.matrix = this.inverse = TransformMatrix.identity(); + return; + } + var oldSize = oldBounds.getSize(); if (relative) { diff --git a/util/src/main/java/tc/oc/pgm/util/math/TransformMatrix.java b/util/src/main/java/tc/oc/pgm/util/math/TransformMatrix.java index 77507ace2c..17e86be364 100644 --- a/util/src/main/java/tc/oc/pgm/util/math/TransformMatrix.java +++ b/util/src/main/java/tc/oc/pgm/util/math/TransformMatrix.java @@ -3,12 +3,23 @@ import org.bukkit.util.Vector; public class TransformMatrix { + + private static final TransformMatrix IDENTITY = new TransformMatrix(new double[] { + 1, 0, 0, 0, // + 0, 1, 0, 0, // + 0, 0, 1, 0, // + 0, 0, 0, 1 // + }); private final double[] matrix; private TransformMatrix(double[] matrix) { this.matrix = matrix; } + public static TransformMatrix identity() { + return IDENTITY; + } + public static TransformMatrix translate(Vector vector) { return new TransformMatrix(new double[] { 1, 0, 0, vector.getX(), @@ -31,7 +42,12 @@ public static TransformMatrix scale(Vector vector) { double x = vector.getX(); double y = vector.getY(); double z = vector.getZ(); - return new TransformMatrix(new double[] {x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1}); + return new TransformMatrix(new double[] { + x, 0, 0, 0, // + 0, y, 0, 0, // + 0, 0, z, 0, // + 0, 0, 0, 1 // + }); } public static TransformMatrix concat(TransformMatrix... a) {