aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2020-12-21 17:04:31 +0200
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2020-12-21 17:04:31 +0200
commitea894bba3b8056740af61635139023ccf0756ded (patch)
treebfdc69f9636394802eb87d5a3acb576a8b1e0a1e
parent788176dcaa49ced35e9f441a820410bcd4f09cfe (diff)
downloadLibGui-ea894bba3b8056740af61635139023ccf0756ded.tar.gz
LibGui-ea894bba3b8056740af61635139023ccf0756ded.tar.bz2
LibGui-ea894bba3b8056740af61635139023ccf0756ded.zip
Fix dedicated server crashing when trying to load ClientPlayerEntity3.3.1
Apparently having a client-only-typed field referenced in a lambda body can be dangerous, so I moved the packet registration to the client init class.
-rw-r--r--gradle.properties2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java6
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java12
3 files changed, 7 insertions, 13 deletions
diff --git a/gradle.properties b/gradle.properties
index 20c3ff5..0779317 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.10.8
# Mod Properties
- mod_version = 3.3.0
+ mod_version = 3.3.1
maven_group = io.github.cottonmc
archives_base_name = LibGui
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java b/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java
index d216106..80fa414 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java
@@ -1,6 +1,7 @@
package io.github.cottonmc.cotton.gui.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;
@@ -28,8 +29,11 @@ public class LibGuiClient implements ClientModInitializer {
public void onInitializeClient() {
config = loadConfig();
- ScreenNetworkingImpl.initClient();
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(NinePatch.MetadataLoader.INSTANCE);
+
+ ClientPlayNetworking.registerGlobalReceiver(ScreenNetworkingImpl.SCREEN_MESSAGE_S2C, (client, networkHandler, buf, responseSender) -> {
+ ScreenNetworkingImpl.handle(client, client.player, buf);
+ });
}
public static LibGuiConfig loadConfig() {
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