From 8e9b42b127d790d53031c0958b1da50950852501 Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 28 May 2020 17:04:20 -0400 Subject: [PATCH] Fix some logic on villager poi max attempts Hopefully will help #3462 --- Spigot-Server-Patches/Optimize-Villagers.patch | 7 ++++--- ...-more-reasonable-thread-count-default-for-bootstr.patch | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Spigot-Server-Patches/Optimize-Villagers.patch b/Spigot-Server-Patches/Optimize-Villagers.patch index 7e04e431a8..28c23761a5 100644 --- a/Spigot-Server-Patches/Optimize-Villagers.patch +++ b/Spigot-Server-Patches/Optimize-Villagers.patch @@ -79,14 +79,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ++poiAttempts; + PathEntity pathentity = entitycreature.getNavigation().a(com.google.common.collect.ImmutableSet.of(pos), 8, false, this.a.d()); + -+ if (poiAttempts <= maxPoiAttempts && pathentity != null && pathentity.h()) { ++ if (pathentity != null && pathentity.h()) { + record.decreaseVacancy(); + GlobalPos globalPos = GlobalPos.create(worldserver.getWorldProvider().getDimensionManager(), pos); + entitycreature.getBehaviorController().setMemory(this.b, globalPos); + break OUT; + } -+ if (poiAttempts > maxPoiAttempts) { -+ this.e.long2LongEntrySet().removeIf((entry) -> entry.getLongValue() < this.d); ++ if (poiAttempts >= maxPoiAttempts) { + break OUT; + } + } @@ -94,6 +93,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + } ++ // Clean up - vanilla does this only when it runs out, but that would push it to try farther POI's... ++ this.e.long2LongEntrySet().removeIf((entry) -> entry.getLongValue() < this.d); + /* Predicate predicate = (blockposition) -> { long j = blockposition.asLong(); diff --git a/Spigot-Server-Patches/Use-more-reasonable-thread-count-default-for-bootstr.patch b/Spigot-Server-Patches/Use-more-reasonable-thread-count-default-for-bootstr.patch index dd46628827..0d55658d41 100644 --- a/Spigot-Server-Patches/Use-more-reasonable-thread-count-default-for-bootstr.patch +++ b/Spigot-Server-Patches/Use-more-reasonable-thread-count-default-for-bootstr.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private static ExecutorService k() { - int i = MathHelper.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, 7); -+ int i = Math.min(8, Math.max(Runtime.getRuntime().availableProcessors() - 2, 3)); // Paper - use more reasonable default - 2 is hard minimum to avoid using unlimited threads ++ int i = Math.min(8, Math.max(Runtime.getRuntime().availableProcessors() - 2, 2)); // Paper - use more reasonable default - 2 is hard minimum to avoid using unlimited threads + i = Integer.getInteger("Paper.WorkerThreadCount", i); // Paper - allow overriding Object object;