Jump to content

[1.12] How to get selected slot index on client side?


WildHeart

Recommended Posts

Hello, i created custom GuiScreen on client and Container on server, now I was faced with the problem of how to obtain on the client which slot was clicked/selected by mouse click. On the server in the container I created the variable, and the client does not know how to do. Can you tell me?

Link to comment
Share on other sites

Just now, WildHeart said:

How to send packet with List<String>? (How to convert List<String> to bytes.)

Store the size of the list as an integer, then loop through the list and store each string. To read it, create a new list, read the size, and then loop through that number of times to read each string.

Link to comment
Share on other sites

4 minutes ago, Jay Avery said:

Store the size of the list as an integer, then loop through the list and store each string. To read it, create a new list, read the size, and then loop through that number of times to read each string.

So?

private byte[] writeToByteArray(ArrayList<UObject> list) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(baos);
    for (UObject element : list) {
        out.writeObject(element);
    }
    return baos.toByteArray();
}

 

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.