Don't complete skull lookups on main thread (MC-227435)

This commit is contained in:
Shane Freeder 2021-06-29 17:34:20 +01:00
parent d0c06257f1
commit 73d13c8c88

View file

@ -0,0 +1,97 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
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 <theboyetronic@gmail.com>
+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<GameProfile> 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<GameProfile> 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);