diff --git a/src/main/java/net/aufdemrand/denizen/objects/dCuboid.java b/src/main/java/net/aufdemrand/denizen/objects/dCuboid.java index f0395cdf30..e40f2080e0 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dCuboid.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dCuboid.java @@ -829,8 +829,11 @@ public String getAttribute(Attribute attribute) { dCuboid cub2 = dCuboid.valueOf(attribute.getContext(1)); if (cub2 != null) { boolean intersects = false; - for (LocationPair pair: pairs) { + whole_loop: for (LocationPair pair: pairs) { for (LocationPair pair2: cub2.pairs) { + if (!pair.low.getWorld().getName().equalsIgnoreCase(pair2.low.getWorld().getName())) { + return new Element("false").getAttribute(attribute.fulfill(1)); + } if (pair2.low.getX() <= pair.high.getX() && pair2.low.getY() <= pair.high.getY() && pair2.low.getZ() <= pair.high.getZ() @@ -838,7 +841,7 @@ public String getAttribute(Attribute attribute) { && pair2.high.getY() >= pair.low.getY() && pair2.high.getZ() >= pair.low.getZ()) { intersects = true; - break; + break whole_loop; } } } @@ -846,6 +849,42 @@ public String getAttribute(Attribute attribute) { } } + // <--[tag] + // @attribute ]> + // @returns Element(Boolean) + // @description + // Returns whether this cuboid is fully inside another cuboid. + // --> + if (attribute.startsWith("is_within") + && attribute.hasContext(1)) { + dCuboid cub2 = dCuboid.valueOf(attribute.getContext(1)); + if (cub2 != null) { + boolean contains = true; + for (LocationPair pair2: pairs) { + boolean contained = false; + for (LocationPair pair: cub2.pairs) { + if (!pair.low.getWorld().getName().equalsIgnoreCase(pair2.low.getWorld().getName())) { + return new Element("false").getAttribute(attribute.fulfill(1)); + } + if (!(pair2.low.getX() >= pair.low.getX() + && pair2.low.getY() >= pair.low.getY() + && pair2.low.getZ() >= pair.low.getZ() + && pair2.high.getX() <= pair.high.getX() + && pair2.high.getY() <= pair.high.getY() + && pair2.high.getZ() <= pair.high.getZ())) { + contained = true; + break; + } + } + if (!contained) { + contains = false; + break; + } + } + return new Element(contains).getAttribute(attribute.fulfill(1)); + } + } + // <--[tag] // @attribute ]> // @returns dLocation diff --git a/src/main/java/net/aufdemrand/denizen/scripts/containers/core/BukkitWorldScriptHelper.java b/src/main/java/net/aufdemrand/denizen/scripts/containers/core/BukkitWorldScriptHelper.java index 3d9a1b668e..ef8cae4095 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/containers/core/BukkitWorldScriptHelper.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/containers/core/BukkitWorldScriptHelper.java @@ -3390,7 +3390,7 @@ public void playerGameModeChange(PlayerGameModeChangeEvent event) { // returns the dLocation the player is clicking on. // returns a dList of the notable cuboids that contain the clicked block. // returns an Element of the click type. - // returns a dLocation of the air block in front of the click block. + // returns a dLocation of the air block in front of the clicked block. // // @Determine // "CANCELLED" to stop the click from happening.