Posted October 19, 20205 yr 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.
October 19, 20205 yr 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?
October 20, 20205 yr 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
October 21, 20205 yr 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.
October 21, 20205 yr 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.