Oops was registering channels to wrong environments

This commit is contained in:
Ran
2022-02-20 00:15:33 +06:00
parent e4a97dd76d
commit 1c859cd7da
7 changed files with 46 additions and 19 deletions
@@ -15,7 +15,7 @@ public class LodCommonMain {
public static LodForgeMethodCaller forgeMethodCaller;
public static NetworkInterface networkInterface;
public static void startup(LodForgeMethodCaller caller, boolean serverSided) {
public static void startup(LodForgeMethodCaller caller, boolean serverSided, NetworkInterface networkInterface) {
LodCommonMain.serverSided = serverSided;
if (caller != null) {
LodCommonMain.forge = true;
@@ -23,15 +23,17 @@ public class LodCommonMain {
}
DependencySetup.createInitialBindings();
LodCommonMain.networkInterface = networkInterface;
if (!serverSided) {
networkInterface.register_Client();
} else {
networkInterface.register_Server();
}
}
public static void initConfig() {
ConfigGui.init(Config.class);
}
public static void registerNetworking(NetworkInterface networkInterface) {
LodCommonMain.networkInterface = networkInterface;
networkInterface.register();
}
}
@@ -3,6 +3,9 @@ package com.seibel.lod.common.networking;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
/**
* This is packet handler for our mod
@@ -18,4 +21,10 @@ public class NetworkHandler {
// You can make client execute something by using client.execute(Runnable)
// In the fabric docs it says that client.execute is ran on the render thread?
}
// If you need the response sender then tell me
// I'll add extra code to get the response sender
public static void receivePacketServer(MinecraftServer server, ServerPlayer client, ServerGamePacketListenerImpl handler, FriendlyByteBuf buf) {
// TODO: Server sided stuff here
}
}
@@ -4,5 +4,6 @@ package com.seibel.lod.common.networking;
* @author Ran
*/
public interface NetworkInterface {
void register();
void register_Client();
void register_Server();
}