Do not schedule poi task for each block write on chunk gen

Most of the time optional == optional1, so we shouldn't
schedule a task for each write.
This commit is contained in:
Spottedleaf 2021-04-21 20:04:42 +01:00 committed by Shane Freeder
parent 39bf5b525d
commit a9525a6f71
No known key found for this signature in database
GPG key ID: A3F61EA5A085289C

View file

@ -5,28 +5,22 @@ Subject: [PATCH] Remove stale POIs
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
index 4a87b9ebc2a584d8a2fca874342057e81fbbc1c6..bf9bf8368b345bf0ac3b14a08e8342f7bd63dead 100644 index 4a87b9ebc2a584d8a2fca874342057e81fbbc1c6..c38ef337f9a662d689994a0d530e8e655b843177 100644
--- a/src/main/java/net/minecraft/server/level/WorldServer.java --- a/src/main/java/net/minecraft/server/level/WorldServer.java
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java +++ b/src/main/java/net/minecraft/server/level/WorldServer.java
@@ -2067,8 +2067,16 @@ public class WorldServer extends World implements GeneratorAccessSeed { @@ -2078,6 +2078,11 @@ public class WorldServer extends World implements GeneratorAccessSeed {
Optional<VillagePlaceType> optional = VillagePlaceType.b(iblockdata); });
Optional<VillagePlaceType> optional1 = VillagePlaceType.b(iblockdata1); optional1.ifPresent((villageplacetype) -> {
+ // Paper start
+ BlockPosition blockposition1 = blockposition.immutableCopy();
+ this.getMinecraftServer().execute(() -> {
+ if (!optional.isPresent() && this.getPoiStorage().test(blockposition1, com.google.common.base.Predicates.alwaysTrue())) {
+ this.getPoiStorage().remove(blockposition1);
+ }
+ });
if (!Objects.equals(optional, optional1)) {
- BlockPosition blockposition1 = blockposition.immutableCopy();
+ //BlockPosition blockposition1 = blockposition.immutableCopy();
+ // Paper end
optional.ifPresent((villageplacetype) -> {
this.getMinecraftServer().execute(() -> { this.getMinecraftServer().execute(() -> {
@@ -2085,6 +2093,7 @@ public class WorldServer extends World implements GeneratorAccessSeed { + // Paper start
+ if (!optional.isPresent() && this.getPoiStorage().test(blockposition1, com.google.common.base.Predicates.alwaysTrue())) {
+ this.getPoiStorage().remove(blockposition1);
+ }
+ // Paper end
this.y().a(blockposition1, villageplacetype);
PacketDebug.a(this, blockposition1);
});
@@ -2085,6 +2090,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
} }
} }