Jump to content

Recommended Posts

Posted

I setup my SimpleNetworkWrapper in my preInit method of my base mode class. This works fine for dedicated servers and single player, but when my mods runs as a client in multiplayer, it crashes. How can I prevent my mod from setting up the SimpleNetworkWrapper when it is run as a client on multiplayer. I already tried

Minecraft.getMinecraft.isSinglePlayer()

to detect if my mod is running on an integrated server, but it always returns false.

Posted

I fixed the issue for single player by making a global variable that the integrated server can set directly, nullifying the need for packets. Now my SimpleNetworkWrapper isn't working on multiplayer. I set it up in my server's preInit method with

net = NetworkRegistry.INSTANCE.newSimpleChannel("dataChannel");
net.registerMessage(PacketHandler.class, Packet.class, 0, Side.CLIENT);

and send it with

net.sendTo(new Packet(data), player);

I tested this code on single player without the global variable and it worked, but on multiplayer the client doesn't receive the packet.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.