Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
cuboid.contains
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 24, 2016
1 parent a5c7d7f commit 24796e9
Showing 1 changed file with 21 additions and 5 deletions.
Expand Up @@ -2,6 +2,7 @@

import com.denizenscript.denizen2core.tags.AbstractTagObject;
import com.denizenscript.denizen2core.tags.TagData;
import com.denizenscript.denizen2core.tags.objects.BooleanTag;
import com.denizenscript.denizen2core.tags.objects.ListTag;
import com.denizenscript.denizen2core.tags.objects.NumberTag;
import com.denizenscript.denizen2core.tags.objects.TextTag;
Expand Down Expand Up @@ -38,11 +39,16 @@ public UtilCuboid getInternal() {
return internal;
}

public boolean contains(UtilLocation point) {
return point.x >= internal.min.x && point.y >= internal.min.y && point.z >= internal.min.z
&& point.x <= internal.max.x && point.y <= internal.max.y && point.z <= internal.max.z;
}

public final static HashMap<String, Function2<TagData, AbstractTagObject, AbstractTagObject>> handlers = new HashMap<>();

static {
// <--[tag]
// @Name LocationTag.min
// @Name CuboidTag.min
// @Updated 2016/11/24
// @Group Identification
// @ReturnType LocationTag
Expand All @@ -51,7 +57,7 @@ public UtilCuboid getInternal() {
// -->
handlers.put("min", (dat, obj) -> new LocationTag(((CuboidTag) obj).internal.min));
// <--[tag]
// @Name LocationTag.max
// @Name CuboidTag.max
// @Updated 2016/11/24
// @Group Identification
// @ReturnType LocationTag
Expand All @@ -60,7 +66,7 @@ public UtilCuboid getInternal() {
// -->
handlers.put("max", (dat, obj) -> new LocationTag(((CuboidTag) obj).internal.max));
// <--[tag]
// @Name LocationTag.world
// @Name CuboidTag.world
// @Updated 2016/11/24
// @Group Identification
// @ReturnType WorldTag
Expand All @@ -69,9 +75,19 @@ public UtilCuboid getInternal() {
// -->
handlers.put("world", (dat, obj) -> new WorldTag(((CuboidTag) obj).internal.min.world));
// <--[tag]
// @Name LocationTag.block_locations[<ListTag>]
// @Name CuboidTag.contains[<LocationTag>]
// @Updated 2016/11/24
// @Group Identification
// @Group Mathematics
// @ReturnType WorldTag
// @Returns whether the cuboid contains the specified location.
// @Example "0,1,2/4,5,6/world" .contains[1,2,3,world] returns "true".
// -->
handlers.put("contains", (dat, obj) -> new BooleanTag(((CuboidTag) obj).contains(
LocationTag.getFor(dat.error, dat.getNextModifier()).getInternal())));
// <--[tag]
// @Name CuboidTag.block_locations[<ListTag>]
// @Updated 2016/11/24
// @Group Connected Information
// @ReturnType ListTag
// @Returns the location of all block locations in this cuboid. Optionally, specify a list of BlockType's to use.
// @Note that partially covered blocks are counted.
Expand Down

0 comments on commit 24796e9

Please sign in to comment.