MSpace-Dev Posted November 10, 2019 Share Posted November 10, 2019 (edited) Hey all, I am trying to return an ITextComponent from the client to the server again. The reason I need to do this is so that I can use the i18n class to do some translations client side, and then send that message to the player server side. I have the bulk of it working, just need to figure out how to get a return from a packet. My onMessage function @Override public IMessage onMessage(PacketRetrieveTileData message, MessageContext ctx) { TileEntityBlockBase tile = message.tile; ITextComponent component = new TextComponentString(""); component.appendText("\n" + I18n.format("translate.key.here")); // RETURN CHAT COMPONENT BACK TO PLAYER THAT SENT INITIAL PACKET return null; } How I send the packet: @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!world.isRemote) { TileEntityBlockBase tile = world.getTileEntity(pos); // Tile entity null checks, etc, etc... PacketDispatcher.sendTileData(tile, (EntityPlayerMP) player); // <- Packet is sent here } return true; } I want to do something like this: ITextComponent component = PacketDispatcher.sendTileData(tile, (EntityPlayerMP) player); Is that possible? ^^ Edited November 10, 2019 by MSpace-Dev Quote Link to comment Share on other sites More sharing options...
MSpace-Dev Posted November 10, 2019 Author Share Posted November 10, 2019 When a player right clicks a block, they get information about it outputted to the chat. I want that to accept all translations my mod supports. I've tried to send a packet back, but I can not figure out for the life of me how to send it back to the same player that activated the block. Quote Link to comment Share on other sites More sharing options...
MSpace-Dev Posted November 10, 2019 Author Share Posted November 10, 2019 (edited) I'm not sending IComponentText in my first packet, that gets constructed in the onMessage() function. I send my TileEntity in the first packet. Am I missing something here? Not sure what a Chat Packet is exactly Edited November 10, 2019 by MSpace-Dev typo Quote Link to comment Share on other sites More sharing options...
MSpace-Dev Posted November 10, 2019 Author Share Posted November 10, 2019 Oh, never knew that class existed! That simplifies things so much more. I was detecting right-click on the server -> sending a packet to client to get translated -> constructed ITextComponent -> to display to the player. This is a much simpler option, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.