Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

nooblong's Achievements

Tree Puncher

Tree Puncher (2/8)



  1. I storge data in an item's nbt, how can i get these data in the ContainerScreen and storge data into item's nbt again. i have no idea how to communicate between client's screen and container. My purpose is to save different data for different item and show them on gui
  2. I found a very stupid way to save my (Screen) data for each block instead of using (ContainerScreen) public class Mp3Gui extends Screen { ... public class BlockMp3 extends BlockBase { @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { if (!worldIn.isRemote){ Mp3TileEntity t = (Mp3TileEntity) worldIn.getTileEntity(pos); System.out.println("server send Gui packet"); MySimpleNetworkHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity)player), new GuiDataPacket(my gui data); return ActionResultType.SUCCESS; } else { f(worldIn,pos); } return ActionResultType.SUCCESS; } //Use this to cheat the inspection @OnlyIn(Dist.CLIENT) private static void f(World worldIn, BlockPos pos){ System.out.println("client open gui"); Mp3Gui mp3Gui = new Mp3Gui((Mp3TileEntity) worldIn.getTileEntity(pos)); Minecraft.getInstance().displayGuiScreen(mp3Gui); } and in dataPacket public class GuiDataPacket { public static void handle(GuiDataPacket msg, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> { World world; try { //clint to server ServerPlayerEntity sender = ctx.get().getSender(); //at client it will produce null pointer exception world = sender.world; } catch (NullPointerException e){ //server to client world = getClientWorld(); } if (!world.isRemote) { System.out.println("server receive gui packet"); if (world.getTileEntity(msg.blockPos) instanceof Mp3TileEntity) { Mp3TileEntity mp3TileEntity = ((Mp3TileEntity) world.getTileEntity(msg.blockPos)); set my tile entity } } if (world.isRemote){ System.out.println("client receive gui packet"); if (world.getTileEntity(msg.blockPos) instanceof Mp3TileEntity) { Mp3TileEntity mp3TileEntity = ((Mp3TileEntity) world.getTileEntity(msg.blockPos)); set my tile entity } } }); ctx.get().setPacketHandled(true); } //Use this to cheat the inspection @OnlyIn(Dist.CLIENT) private static World getClientWorld(){ return Minecraft.getInstance().world; } it does work.
  3. ok, i found how to do in SkinManager , thank you so much
  4. 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.
  5. 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
  6. 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?
  7. 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.
  8. How to get the player to switch to vec3 after getting it, or do you have a tutorial on this, I can hardly find it online
  9. i tried : player.setPositionAndUpdate(player.posX+1, player.posY, player.posZ+1); It just changing the x and y coordinates. Can I make player Move toward the mouse but Do not change orientation? Or force the player to press the w key for a while.what should I do?
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.