mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-21 20:18:01 +01:00
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
This commit is contained in:
parent
4de3f3daa2
commit
667ce0ce4b
2 changed files with 8 additions and 15 deletions
|
@ -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);
|
||||
|
|
|
@ -88,16 +88,17 @@ public class NativeUtil {
|
|||
}
|
||||
|
||||
public static void parseImage(Identifier resource, Consumer<TriggerPixel.Mat> consumer, Consumer<Exception> fail) {
|
||||
parseImage(resource, consumer, fail, 0);
|
||||
}
|
||||
|
||||
private static void parseImage(Identifier resource, Consumer<TriggerPixel.Mat> consumer, Consumer<Exception> 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<TriggerPixel.Mat> consumer, Consumer<Exception> fail, int attempt) {
|
||||
try {
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
TextureManager textures = mc.getTextureManager();
|
||||
|
||||
|
|
Loading…
Reference in a new issue