From 667ce0ce4b179eb2d37ce3d2ab8e9544d3fcae8c Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 27 Oct 2023 22:09:55 +0100 Subject: [PATCH] Parse pony data on the client thread executor, and don't send unparsed pony data responses to a consenting server. Rather wait for the data to resolve and let the entity send it normally. # Conflicts: # src/main/java/com/minelittlepony/api/events/Channel.java # src/main/java/com/minelittlepony/client/util/render/NativeUtil.java --- .../java/com/minelittlepony/api/events/Channel.java | 10 +--------- .../client/util/render/NativeUtil.java | 13 +++++++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/minelittlepony/api/events/Channel.java b/src/main/java/com/minelittlepony/api/events/Channel.java index ce1ac4b8..95289480 100644 --- a/src/main/java/com/minelittlepony/api/events/Channel.java +++ b/src/main/java/com/minelittlepony/api/events/Channel.java @@ -13,7 +13,6 @@ import net.minecraft.util.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.minelittlepony.api.pony.Pony; import com.minelittlepony.api.pony.PonyData; @Environment(EnvType.CLIENT) @@ -37,14 +36,7 @@ public class Channel { ClientPlayNetworking.registerGlobalReceiver(REQUEST_PONY_DATA, (client, handler, ignored, sender) -> { registered = true; - if (client.player != null) { - Pony pony = Pony.getManager().getPony(client.player); - LOGGER.info("Server has just consented"); - - sender.sendPacket(CLIENT_PONY_DATA, MsgPonyData.write(pony.metadata(), PacketByteBufs.create())); - } else { - LOGGER.info("Server has just consented but the client player was not set"); - } + LOGGER.info("Server has just consented"); }); ServerPlayNetworking.registerGlobalReceiver(CLIENT_PONY_DATA, (server, player, ignore, buffer, ignore2) -> { PonyData packet = MsgPonyData.read(buffer); diff --git a/src/main/java/com/minelittlepony/client/util/render/NativeUtil.java b/src/main/java/com/minelittlepony/client/util/render/NativeUtil.java index 2de10b02..5ec669e4 100644 --- a/src/main/java/com/minelittlepony/client/util/render/NativeUtil.java +++ b/src/main/java/com/minelittlepony/client/util/render/NativeUtil.java @@ -88,16 +88,17 @@ public class NativeUtil { } public static void parseImage(Identifier resource, Consumer consumer, Consumer fail) { - parseImage(resource, consumer, fail, 0); - } - - private static void parseImage(Identifier resource, Consumer consumer, Consumer fail, int attempt) { - try { + MinecraftClient.getInstance().execute(() -> { if (!RenderSystem.isOnRenderThread()) { - RenderSystem.recordRenderCall(() -> parseImage(resource, consumer, fail, attempt)); + RenderSystem.recordRenderCall(() -> _parseImage(resource, consumer, fail, 0)); return; } + _parseImage(resource, consumer, fail, 0); + }); + } + private static void _parseImage(Identifier resource, Consumer consumer, Consumer fail, int attempt) { + try { MinecraftClient mc = MinecraftClient.getInstance(); TextureManager textures = mc.getTextureManager();