Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
Add configuration for async path search entities
Browse files Browse the repository at this point in the history
  • Loading branch information
windcolor-dev committed May 18, 2022
1 parent 56b9ae0 commit 8bce43d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,8 @@ public AsyncNavigation(EntityInsentient var1, World var2) {
super(var1, var2);
}

static {
offloadedEntities.add(EntityType.BAT);
offloadedEntities.add(EntityType.BLAZE);
offloadedEntities.add(EntityType.CHICKEN);
offloadedEntities.add(EntityType.COW);
offloadedEntities.add(EntityType.CREEPER);
offloadedEntities.add(EntityType.ENDERMAN);
offloadedEntities.add(EntityType.HORSE);
offloadedEntities.add(EntityType.IRON_GOLEM);
offloadedEntities.add(EntityType.MAGMA_CUBE);
offloadedEntities.add(EntityType.MUSHROOM_COW);
offloadedEntities.add(EntityType.PIG);
offloadedEntities.add(EntityType.PIG_ZOMBIE);
offloadedEntities.add(EntityType.RABBIT);
offloadedEntities.add(EntityType.SHEEP);
offloadedEntities.add(EntityType.SKELETON);
offloadedEntities.add(EntityType.SILVERFISH);
offloadedEntities.add(EntityType.SLIME);
offloadedEntities.add(EntityType.SNOWMAN);
offloadedEntities.add(EntityType.SQUID);
offloadedEntities.add(EntityType.WITCH);
offloadedEntities.add(EntityType.ZOMBIE);
public static void addOffloadedEntities(List<EntityType> entities) {
offloadedEntities.addAll(entities);
}

private void issueSearch(Entity targetEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,24 @@ private static void modernKeepalive() {
public static int pathSearchThreads;
public static boolean ensurePathSearchAccuracy;

@SuppressWarnings("unchecked")
private static void asyncPathSearches() {
asyncPathSearches = getBoolean("settings.async.path-searches.enabled", true);

if (asyncPathSearches) {

List<String> asyncSearchEntities = getList("settings.async.path-searches.entities",
Lists.newArrayList("BAT", "BLAZE", "CHICKEN", "COW", "CREEPER", "ENDERMAN", "HORSE", "IRON_GOLEM",
"MAGMA_CUBE", "MUSHROOM_COW", "PIG", "PIG_ZOMBIE", "RABBIT", "SHEEP", "SKELETON", "SILVERFISH",
"SLIME", "SNOWMAN", "SQUID", "WITCH", "ZOMBIE"));

List<EntityType> finalEntities = Lists.newArrayList();

for (String entityName : asyncSearchEntities) {
finalEntities.add(EntityType.fromName(entityName));
}

AsyncNavigation.addOffloadedEntities(finalEntities);

distanceToAsync = getInt("settings.async.path-searches.distance-to-async", 0);
AsyncNavigation.setMinimumDistanceForOffloading(distanceToAsync);

Expand All @@ -336,6 +349,7 @@ private static void asyncPathSearches() {

}
c.addComment("settings.async.path-searches.enabled", "Enables async path searching for entities.");
c.addComment("settings.async.path-searches.entities", "A list of entities that utilize async path searches. Removing entities from this list will ensure 100% vanilla behavior, but worse performance.");
c.addComment("settings.async.path-searches.distance-to-async", "The mininum distance an entity is targeting to handle it async. Tune this based on how many entities your server will has.");
c.addComment("settings.async.path-searches.threads", "The threads used for path searches. Tune this based on how many entities your server will has.");
c.addComment("settings.async.path-searches.ensure-accuracy", "Ensures accuracy of async path searches, disabling this will result in possibly inaccurate targeting, but higher performance.");
Expand Down

0 comments on commit 8bce43d

Please sign in to comment.