Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello, recently i've been struggling with sending packets from the server to the client side. I understood the concept but i still don't know how to do it.

1) how do can i send a msg to the client side i did that :

public class ModPacketHandler {
	private static final String PROTOCOL_VERSION = "1";
	public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
	    new ResourceLocation("mod", "main"),
	    () -> PROTOCOL_VERSION,
	    PROTOCOL_VERSION::equals,
	    PROTOCOL_VERSION::equals
	);
	
	public static void handle(String msg, Supplier<NetworkEvent.Context> ctx) {
	    ctx.get().enqueueWork(() -> {
	        // Work that needs to be threadsafe (most work)
	        ServerPlayerEntity sender = ctx.get().getSender(); // the client that sent this packet
	        // do stuff
	    });
	    ctx.get().setPacketHandled(true);
	}
}

But i don't know how to use it. And i don't even know if it is necessary.

2) I don't know what i have to put in the "msg" variable because what i want to do is send the position of a particules that has been determinated randomly by the server side so that they can be synchronized.

Any help or documentation will be appriciated. Thank you for helping

  • Author
MinesteriousPacketHandler.INSTANCE.sendTo("something i don't know what to put here but its a string", NetworkManger "here too..." , NetworkDirection.PLAY_TO_CLIENT); // On the last one i don't know what to put between PLAY_TO_CLIENT or LOGIN_TO_CLIENT	

that's what i tried to do for now ...

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.