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

When trying to send a package from the Spigot Plugin, this warning appears
I tried to decode it any way or even removed everything, all without success

Unknown custom packet identifier: mod_id:channel_id

Network Init:

public class NetworkHandler {

    public static final String FD_ID = "mod_id";
    public static final String PROTOCOL_VERSION = Integer.toString(1);

    public static void init() {
        SimpleChannel network = NetworkRegistry.newSimpleChannel(
                new ResourceLocation(FD_ID, FDCore.FD_CHANNEL),
                () -> PROTOCOL_VERSION,
                PROTOCOL_VERSION::equals,
                PROTOCOL_VERSION::equals);

        network.registerMessage(0, UIPacket.class, UIPacket::encode, UIPacket::decode, UIPacket::handle);
    }

}

 

UIPacket:

public class UIPacket {

    private final JsonObject jsonObject;

    public UIPacket(JsonObject jsonObject) {
        this.jsonObject = jsonObject;
    }

    public static void encode(UIPacket packet, PacketBuffer buf) {
        buf.writeUtf(packet.jsonObject.toString(), 262144);
    }

    public static UIPacket decode(PacketBuffer buf) {
        int bytesCount = buf.readableBytes();
        byte[] imageBytes = new byte[bytesCount];
        for (int i = 0; i < bytesCount; ++i)
            imageBytes[i] = buf.readByte();
                                       
        // buf.readUtf(262144);

        return new UIPacket(new JsonParser().parse(new String(imageBytes).substring(1)).getAsJsonObject());
    }

    public static void handle(UIPacket packet, Supplier<NetworkEvent.Context> ctx) {
        ctx.get().enqueueWork(() -> {
            JsonObject jsonObject = packet.jsonObject;

            for (UIHandler handler : Handlers.handlersList) {
                if (jsonObject.has(handler.getId())) {
                    handler.handle(jsonObject);
                    break;
                }
            }
        });
    }

 

Spigot:

// init
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, CHANNEL);

// sending
player.sendPluginMessage(plugin, CHANNEL, "text".getBytes(StandardCharsets.UTF_8));

Edited by spray

The version you are using is no longer supported on this forum.

Please update to a modern version of Minecraft to receive support.

Currently supported versions are 1.19.2 (Latest) and 1.18.2 (LTS).

Guest
This topic is now closed to further replies.

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.