mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-09-28 23:27:42 +02:00
c4a68471e4
* Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: d80e43647 [CI-SKIP] Removal from the MIT list (#5345) Tuinity Changes: c303521 Change license from MIT to LGPLv3 Purpur Changes: 3044036 Re-enable timings by default 4f85cbe Include all Airplane patches 7b5feba [ci-skip] Tuinity license change 210ff8f [ci-skip] revert last commit. wasnt what i thought it was :3 47e8965 [ci-skip] Add maven repositories for Adventure API 3930ac4 It's muffin time! e535225 Updated Upstream (Paper & Tuinity) * whoops * this actually fixes it (I was being stupid) * [CI-SKIP] fix akarin link in Licensing/LICENSE.md * Updated Upstream and Sidestream(s) (Paper/Airplane/Akarin/Empirecraft) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 39c487b37 Add per-command perms for paper command cdbf2578c Add Item Rarity API (#5352) Airplane Changes: 5df9825 Remove iterators from inventory contains 18d2be1 Merge pull request #14 from violetwtf/patch-1 f716d4c Merge pull request #13 from violetwtf/master 128cbe5 Reduce entity chunk ticking checks from 3 to 1 03ac093 Skip copying unloading tile entities 97dd027 Smaller pool size for tracking 9e9f57b Only set up Flare if token is available 580f380 Updated Upstream (Tuinity) 97df206 Update README to reflect support changes cf161dd Change blog URL to more helpful one Akarin Changes: 6be3d57 Update Jenkinsfile 3aa2e99 Merge pull request #198 from HookWoods/ver/1.16.5 c548038 try to fix velocity repo 5b03eb1 Update patches to 1.16.5 Empirecraft Changes: 81545aaf Updated Paper Airplane Changes: 82253fd Early return optimization for target finding 9572643 Cache entityhuman display name * Updated Upstream and Sidestream(s) (Tuinity/Purpur/Airplane) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Tuinity Changes: aea6b83 Merge dev/playerchunkloading 722c7ca Use hash table for maintaing changed block set 98ae59d Custom table implementation for blockstate state lookups 8b8704f Oprimise map impl for tracked players ea71d6b Optimise snow & ice in chunk ticking 9871d4c Remove chunk lookup & lambda allocation from counting mobs 5a4a35f Add patreon 7d93d96 Refactor data management for region manager Purpur Changes: 37591fe Add config to use no-tick vd for tracker (#195) Airplane Changes: cc00c69 Updated Upstream (Tuinity)
117 lines
6.1 KiB
Diff
117 lines
6.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
|
Date: Sat, 12 Sep 2020 19:17:05 +0300
|
|
Subject: [PATCH] Optimize Villagers
|
|
|
|
These changes aim to fix the following:
|
|
- Villagers trying to push farther POIs (Points Of Interest)
|
|
- Villagers ignoring doors most of the times
|
|
- Villagers pushing POIs (Points Of Interest) to unloaded chunks
|
|
|
|
The following has been done to fix the mentioned problems:
|
|
- Replaced stream off BehaviorFindPosition
|
|
- Made sure that chunks are loaded for the POIs (Points Of Interest) that are gonna be tried.
|
|
- Added a profession cache, which followed by a stream removal.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BehaviorFindPosition.java b/src/main/java/net/minecraft/server/BehaviorFindPosition.java
|
|
index a48f2f82517bc391d5d5b7961e3c7a75175abb65..490a1d4d53a6180ac4c40f1f51d4704825c01ed7 100644
|
|
--- a/src/main/java/net/minecraft/server/BehaviorFindPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/BehaviorFindPosition.java
|
|
@@ -48,7 +48,7 @@ public class BehaviorFindPosition extends Behavior<EntityCreature> {
|
|
if (this.d && entitycreature.isBaby()) {
|
|
return false;
|
|
} else if (this.f == 0L) {
|
|
- this.f = entitycreature.world.getTime() + (long) worldserver.random.nextInt(20);
|
|
+ this.f = entitycreature.world.getTime() + (long) java.util.concurrent.ThreadLocalRandom.current().nextInt(20); // Yatopia
|
|
return false;
|
|
} else {
|
|
return worldserver.getTime() >= this.f;
|
|
@@ -56,7 +56,7 @@ public class BehaviorFindPosition extends Behavior<EntityCreature> {
|
|
}
|
|
|
|
protected void a(WorldServer worldserver, EntityCreature entitycreature, long i) {
|
|
- this.f = i + 20L + (long) worldserver.getRandom().nextInt(20);
|
|
+ this.f = i + 20L + (long) java.util.concurrent.ThreadLocalRandom.current().nextInt(20); // Yatopia
|
|
if (entitycreature.getNavigation().isStuck()) this.f += 200L; // Airplane - wait an additional 10s to check again if they're stuck
|
|
VillagePlace villageplace = worldserver.y();
|
|
|
|
@@ -67,12 +67,20 @@ public class BehaviorFindPosition extends Behavior<EntityCreature> {
|
|
BehaviorFindPosition.a behaviorfindposition_a = (BehaviorFindPosition.a) this.g.get(blockposition.asLong());
|
|
|
|
if (behaviorfindposition_a == null) {
|
|
- return true;
|
|
+ return worldserver.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null; // Yatopia
|
|
} else if (!behaviorfindposition_a.c(i)) {
|
|
return false;
|
|
} else {
|
|
- behaviorfindposition_a.a(i);
|
|
- return true;
|
|
+ // Yatopia start - make sure chunks are loaded
|
|
+ int chunkX = blockposition.getX() >> 4;
|
|
+ int chunkZ = blockposition.getZ() >> 4;
|
|
+ if (worldserver.getChunkIfLoaded(chunkX, chunkZ) != null) {
|
|
+ behaviorfindposition_a.a(i);
|
|
+ return true;
|
|
+ } else {
|
|
+ return false;
|
|
+ }
|
|
+ // Yatopia end
|
|
}
|
|
};
|
|
// Tuinity start - optimise POI access
|
|
@@ -103,7 +111,7 @@ public class BehaviorFindPosition extends Behavior<EntityCreature> {
|
|
BlockPosition blockposition1 = (BlockPosition) iterator.next();
|
|
|
|
this.g.computeIfAbsent(blockposition1.asLong(), (j) -> {
|
|
- return new BehaviorFindPosition.a(entitycreature.world.random, i);
|
|
+ return new BehaviorFindPosition.a(java.util.concurrent.ThreadLocalRandom.current(), i); // Yatopia
|
|
});
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/VillagePlaceType.java b/src/main/java/net/minecraft/server/VillagePlaceType.java
|
|
index b6b4c8c491d692f93d2c38d602ff99b0611b72aa..082b060407f2424c10f865e23feb60b970b851cb 100644
|
|
--- a/src/main/java/net/minecraft/server/VillagePlaceType.java
|
|
+++ b/src/main/java/net/minecraft/server/VillagePlaceType.java
|
|
@@ -14,11 +14,20 @@ import java.util.stream.Collectors;
|
|
|
|
public class VillagePlaceType {
|
|
|
|
+ static Set<VillagePlaceType> professionCache; // Yatopia
|
|
private static final Supplier<Set<VillagePlaceType>> y = Suppliers.memoize(() -> {
|
|
return (Set) IRegistry.VILLAGER_PROFESSION.g().map(VillagerProfession::b).collect(Collectors.toSet());
|
|
});
|
|
public static final Predicate<VillagePlaceType> a = (villageplacetype) -> {
|
|
- return ((Set) VillagePlaceType.y.get()).contains(villageplacetype);
|
|
+ // Yatopia start
|
|
+ if (professionCache == null) {
|
|
+ professionCache = new java.util.HashSet<>();
|
|
+ for (VillagerProfession profession : IRegistry.VILLAGER_PROFESSION) {
|
|
+ professionCache.add(profession.getPlaceType());
|
|
+ }
|
|
+ }
|
|
+ return professionCache.contains(villageplacetype);
|
|
+ // Yatopia end
|
|
};
|
|
public static final Predicate<VillagePlaceType> b = (villageplacetype) -> {
|
|
return true;
|
|
diff --git a/src/main/java/net/minecraft/server/VillagerProfession.java b/src/main/java/net/minecraft/server/VillagerProfession.java
|
|
index 6493f220a0cf627e82e5f3f3c85e9934d9a9ebae..f4c8ba2d94e5875197b674a0e39e997b45186d63 100644
|
|
--- a/src/main/java/net/minecraft/server/VillagerProfession.java
|
|
+++ b/src/main/java/net/minecraft/server/VillagerProfession.java
|
|
@@ -35,6 +35,7 @@ public class VillagerProfession {
|
|
this.t = soundeffect;
|
|
}
|
|
|
|
+ public final VillagePlaceType getPlaceType() { return b(); } // Yatopia - OBFHELPER
|
|
public VillagePlaceType b() {
|
|
return this.q;
|
|
}
|
|
@@ -61,6 +62,7 @@ public class VillagerProfession {
|
|
}
|
|
|
|
static VillagerProfession a(String s, VillagePlaceType villageplacetype, ImmutableSet<Item> immutableset, ImmutableSet<Block> immutableset1, @Nullable SoundEffect soundeffect) {
|
|
+ VillagePlaceType.professionCache = null; // Yatopia
|
|
return (VillagerProfession) IRegistry.a((IRegistry) IRegistry.VILLAGER_PROFESSION, new MinecraftKey(s), (Object) (new VillagerProfession(s, villageplacetype, immutableset, immutableset1, soundeffect)));
|
|
}
|
|
}
|