From 8832beac3258ed351045bfbe2c72dfd95389e2ef 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. --- .../api/pony/network/fabric/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/pony/network/fabric/Channel.java b/src/main/java/com/minelittlepony/api/pony/network/fabric/Channel.java index 2c719950..a35e7ecc 100644 --- a/src/main/java/com/minelittlepony/api/pony/network/fabric/Channel.java +++ b/src/main/java/com/minelittlepony/api/pony/network/fabric/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.IPony; import com.minelittlepony.api.pony.IPonyData; import com.minelittlepony.api.pony.network.MsgPonyData; import com.minelittlepony.client.MineLittlePony; @@ -38,14 +37,7 @@ public class Channel { ClientPlayNetworking.registerGlobalReceiver(REQUEST_PONY_DATA, (client, handler, ignored, sender) -> { registered = true; - if (client.player != null) { - IPony pony = IPony.getManager().getPony(client.player); - LOGGER.info("Server has just consented"); - - sender.sendPacket(CLIENT_PONY_DATA, new MsgPonyData(pony.metadata(), pony.defaulted()).toBuffer(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) -> { MsgPonyData packet = new MsgPonyData(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 75639cd4..7063d0c0 100644 --- a/src/main/java/com/minelittlepony/client/util/render/NativeUtil.java +++ b/src/main/java/com/minelittlepony/client/util/render/NativeUtil.java @@ -87,16 +87,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();