Skip to content

Commit

Permalink
Restore old stuck behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 16, 2020
1 parent 6bc8692 commit 1ddc78a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 23 deletions.
47 changes: 31 additions & 16 deletions main/src/main/java/net/citizensnpcs/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,15 @@ public enum Setting {
CHAT_MAX_NUMBER_OF_TARGETS("npc.chat.options.max-number-of-targets-to-show", 2),
CHAT_MULTIPLE_TARGETS_FORMAT("npc.chat.options.multiple-targets-format",
"<target>|, <target>| & <target>| & others"),
CHAT_RANGE("npc.chat.options.range", 5), CHECK_MINECRAFT_VERSION("advanced.check-minecraft-version", true),
DEBUG_FILE("general.debug-file", ""), DEBUG_MODE("general.debug-mode", false),
CHAT_RANGE("npc.chat.options.range", 5),
CHECK_MINECRAFT_VERSION("advanced.check-minecraft-version", true),
DEBUG_FILE("general.debug-file", ""),
DEBUG_MODE("general.debug-mode", false),
DEBUG_PATHFINDING("general.debug-pathfinding", false),
DEFAULT_DISTANCE_MARGIN("npc.pathfinding.default-distance-margin", 2),
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_LOOK_CLOSE_RANGE("npc.default.look-close.range", 5),
DEFAULT_NPC_LIMIT("npc.limits.default-limit", 10),
DEFAULT_PATH_DISTANCE_MARGIN("npc.pathfinding.default-path-distance-margin", 1),
DEFAULT_PATHFINDER_UPDATE_PATH_RATE("npc.pathfinding.update-path-rate", 20),
DEFAULT_PATHFINDING_RANGE("npc.default.pathfinding.range", 25F),
Expand All @@ -92,33 +95,45 @@ public void loadFromKey(DataKey root) {
value = list;
}
},
DISABLE_TABLIST("npc.tablist.disable", true), ERROR_COLOUR("general.color-scheme.message-error", "<c>"),
DISABLE_LOOKCLOSE_WHILE_NAVIGATING("npc.default.look-close.disable-while-navigating", true),
DISABLE_MC_NAVIGATION_FALLBACK("npc.pathfinding.disable-mc-fallback-navigation", true),
DISABLE_TABLIST("npc.tablist.disable", true),
ERROR_COLOUR("general.color-scheme.message-error", "<c>"),
HIGHLIGHT_COLOUR("general.color-scheme.message-highlight", "<e>"),
KEEP_CHUNKS_LOADED("npc.chunks.always-keep-loaded", false), LOCALE("general.translation.locale", ""),
KEEP_CHUNKS_LOADED("npc.chunks.always-keep-loaded", false),
LOCALE("general.translation.locale", ""),
MAX_CONTROLLABLE_GROUND_SPEED("npc.controllable.max-ground-speed", 0.5),
MAX_NPC_LIMIT_CHECKS("npc.limits.max-permission-checks", 100),
MAX_NPC_SKIN_RETRIES("npc.skins.max-retries", -1), MAX_PACKET_ENTRIES("npc.limits.max-packet-entries", 15),
MAX_SPEED("npc.limits.max-speed", 100), MAX_TEXT_RANGE("npc.chat.options.max-text-range", 500),
MAX_NPC_SKIN_RETRIES("npc.skins.max-retries", -1),
MAX_PACKET_ENTRIES("npc.limits.max-packet-entries", 15),
MAX_SPEED("npc.limits.max-speed", 100),
MAX_TEXT_RANGE("npc.chat.options.max-text-range", 500),
MAXIMUM_ASTAR_ITERATIONS("npc.pathfinding.maximum-new-pathfinder-iterations", 50000),
MESSAGE_COLOUR("general.color-scheme.message", "<a>"),
NEW_PATHFINDER_OPENS_DOORS("npc.pathfinding.new-finder-open-doors", false),
NPC_ATTACK_DISTANCE("npc.pathfinding.attack-range", 1.75 * 1.75), NPC_COST("economy.npc.cost", 100D),
NPC_ATTACK_DISTANCE("npc.pathfinding.attack-range", 1.75 * 1.75),
NPC_COST("economy.npc.cost", 100D),
NPC_SKIN_RETRY_DELAY("npc.skins.retry-delay", 120),
NPC_SKIN_ROTATION_UPDATE_DEGREES("npc.skins.rotation-update-degrees", 90f),
NPC_SKIN_USE_LATEST("npc.skins.use-latest-by-default", false),
NPC_SKIN_VIEW_DISTANCE("npc.skins.view-distance", 100D), PACKET_UPDATE_DELAY("npc.packets.update-delay", 30),
NPC_SKIN_VIEW_DISTANCE("npc.skins.view-distance", 100D),
PACKET_UPDATE_DELAY("npc.packets.update-delay", 30),
QUICK_SELECT("npc.selection.quick-select", false),
REMOVE_PLAYERS_FROM_PLAYER_LIST("npc.player.remove-from-list", true),
SAVE_TASK_DELAY("storage.save-task.delay", 20 * 60 * 60), SELECTION_ITEM("npc.selection.item", "stick"),
SAVE_TASK_DELAY("storage.save-task.delay", 20 * 60 * 60),
SELECTION_ITEM("npc.selection.item", "stick"),
SELECTION_MESSAGE("npc.selection.message", "<b>You selected <a><npc><b>!"),
SERVER_OWNS_NPCS("npc.server-ownership", false), STORAGE_FILE("storage.file", "saves.yml"),
STORAGE_TYPE("storage.type", "yaml"), SUBPLUGIN_FOLDER("subplugins.folder", "plugins"),
SERVER_OWNS_NPCS("npc.server-ownership", false),
STORAGE_FILE("storage.file", "saves.yml"),
STORAGE_TYPE("storage.type", "yaml"),
SUBPLUGIN_FOLDER("subplugins.folder", "plugins"),
TALK_CLOSE_MAXIMUM_COOLDOWN("npc.text.max-talk-cooldown", 5),
TALK_CLOSE_MINIMUM_COOLDOWN("npc.text.min-talk-cooldown", 10), TALK_ITEM("npc.text.talk-item", "book"),
TELEPORT_DELAY("npc.teleport-delay", -1), USE_BOAT_CONTROLS("npc.controllable.use-boat-controls", true),
TALK_CLOSE_MINIMUM_COOLDOWN("npc.text.min-talk-cooldown", 10),
TALK_ITEM("npc.text.talk-item", "book"),
TELEPORT_DELAY("npc.teleport-delay", -1),
USE_BOAT_CONTROLS("npc.controllable.use-boat-controls", true),
USE_NEW_PATHFINDER("npc.pathfinding.use-new-finder", false),
USE_SCOREBOARD_TEAMS("npc.player-scoreboard-teams.enable", true),
DISABLE_LOOKCLOSE_WHILE_NAVIGATING("npc.default.look-close.disable-while-navigating", true);
USE_SCOREBOARD_TEAMS("npc.player-scoreboard-teams.enable", true);

