Skip to content

Commit

Permalink
add a path_distance_margin tag/mech pair
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 10, 2019
1 parent 6db6005 commit 1f4db2c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions plugin/src/main/java/com/denizenscript/denizen/objects/NPCTag.java
Expand Up @@ -954,6 +954,17 @@ && isSpawned() && getEntity() instanceof Player) {
return new ElementTag(getNavigator().getDefaultParameters().distanceMargin()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <NPCTag.path_distance_margin>
// @returns ElementTag(Decimal)
// @mechanism path_distance_margin
// @description
// Returns the NPC's current pathfinding distance margin. That is, how close it needs to get to individual points along its path.
// -->
if (attribute.startsWith("path_distance_margin")) {
return new ElementTag(getNavigator().getDefaultParameters().pathDistanceMargin()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <NPCTag.is_navigating>
// @returns ElementTag(Boolean)
Expand Down Expand Up @@ -1523,6 +1534,19 @@ else if (!trait.isSneaking() && mechanism.getValue().asBoolean()) {
getNavigator().getDefaultParameters().distanceMargin(mechanism.getValue().asDouble());
}

// <--[mechanism]
// @object NPCTag
// @name path_distance_margin
// @input Element(Decimal)
// @description
// Sets the NPC's path distance margin.
// @tags
// <NPCTag.path_distance_margin>
// -->
if (mechanism.matches("path_distance_margin") && mechanism.requireDouble()) {
getNavigator().getDefaultParameters().pathDistanceMargin(mechanism.getValue().asDouble());
}

// <--[mechanism]
// @object NPCTag
// @name name_visible
Expand Down

0 comments on commit 1f4db2c

Please sign in to comment.