Fix some logic on villager poi max attempts

Hopefully will help #3462
This commit is contained in:
Aikar
2020-05-28 17:04:20 -04:00
parent 6bff219f15
commit 8e9b42b127
2 changed files with 5 additions and 4 deletions

View File

@@ -79,14 +79,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ ++poiAttempts; + ++poiAttempts;
+ PathEntity pathentity = entitycreature.getNavigation().a(com.google.common.collect.ImmutableSet.of(pos), 8, false, this.a.d()); + 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(); + record.decreaseVacancy();
+ GlobalPos globalPos = GlobalPos.create(worldserver.getWorldProvider().getDimensionManager(), pos); + GlobalPos globalPos = GlobalPos.create(worldserver.getWorldProvider().getDimensionManager(), pos);
+ entitycreature.getBehaviorController().setMemory(this.b, globalPos); + entitycreature.getBehaviorController().setMemory(this.b, globalPos);
+ break OUT; + break OUT;
+ } + }
+ if (poiAttempts > maxPoiAttempts) { + if (poiAttempts >= maxPoiAttempts) {
+ this.e.long2LongEntrySet().removeIf((entry) -> entry.getLongValue() < this.d);
+ break OUT; + 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<BlockPosition> predicate = (blockposition) -> { Predicate<BlockPosition> predicate = (blockposition) -> {
long j = blockposition.asLong(); long j = blockposition.asLong();

View File

@@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static ExecutorService k() { private static ExecutorService k() {
- int i = MathHelper.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, 7); - 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 + i = Integer.getInteger("Paper.WorkerThreadCount", i); // Paper - allow overriding
Object object; Object object;