diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/NPCTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/NPCTag.java index d9efadccd2..58628effc0 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/NPCTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/NPCTag.java @@ -1134,6 +1134,24 @@ else if (attribute.startsWith("list", 2)) { return new LocationTag(object.getNavigator().getTargetAsLocation()); }); + // <--[tag] + // @attribute + // @returns LocationTag + // @mechanism NPCTag.navigator_look_at + // @description + // Returns the location the NPC will currently look at while moving, if any. + // --> + registerTag("navigator_look_at", (attribute, object) -> { + if (object.getNavigator().getLocalParameters().lookAtFunction() == null) { + return null; + } + Location res = object.getNavigator().getLocalParameters().lookAtFunction().apply(object.getNavigator()); + if (res == null) { + return null; + } + return new LocationTag(res); + }); + // <--[tag] // @attribute // @returns ElementTag(Boolean) @@ -1636,6 +1654,27 @@ else if (!trait.isSneaking() && mechanism.getValue().asBoolean()) { getNavigator().getDefaultParameters().pathDistanceMargin(mechanism.getValue().asDouble()); } + // <--[mechanism] + // @object NPCTag + // @name navigator_look_at + // @input LocationTag + // @description + // Sets the location the NPC will currently look at while moving. + // Give no value to let the NPC automatically look where it's going. + // Should be set after the NPC has started moving. + // @tags + // + // --> + if (mechanism.matches("navigator_look_at")) { + if (mechanism.hasValue() && mechanism.requireObject(LocationTag.class)) { + final LocationTag loc = mechanism.valueAsType(LocationTag.class); + getNavigator().getLocalParameters().lookAtFunction((n) -> loc); + } + else { + getNavigator().getLocalParameters().lookAtFunction(null); + } + } + // <--[mechanism] // @object NPCTag // @name name_visible