Restore old stuck behaviour

This commit is contained in:
fullwall 2020-03-16 20:28:41 +08:00
parent 6bc8692b5f
commit 1ddc78a543
4 changed files with 59 additions and 23 deletions

View File

@ -67,12 +67,15 @@ public class Settings {
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),
@ -92,33 +95,45 @@ public class Settings {
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;

View File

@ -81,6 +81,10 @@ public class MCNavigationStrategy extends AbstractPathStrategy {
stop();
return true;
}
if (navigator.getCancelReason() != null) {
setCancelReason(navigator.getCancelReason());
return true;
}
return wasFinished;
}

View File

@ -13,6 +13,7 @@ import java.util.stream.Stream;
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;
@ -129,9 +130,7 @@ public class PlayerPathfinder extends Pathfinder {
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();
@ -155,4 +154,14 @@ public class PlayerPathfinder extends Pathfinder {
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));
}
}

View File

@ -13,6 +13,7 @@ import java.util.stream.Stream;
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;
@ -86,7 +87,6 @@ public class PlayerPathfinder extends Pathfinder {
this.a.a(var0);
int var6 = 0;
int var7 = (int) (this.d * var4);
while (!this.a.e()) {
++var6;
if (var6 >= var7) {
@ -131,9 +131,7 @@ public class PlayerPathfinder extends Pathfinder {
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();
@ -158,4 +156,14 @@ public class PlayerPathfinder extends Pathfinder {
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));
}
}