Jump to content

[1.7.10] Send long in container via sendProgressBarUpdate?


Recommended Posts

Hi, this is my question:

Is it possible, and yes - how,  to sync long between containers (server-client)? Or i have to use packets???


Why i am using longs: in my tileentity, because of use of big numbers, multiplications of integers wre going wrong (10000*989000=-216578532), so i decided to use longs instead...


Thanks for help!

If you have any questions - just ask!!!

Link to comment
Share on other sites

The most you can use is a short, as you already know. But via some bit-tricks you can transform a long into 8 short values.



[nobbc]long l = <someLongValue>;
short[] shorts = new short[8];
for (int i = 0; i < 8; i++) {
    shorts[i] = (short) ((l >>> (i << 3)) & 0xFF);



[nobbc]short[] shorts = <the shorts>
long l = 0;
for (int i = 0; i < 8; i++) {
    l |= (((long) shorts[i]) << (i << 3)) & 0xFF;


Then sync all the 8 shorts.

Untested, but this should work.

Otherwise, use a custom packet.


Thanks, i'll try it!!!

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.

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.


  • Create New...

Important Information

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