diff options
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java | 12 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiClient.java | 8 |
3 files changed, 8 insertions, 14 deletions
diff --git a/build.gradle b/build.gradle index 074acc2..acb42bf 100644 --- a/build.gradle +++ b/build.gradle @@ -133,4 +133,4 @@ artifactory { } else { println "Cannot configure artifactory; please define ext.artifactoryUsername and ext.artifactoryPassword before running artifactoryPublish" } -}
\ No newline at end of file +} diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java index a8d8921..58c7831 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java @@ -1,8 +1,5 @@ package io.github.cottonmc.cotton.gui.impl; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.entity.player.PlayerEntity; @@ -73,14 +70,7 @@ public class ScreenNetworkingImpl implements ScreenNetworking { }); } - @Environment(EnvType.CLIENT) - public static void initClient() { - ClientPlayNetworking.registerGlobalReceiver(SCREEN_MESSAGE_S2C, (client, networkHandler, buf, responseSender) -> { - handle(client, client.player, buf); - }); - } - - private static void handle(Executor executor, PlayerEntity player, PacketByteBuf buf) { + public static void handle(Executor executor, PlayerEntity player, PacketByteBuf buf) { ScreenHandler screenHandler = player.currentScreenHandler; // Packet data diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiClient.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiClient.java index 91ce7b7..ccb4a0a 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiClient.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/LibGuiClient.java @@ -1,6 +1,7 @@ package io.github.cottonmc.cotton.gui.impl.client; import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.resource.ResourceType; @@ -8,8 +9,8 @@ import net.minecraft.resource.ResourceType; import blue.endless.jankson.Jankson; import blue.endless.jankson.JsonElement; import blue.endless.jankson.JsonObject; -import io.github.cottonmc.cotton.gui.impl.ScreenNetworkingImpl; import io.github.cottonmc.jankson.JanksonFactory; +import io.github.cottonmc.cotton.gui.impl.ScreenNetworkingImpl; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -28,8 +29,11 @@ public class LibGuiClient implements ClientModInitializer { public void onInitializeClient() { config = loadConfig(); - ScreenNetworkingImpl.initClient(); ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(NinePatchInternals.MetadataLoader.INSTANCE); + + ClientPlayNetworking.registerGlobalReceiver(ScreenNetworkingImpl.SCREEN_MESSAGE_S2C, (client, networkHandler, buf, responseSender) -> { + ScreenNetworkingImpl.handle(client, client.player, buf); + }); } public static LibGuiConfig loadConfig() { |