Allow users to set the path distance margin as well

This commit is contained in:
fullwall 2019-04-26 18:10:23 +08:00
parent e4717d4bc7
commit 0922694604
5 changed files with 12 additions and 0 deletions

View File

@ -76,6 +76,7 @@ public class Settings {
DEFAULT_LOOK_CLOSE("npc.default.look-close.enabled", false),
DEFAULT_LOOK_CLOSE_RANGE("npc.default.look-close.range", 5),
DEFAULT_NPC_LIMIT("npc.limits.default-limit", 10),
DEFAULT_PATH_DISTANCE_MARGIN("npc.pathfinding.default-distance-margin", 1),
DEFAULT_PATHFINDER_UPDATE_PATH_RATE("npc.pathfinding.update-path-rate", 20),
DEFAULT_PATHFINDING_RANGE("npc.default.pathfinding.range", 25F),
DEFAULT_RANDOM_TALKER("npc.default.random-talker", true),

View File

@ -1131,6 +1131,14 @@ public class NPCCommands {
Messaging.sendTr(sender, Messages.PATHFINDING_OPTIONS_DISTANCE_MARGIN_SET, npc.getName(), distance);
found = true;
}
if (args.hasValueFlag("path-distance-margin")) {
double distance = Double.parseDouble(args.getFlag("distance-margin"));
if (distance < 0)
throw new CommandException();
npc.getNavigator().getDefaultParameters().pathDistanceMargin(Math.pow(distance, 2));
Messaging.sendTr(sender, Messages.PATHFINDING_OPTIONS_PATH_DISTANCE_MARGIN_SET, npc.getName(), distance);
found = true;
}
if (args.hasValueFlag("attack-range")) {
double range = Double.parseDouble(args.getFlag("attack-range"));
if (range < 0)

View File

@ -43,6 +43,7 @@ public class CitizensNavigator implements Navigator, Runnable {
.attackRange(Setting.NPC_ATTACK_DISTANCE.asDouble())
.updatePathRate(Setting.DEFAULT_PATHFINDER_UPDATE_PATH_RATE.asInt())
.distanceMargin(Setting.DEFAULT_DISTANCE_MARGIN.asDouble())
.pathDistanceMargin(Setting.DEFAULT_PATH_DISTANCE_MARGIN.asDouble())
.stationaryTicks(Setting.DEFAULT_STATIONARY_TICKS.asInt()).stuckAction(TeleportStuckAction.INSTANCE)
.examiner(new MinecraftBlockExaminer()).useNewPathfinder(Setting.USE_NEW_PATHFINDER.asBoolean());
private PathStrategy executing;

View File

@ -195,6 +195,7 @@ public class Messages {
public static final String PATHFINDING_OPTIONS_AVOID_WATER_SET = "citizens.commands.npc.pathopt.avoid-water-set";
public static final String PATHFINDING_OPTIONS_AVOID_WATER_UNSET = "citizens.commands.npc.pathopt.avoid-water-unset";
public static final String PATHFINDING_OPTIONS_DISTANCE_MARGIN_SET = "citizens.commands.npc.pathopt.distance-margin-set";
public static final String PATHFINDING_OPTIONS_PATH_DISTANCE_MARGIN_SET = "citizens.commands.npc.pathopt.path-distance-margin-set";
public static final String PATHFINDING_OPTIONS_STATIONARY_TICKS_SET = "citizens.commands.npc.pathopt.stationary-ticks-set";
public static final String PATHFINDING_RANGE_SET = "citizens.commands.npc.pathfindingrange.set";
public static final String PHANTOM_STATE_SET = "citizens.commands.npc.phantom.phantom-set";

View File

@ -98,6 +98,7 @@ citizens.commands.npc.pathopt.avoid-water-set=[[{0}]] will now avoid water.
citizens.commands.npc.pathopt.avoid-water-unset=[[{0}]] will no longer avoid water.
citizens.commands.npc.pathopt.stationary-ticks-set=[[{0}]]''s maximum stationary ticks set to [[{1}]].
citizens.commands.npc.pathopt.distance-margin-set=[[{0}]]''s pathfinding distance margin set to [[{1}]].
citizens.commands.npc.pathopt.path-distance-margin-set=[[{0}]]''s pathfinding path distance margin set to [[{1}]].
citizens.commands.npc.pathopt.attack-range-set=[[{0}]]''s attack range set to [[{1}]].
citizens.commands.npc.playerlist.added=Added [[{0}]] to the player list.
citizens.commands.npc.playerlist.removed=Removed [[{0}]] from the player list.