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

 

I make a netty server on mod.

 

@Mod.EventBusSubscriber(modid = MusicRestaurant.MOD_ID, value = Dist.DEDICATED_SERVER)
public class ServerEventSubscriber {

    @SubscribeEvent
    public static void serverStarted(FMLServerStartedEvent event){
        try {
            System.out.println("nettyStart");
            NettyServer.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@OnlyIn(Dist.DEDICATED_SERVER)
public class NettyServer {

    public static final int PORT = 12333;

    static EventLoopGroup bossGroup = new NioEventLoopGroup();
    static EventLoopGroup workerGroup = new NioEventLoopGroup();

    public static void start() throws Exception {
        try {
            ServerBootstrap bootstrap = new ServerBootstrap();
            bootstrap.group(bossGroup, workerGroup);
            bootstrap.channel(NioServerSocketChannel.class);
            bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {
                @Override
                protected void initChannel(SocketChannel ch) throws Exception {
                    ch.pipeline().addLast(new NettyServerHandler());
                }
            });
            ChannelFuture channelFuture = bootstrap.bind(PORT).sync();



            channelFuture.addListener(new ChannelFutureListener() {
                public void operationComplete(ChannelFuture channelFuture) throws Exception {
                    if (channelFuture.isSuccess()){
                        System.out.println("lister"+PORT+"success");
                    } else {
                        System.out.println("listen"+PORT+"fail");
                    }
                }
            });
        } finally {
            MusicRestaurant.LOGGER.error("ServerShutdown");
            bossGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();
        }
    }

}

when server started, command line show 

[02:03:29] [Server thread/INFO] [STDOUT/]: [github.nooblong.mr.util.ServerEventSubscriber:serverStarted:20]: nettyStart
[02:03:29] [Server thread/ERROR] [gi.no.mr.MusicRestaurant/]: ServerShutdown
[02:03:29] [nioEventLoopGroup-2-1/INFO] [STDOUT/]: [github.nooblong.mr.upload.NettyServer$2:operationComplete:38]: listen12333success

why after "ChannelFuture channelFuture = bootstrap.bind(PORT).sync();"

it still close.

  • Author
2 minutes ago, diesieben07 said:

Why?

I want to upload some file from client to server, Or you mean I would better to use minecraft's own tool to upload about 10M file?

  • Author
13 hours ago, diesieben07 said:

Unless you really need to, you should not deviate from Minecraft's default networking as it will require potentially lots of extra setup for people using your mod (extra firewall rules, etc.) or make it even impossible (on server hosts which do not allow additional ports to be opened).

I use SImpleChannel to send message, it works on single player, but when I use server and client, client show 

internal exception io.netty.handler.codec.decoderException:java.io.IOExcepton: payload may not be larger than 32767 bytes

how to send larger files, or how to split it to send

  • Author
20 hours ago, diesieben07 said:

You already discovered how to do it: Split it into multiple packets.

one last question, 

Can I customize the ResourceLocation and Let it point to a folder at the same level as /mods

How should I modify the sounds.json?

I want to register resources dynamically in the game.

  • Author

 

2 hours ago, nooblong said:

one last question, 

Can I customize the ResourceLocation and Let it point to a folder at the same level as /mods

How should I modify the sounds.json?

I want to register resources dynamically in the game.

ok, i found how to do in SkinManager , thank you so much

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.