Skip to content

Commit

Permalink
Make /npc pickupitems persistent
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Nov 11, 2022
1 parent 35245a5 commit ce1f306
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Expand Up @@ -1768,7 +1768,7 @@ public void pathto(CommandContext args, CommandSender sender, NPC npc,
public void pickupitems(CommandContext args, CommandSender sender, NPC npc, @Flag("set") Boolean set)
throws CommandException {
boolean pickup = set == null ? !npc.data().get(NPC.Metadata.PICKUP_ITEMS, !npc.isProtected()) : set;
npc.data().set(NPC.Metadata.PICKUP_ITEMS, pickup);
npc.data().setPersistent(NPC.Metadata.PICKUP_ITEMS, pickup);
Messaging.sendTr(sender, pickup ? Messages.PICKUP_ITEMS_SET : Messages.PICKUP_ITEMS_UNSET, npc.getName());
}

Expand Down
Expand Up @@ -302,9 +302,11 @@ public void run(GoalSelector selector) {
selector.finish();
return;
}

if (npc.getNavigator().isNavigating()) {
return;
}

Waypoint current = plan.getCurrentWaypoint();
npc.getNavigator().setTarget(current.getLocation());
npc.getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() {
Expand All @@ -322,6 +324,7 @@ public boolean shouldExecute(GoalSelector selector) {
if (paused || available.size() == 0 || !npc.isSpawned() || npc.getNavigator().isNavigating()) {
return false;
}

Waypoint target = available.get(Util.getFastRandom().nextInt(available.size()));
plan = ASTAR.runFully(new GuidedGoal(target), new GuidedNode(null, new Waypoint(npc.getStoredLocation())));
return plan != null;
Expand Down Expand Up @@ -403,8 +406,8 @@ public Iterable<AStarNode> getNeighbours() {
List<AStarNode> resList = Lists.newArrayList();
res.forEachRemaining(new Consumer<Waypoint>() {
@Override
public void accept(Waypoint t) {
resList.add(new GuidedNode(null, t));
public void accept(Waypoint n) {
resList.add(new GuidedNode(null, n));
}
});
return resList;
Expand Down

0 comments on commit ce1f306

Please sign in to comment.