protected String path;
protected Object value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public boolean update() {
stop();
return true;
}
if (navigator.getCancelReason() != null) {
setCancelReason(navigator.getCancelReason());
return true;
}
return wasFinished;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC;
import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.EntityInsentient;
Expand Down Expand Up @@ -129,9 +130,7 @@ private PathEntity a(PathPoint var0, Map var1, float var2, int var3) {
return this.a(var1x.d(), (BlockPosition) var1.get(var1x), true);
}).sorted(Comparator.comparingInt(PathEntity::e));
} else {
var6 = var4.stream().map((var1x) -> {
return this.a(var1x.d(), (BlockPosition) var1.get(var1x), false);
}).sorted(Comparator.comparingDouble(PathEntity::l).thenComparingInt(PathEntity::e));
var6 = getFallbackDestinations(var1, var4);
}

Optional var7 = var6.findFirst();
Expand All @@ -155,4 +154,14 @@ private float a(PathPoint var0, Set var1) {

return var2;
}

public Stream<PathEntity> getFallbackDestinations(Map<PathDestination, BlockPosition> var1,
Set<PathDestination> var5) {
if (Setting.DISABLE_MC_NAVIGATION_FALLBACK.asBoolean()) {
return Stream.empty();
}
return var5.stream().map((var1x) -> {
return this.a(var1x.d(), var1.get(var1x), false);
}).sorted(Comparator.comparingDouble(PathEntity::l).thenComparingInt(PathEntity::e));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.ChunkCache;
Expand Down Expand Up @@ -86,7 +87,6 @@ private PathEntity a(PathPoint var0, Map<PathDestination, BlockPosition> var1, f
this.a.a(var0);
int var6 = 0;
int var7 = (int) (this.d * var4);

while (!this.a.e()) {
++var6;
if (var6 >= var7) {
Expand Down Expand Up @@ -131,9 +131,7 @@ private PathEntity a(PathPoint var0, Map<PathDestination, BlockPosition> var1, f
return this.a(var1x.d(), var1.get(var1x), true);
}).sorted(Comparator.comparingInt(PathEntity::e));
} else {
var8 = var5.stream().map((var1x) -> {
return this.a(var1x.d(), var1.get(var1x), false);
}).sorted(Comparator.comparingDouble(PathEntity::l).thenComparingInt(PathEntity::e));
var8 = getFallbackDestinations(var1, var5);
}

Optional var9 = var8.findFirst();
Expand All @@ -158,4 +156,14 @@ private float a(PathPoint var0, Set var1) {
return var2;
}

public Stream<PathEntity> getFallbackDestinations(Map<PathDestination, BlockPosition> var1,
Set<PathDestination> var5) {
if (Setting.DISABLE_MC_NAVIGATION_FALLBACK.asBoolean()) {
return Stream.empty();
}
return var5.stream().map((var1x) -> {
return this.a(var1x.d(), var1.get(var1x), false);
}).sorted(Comparator.comparingDouble(PathEntity::l).thenComparingInt(PathEntity::e));
}

}

0 comments on commit 1ddc78a

Please sign in to comment.