Don't complete skull lookups on main thread (MC-227435)
This commit is contained in:
parent
1d194e5605
commit
333cc2e36f
1 changed files with 97 additions and 0 deletions
|
@ -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..602ee10b4328ef0c9e0301445a1dae3486a57e0a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/0001-Don-t-complete-skull-lookups-on-main-thread.patch
|
||||||
|
@@ -0,0 +1,53 @@
|
||||||
|
+From 66c09880e3b6a2b3029af424641827a5bd6e4e36 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
|
||||||
|
+@@ -8,6 +8,8 @@ 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;
|
||||||
|
+@@ -145,15 +147,24 @@ 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 172413fc0f303d5e15bc2bc55c09ce4faf5298a0..705d5ebb3d7b40745b318617ea39a7ea785b9504 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
|
||||||
|
@@ -145,15 +145,24 @@ 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);
|
Loading…
Reference in a new issue