From 73d13c8c88baa6d8180fd91807d080d83fab1c39 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 29 Jun 2021 17:34:20 +0100 Subject: [PATCH] Don't complete skull lookups on main thread (MC-227435) --- ...kull-lookups-on-main-thread-MC-22743.patch | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 patches/server/Don-t-complete-skull-lookups-on-main-thread-MC-22743.patch diff --git a/patches/server/Don-t-complete-skull-lookups-on-main-thread-MC-22743.patch b/patches/server/Don-t-complete-skull-lookups-on-main-thread-MC-22743.patch new file mode 100644 index 0000000000..2d50df964d --- /dev/null +++ b/patches/server/Don-t-complete-skull-lookups-on-main-thread-MC-22743.patch @@ -0,0 +1,97 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Tue, 29 Jun 2021 17:17:34 +0100 +Subject: [PATCH] Don't complete skull lookups on main thread (MC-227435) + + +diff --git a/0001-Don-t-complete-skull-lookups-on-main-thread.patch b/0001-Don-t-complete-skull-lookups-on-main-thread.patch +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/0001-Don-t-complete-skull-lookups-on-main-thread.patch +@@ -0,0 +0,0 @@ ++From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 ++From: Shane Freeder ++Date: Tue, 29 Jun 2021 17:17:34 +0100 ++Subject: [PATCH] Don't complete skull lookups on main thread ++ ++--- ++ .../level/block/entity/SkullBlockEntity.java | 17 ++++++++++++++--- ++ 1 file changed, 14 insertions(+), 3 deletions(-) ++ ++diff --git a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java ++index 172413fc0..59ce41527 100644 ++--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java +++++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java ++@@ -0,0 +0,0 @@ import com.mojang.authlib.properties.Property; ++ import java.util.UUID; ++ import java.util.function.Consumer; ++ import javax.annotation.Nullable; +++ +++import net.minecraft.Util; ++ import net.minecraft.core.BlockPos; ++ import net.minecraft.nbt.CompoundTag; ++ import net.minecraft.nbt.ListTag; ++@@ -0,0 +0,0 @@ public class SkullBlockEntity extends BlockEntity { ++ ++ public static void updateGameprofile(@Nullable GameProfile owner, Consumer callback) { ++ if (owner != null && !StringUtil.isNullOrEmpty(owner.getName()) && (!owner.isComplete() || !owner.getProperties().containsKey("textures")) && SkullBlockEntity.profileCache != null && SkullBlockEntity.sessionService != null) { ++- SkullBlockEntity.profileCache.getAsync(owner.getName(), (gameprofile1) -> { +++ // Paper start +++ SkullBlockEntity.profileCache.getAsync(owner.getName(), (gameprofile) -> { +++ Runnable runnable = () -> { +++ GameProfile gameprofile1 = gameprofile; ++ Property property = (Property) Iterables.getFirst(gameprofile1.getProperties().get("textures"), (Object) null); ++ ++ if (property == null) { ++ gameprofile1 = SkullBlockEntity.sessionService.fillProfileProperties(gameprofile1, true); ++ } ++ ++- SkullBlockEntity.profileCache.add(gameprofile1); ++- callback.accept(gameprofile1); +++ GameProfile finalGameprofile = gameprofile1; +++ net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { +++ SkullBlockEntity.profileCache.add(finalGameprofile); +++ callback.accept(finalGameprofile); +++ }); +++ }; +++ Util.backgroundExecutor().execute(runnable); +++ // paper end ++ }); ++ } else { ++ callback.accept(owner); ++-- ++2.32.0 ++ +diff --git a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java +@@ -0,0 +0,0 @@ public class SkullBlockEntity extends BlockEntity { + + public static void updateGameprofile(@Nullable GameProfile owner, Consumer callback) { + if (owner != null && !StringUtil.isNullOrEmpty(owner.getName()) && (!owner.isComplete() || !owner.getProperties().containsKey("textures")) && SkullBlockEntity.profileCache != null && SkullBlockEntity.sessionService != null) { +- SkullBlockEntity.profileCache.getAsync(owner.getName(), (gameprofile1) -> { ++ // Paper start ++ SkullBlockEntity.profileCache.getAsync(owner.getName(), (gameprofile) -> { ++ Runnable runnable = () -> { ++ GameProfile gameprofile1 = gameprofile; + Property property = (Property) Iterables.getFirst(gameprofile1.getProperties().get("textures"), (Object) null); + + if (property == null) { + gameprofile1 = SkullBlockEntity.sessionService.fillProfileProperties(gameprofile1, true); + } + +- SkullBlockEntity.profileCache.add(gameprofile1); +- callback.accept(gameprofile1); ++ GameProfile finalGameprofile = gameprofile1; ++ net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { ++ SkullBlockEntity.profileCache.add(finalGameprofile); ++ callback.accept(finalGameprofile); ++ }); ++ }; ++ net.minecraft.Util.backgroundExecutor().execute(runnable); ++ // Paper end + }); + } else { + callback.accept(owner);