Posted March 17, 20205 yr Hello, I am facing a sides problem. I have register an id in ServerWorld Data and I want to display it in a gui which is ClientSide. I know how to send Packet to Server but here I want to send a packet from the server to the client so why can I do that ? Or is there anyway to have global value register as capability and which are accesible from both side ?
March 17, 20205 yr 43 minutes ago, matt1999rd said: I want to send a packet from the server to the client Which client? More than one player can be connected, you have to pick one. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 17, 20205 yr Author yes that 's right the player I will always choose is the one who open the gui and try to question the value stored
March 17, 20205 yr Hi If I understand your question correctly- your server will need to remember which client was interested in the GUI and then send the information to them. Or - when the client wants to know the ID, it sends a packet asking for the ID and the server responds. I don't know of any "automatically synchronised" global variables in Forge or Vanilla; but you might look at WorldSavedData, perhaps it can do what you need -TGG
March 18, 20205 yr Author I want to do something like MapItemID but with ID controlled by random and unique generation . 14 hours ago, TheGreyGhost said: but you might look at WorldSavedData, perhaps it can do what you need In fact I did use this in my mod see on git hub : https://github.com/matt1999rd/GatesMod/blob/master/src/main/java/fr/mattmouss/gates/energystorage/IdStorage.java https://github.com/matt1999rd/GatesMod/blob/master/src/main/java/fr/mattmouss/gates/network/ControlIdData.java This idStorage is an EnergyCapability used in this TE : https://github.com/matt1999rd/GatesMod/blob/master/src/main/java/fr/mattmouss/gates/tileentity/TollGateTileEntity.java (see setId ChangeId getId)
March 19, 20205 yr Author ok if anyone has an idea on how to display server value into client gui please answer this topic because I am stuck in this now
March 19, 20205 yr Packets. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
March 20, 20205 yr You can send a packet to the client whenever the value on the server changes. On the client, simply change the GUI when such packet is received. Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
March 20, 20205 yr Author thank you fr your answer but it still not working because I cannot return value in Packet I can only transfer value and I cannot access TE on client side. 5 hours ago, DavidM said: On the client, simply change the GUI when such packet is received. I don't understand what you mean by changing gui because the problem I face only take care of changing the TE. the gui associated has only function of displaying. By the way is it possible for multiple player to access the same gui in Vanilla at the same moment ? it doesn't make sense on one hand I cannot change value that are client side with server side and on the other hand the Server must control everything how can this work properly ? Edited March 20, 20205 yr by matt1999rd
March 20, 20205 yr 1 hour ago, matt1999rd said: thank you fr your answer but it still not working because I cannot return value in Packet I can only transfer value and I cannot access TE on client side. By that I meant using your packet to sync the necessary data needed in order to update the information in the GUI. In this case, you would want to use the packet to sync the tile entity. To illustrate, say you have a GUI that has access to a tile entity. You want to display a string stored in the tile entity, which can change during the opening of the GUI of the tile entity. // Pseudocode @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { // ... drawString(this.myTileEntity.getStoredString()); } Since the string is fetched from the tile entity per rendering of the screen (per frame), it will get updated when your tile entity is updated (in your case, with a sync packet from the server). The post below from diesieben07 illustrated a more suitable approach for your case. 1 hour ago, matt1999rd said: By the way is it possible for multiple player to access the same gui in Vanilla at the same moment ? They are not literally the same "GUI instance", but GUIs/containers like chests can be opened by multiple players at the same time. 1 hour ago, matt1999rd said: it doesn't make sense on one hand I cannot change value that are client side with server side and on the other hand the Server must control everything how can this work properly ? You can change client side values from the server by sending packets. When the client receives a packet, you can change values on the client based on the information in the packet. Technically, you could change server values from the client too with packets. However, since clients can be modified to send false data, most packets sent from a client should be request packets: they should not dictates values on the server, but instead should let the server determine whether the requested actions are valid and should be performed. Edited March 20, 20205 yr by DavidM Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
March 20, 20205 yr Author thank you all for your information. I have finally found a way to display one of my int using Container#trackInt. The others value (id) is strangely defined multiple time : [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 4 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 410085969 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 4 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 623911458 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 4 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 810621267 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 4 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 193589273 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 4 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 1432532023 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 1 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 2099975825 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 1 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 1626932760 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 1 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 1150482662 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 1 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 1437467173 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:81]: ------------price written : 1 [15:47:25] [Server thread/INFO] [STDOUT/]: [fr.mattmouss.gates.tollfuckingcapability.TollStorage:serializeNBT:82]: ------------id written : 2110306105 here is the updated code : https://github.com/matt1999rd/GatesMod/tree/master/src/main/java/fr/mattmouss/gates see information in TollStorage and in TollGate because I fix the id there. The idea of this is to defining id corresponding to each TE. It use Random#nextInt function I don't understand how to use listener I find IContainerListener but this gives three function with no explanation of how to use this... Edited March 20, 20205 yr by matt1999rd correcting and adding some more explanation
March 20, 20205 yr Author because this is what I used for tollkey and it work perfectly well but I want people to use same id with different toll gate... as a beginning definition I choose a random Id which can be modified on TechScreen 20 minutes ago, diesieben07 said: trackInt only supports 16-bit values unfortunately. at least I can do a 16-bit id instead of 32 because it allows almost 2^16 possible id which is sufficiently huge
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.