Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Climbing the interface ladder

From basic graphical interfaces to very advanced ones

Sending information from server to client

  • 2013-08-10 10:34:12
    The title explains my problem...
    I know that one can do that by using player.sendProgressBarUpdate, but you can only send two shorts with it, and thats not enough for my purpose. Does the method onPacketData in the packethandler only get called on the server? And if so, how would you send a packet from the server to the client in order to update the gui?
  • 2013-08-10 11:26:05
    Two shorts? You can send a short of shorts.

    You use the id to specify the information type you're sending and then you use the data to actually send the information. The data is a short so you can send that much information. But you can send a ton of different information types since the id is also a short.

    So basically you can send 65536 shorts. Or in other words: a short of shorts.
  • 2013-08-10 11:56:38
    Ok, let me explain my problem a bit better:
    The server has a list of orders that i want to send to the client to display. Every order has the following information:
    -a byte containing the id of the order.
    -a short containing the position.
    -a short containing additional data
    -some also have an integer containing even more data

    It seems to me that it would be more efficient to send a packet with all the information in it rather than sending a packet for each value(or maybe tow in case of the integer)
  • 2013-08-10 12:42:00
    I would totally use normal sendProgressBarUpdate for that.

    But if you don't want to, the onPacketData is called on the client side if it is the client that receives the packet. Take a look in the PacketDispatcher.java to see how you can send a packet. But you'll have to be very careful if you do it yourself, it's not going to be more efficient if you synchronize it more often than necessary and you'll also have to make sure that it's always synchronized.
  • 2013-08-10 13:18:26
    Well you could use the detectAndSendChanges() and addCraftingToCrafters to tell the packethandler to send stuff, and then just recieve the stuff with the packethandler instead of recieving it with updateProgressBar, it would have the same effect right?

    Because sendProgressBarUpdate is just an other way of sending a packet, or did I miss something?
  • 2013-08-10 15:13:45
    Every syncing in minecraft is in the end Packets. That's the case for everything from meta data to the gui synching. So yeah, you can totally do it like that.
  • 2013-10-29 03:38:48
    I also have a problem to sync values from the tileentity to the GUI. It works well with markblockforupdate if I don't change the metadata, because if I do that the GUI won't get an updated reference of the tileentity. If i print out the values to console in the method isprovidingstrongpower() i always get the right values - but don't helps in my GUI. If i store the powerstate in a field of the tileentity (if it should power or not) and read it out in isprovidingstrongpower() and change the metadata also there ill get the right values in my gui but the block gets powered first when any block changed around. I fixed this with notifzblockchange() but this made my gui getting wrong\old values from the tileentity again.

    That's weird and i am desperate.
  • 2013-10-29 03:56:30
    Sorry for double posting. I am writing with my smartphone and accidentally pressed the send button. My question is if I could fix this by using the container to sync data (my block has no inventorie)? Or is there an other way?
  • 2013-10-29 05:44:17
    There may be other ways but syncing it with the container is the easiest way to do it. Inventory has nothing to do with syncing GUI data.
  • 2013-10-29 11:10:51
    Thanks, I'll give it a try. I already searched the whole web and everywhere it's told to use packets. Awesome job guys guys and that for free. Thanks a lot :)
  • 2017-09-30 12:10:06
    ? ??? ? ???????? ??????? ??????? ??????????? ??????????????? ??????, ????????? ??? ????????? ? ?????, ? ????? ? ??? ? ??????-???????? ???????????? ??????? ?????????? ????????? ??? ????????? ???????????????????. ???? ????? <a href=http://gun54.ru/product_4703.html>?????????????? ????? ??????</a> ? ????? ????????-???????? ????? ??????????????? ??????????? ? ????????????? ??????? ???????????? ??????????.

    ?????????????? ???????? ? ?????????, ?????? ?? ? ????????? ????, ?????????? ? ????? ? ???????? ??? ????? ?? ???????, ???????? ??????? ? ????????, ???? ? ?????????? ? ???, <a href=http://gun54.ru/category_450.html>????? ??????????</a> – ??? ?????? ????????? ????? ????? ???????. ???? ????????? ??????? ????? ?????????, ???? ????? ?? ??????? ?? ?????? ?????, ?????? ??? ???????????? ???????? ? ??????????????? ?????????.

    ??? ??????? ? ???????????? ???????????? ???????? ?? ???? ??????? ??????, ? ????? ?? ????? ??????? ?? ? ??????? ???????????? ????????. ?? ?????? ?????????? ??? ????? ?????????? ???????? ???????????? ?????? ?? ?????? ?????? ????????-???????? - <a href=http://gun54.ru/product_4703.html>???????? hatsan 125 ? ????</a> , ? ??? ????? ??????????? ? ??? ??????????? ???????? ??????? ?????????.

    ? ??????? ???????????? ? ????? ???????? ???????????? ?????? ??? ??????????, ? ??? ??????? ?? ?????????? ??????? ????? ?????????? ?? ??????? ????????. ???? ????? ????????!
  • 2017-10-08 05:16:58
    ? ????? ??????-???????? ??????? ????????? ??????????? ??????????, ??????? ??? ??????? ? ?????, ? ????? ? ??? ? ????????-???????? ???????????? ????????? ?????????? ????????? ??? ????????? ??????. ???? ????? <a href=http://gun54.ru/category_445.html>????? ???????? ????????</a> ? ??? ? ???????? ????? ??????????????? ??????????? ? ???????? ??????????? ???????????? ??????????.

    ?????????????? ???????? ? ?????????, ?????? ?? ? ???? ?? ??????, ?????????? ??2 ? ???????? ?? ????? ?? ???????, ????????? ???? ? ????????, ???? ? ?????????? ? ???, <a href=http://gun54.ru/index.php?categoryID=513&sort=Price&direction=DESC&show_all=yes>????? ??? ?????????? ????? ??????</a> – ??? ????? ???? ????? ????? ????? ???????. ???? ????????? ??????? ????? ?????????, ???? ????? ?? ??????? ?? ????????? ?????, ??? ??? ???????? ??? ??????????? ? ??????????????? ?????????.

    ??? ????????-??????? ? ???????????? ?????????? ???????? ?? ???? ??????? ??????, ? ????? ?? ???? ???????? ?? ? ??????? ???????????? ????????. ?? ?????? ?????????? ??? ????? ?????????? ???????? ???????????? ?????? ?? ?????? ?????? ????????-???????? - <a href=http://gun54.ru/category_493.html>?????? ???????????? ??? ????</a> , ? ??? ????? ??????????? ? ??? ?????????? ????? ? ??????? ??????? ?????????.

    ? ???????? ???????????? ? ????? ???????? ???????????? ?????? ??? ??????????????? ??????, ? ??? ????????? ??????? ?? ?????????? ??????? ????? ??????????? ????????. ???? ????? ????????!
  • 2017-10-08 17:58:08
    ? ??? ? ???????? ??????? ???????? ??????????? ??????????????? ??????, ???????????? ??? ??????? ? ?????, ? ????? ? ??? ? ???????? ??????? ??????? ?????????? ??????? ??? ????????? ???????????????????. ???? ????? <a href=http://gun54.ru/product_3474.html>?????? ?? 654?</a> ? ??? ? ????????-???????? ????? ??????????????? ??????????? ? ???????? ??????? ???????????? ??????????.

    ???????? ? ?????????, ?????? ?? ? ????????? ????, ?????????? ? ????? ? ???????? ?? ????? ?? ???????, ???????? ??????? ? ????????, ???? ? ???????, <a href=http://gun54.ru/product_3519.html>?? 61 ????</a> – ??? ?????? ????? ????? ?????? ????????????. ????????? ????? ??????? ????? ?????????, ??? ????????? ?? ??????? ?? ????????? ?????, ?????? ??? ???????????? ???????? ? ??????????????? ???????.

    ??? ??????? ? ???????????? ?????????? ???????? ?????? ????? ??????, ? ????? ?? ???? ???????? ?? ? ??????? ???????????? ????????. ?? ?????? ?????????? ??? ????? ?????????? ?????????? ??????? ?????? ?? ????????? ?????? ??????-???????? - <a href=http://gun54.ru/category_497.html>??? ?????? ? ????????????</a> , ? ??? ????? ???????? ? ??? ?????????? ????? ? ??????? ??????? ?????????.

    ? ??????? ???????????? ? ??? ???????????? ?????? ??? ??????????????? ??????, ? ??? ????????? ??????? ?? ?????????? ???????? ????? ?????????? ?? ??????? ????????. ???? ????? ???????!
  • 2017-10-09 07:26:09
    ? ????? ???????? ??????? ??????? ??????????? ??????????????? ??????, ????????? ??? ??????? ? ?????, ? ????? ? ??? ? ??????-???????? ???????????? ??????? ?????????? ??????? ??? ????????? ??????. ???? ????? <a href=http://gun54.ru/category_580.html>?????? ??????? ?????????</a> ? ??? ? ???????? ?????????????? ? ???????? ??????? ?????????? ????????.

    ???????? ? ?????????, ?????? ?? ? ????????? ????, ?????????? ? ????? ? ???????? ?? ????? ?? ???????, ????????? ???? ? ????????, ???? ? ?????????? ? ???, <a href=http://gun54.ru/product_4721.html>??????? ??? ?? 38 ??????</a> – ??? ?????? ????? ????? ????? ???????. ????????? ????? ??????? ????? ?????????, ???? ????? ?? ?????????? ?? ????????? ?????, ?????? ??? ???????????? ???????? ? ?????????????? ???????.

    ??? ??????-??????? ? ???????????? ?????????? ???????? ?????? ????? ??????, ? ????? ?? ???? ??????? ?????? ??????????? ???????-???????????? ????????. ?? ?????????? ??? ????? ?????????? ?????????? ??????? ?????? ?? ????????? ?????? ??????-???????? - <a href=http://gun54.ru/category_475.html>??????? ??? ??????????? ??????</a> , ? ??? ????? ??????????? ? ??? ??????????? ???????? ??????? ???????.

    ? ???????? ???????????? ? ??? ???????????? ?????? ??? ??????????, ? ??? ????????? ??????? ?? ?????????? ??????? ????? ?????????? ?? ??????? ????????. ???? ????? ???????!
  • Log in or sign up to reply to this thread