Skip to content

Commit

Permalink
Add entity.can_see, adjust tag some meta
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 10, 2013
1 parent e60bd65 commit 6e66ce6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dEntity.java
Expand Up @@ -922,6 +922,17 @@ else if ((float) getLivingEntity().getHealth() / maxHealth < 1)
return new Duration(entity.getTicksLived() / 20)
.getAttribute(attribute.fulfill(1));

// <--
// <entity.can_see[entity]> -> Element(Boolean)
// Returns true if the entity can see the other entity.
// -->
if (attribute.startsWith("can_see")) {
if (attribute.hasContext(1) && dEntity.matches(attribute.getContext(1))) {
dEntity toEntity = dEntity.valueOf(attribute.getContext(1));
return new Element(String.valueOf(getLivingEntity().hasLineOfSight(toEntity.getBukkitEntity()))).getAttribute(attribute.fulfill(1));
}
}

// <--
// <entity.can_pickup_items> -> Element(Boolean)
// Returns true if the entity can pick up items. Else, returns false.
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Expand Up @@ -585,21 +585,21 @@ public int compare(dEntity ent1, dEntity ent2) {
}

// <--
// <l@location.distance[X]> -> Element(Number)
// <l@location.distance[<location>]> -> Element(Number)
// Returns the distance between 2 locations.
// -->
if (attribute.startsWith("distance")) {
if (attribute.hasContext(1) && dLocation.matches(attribute.getContext(1))) {
dLocation toLocation = dLocation.valueOf(attribute.getContext(1));

// <--
// <l@location.distance[X].horizontal> -> Element(Number)
// <l@location.distance[<location>].horizontal> -> Element(Number)
// Returns the horizontal distance between 2 locations.
// -->
if (attribute.getAttribute(2).startsWith("horizontal")) {

// <--
// <l@location.distance[X].horizontal.multiworld> -> Element(Number)
// <l@location.distance[<location>].horizontal.multiworld> -> Element(Number)
// Returns the horizontal distance between 2 multiworld locations.
// -->
if (attribute.getAttribute(3).startsWith("multiworld"))
Expand All @@ -615,13 +615,13 @@ else if (this.getWorld() == toLocation.getWorld())
}

// <--
// <l@location.distance[X].vertical> -> Element(Number)
// <l@location.distance[<location>].vertical> -> Element(Number)
// Returns the vertical distance between 2 locations.
// -->
else if (attribute.getAttribute(2).startsWith("vertical")) {

// <--
// <l@location.distance[X].vertical.multiworld> -> Element(Number)
// <l@location.distance[<location>].vertical.multiworld> -> Element(Number)
// Returns the vertical distance between 2 multiworld locations.
// -->
if (attribute.getAttribute(3).startsWith("multiworld"))
Expand Down
Expand Up @@ -52,6 +52,4 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {


}


}
}

0 comments on commit 6e66ce6

Please sign in to comment.