Posted March 13, 20214 yr For some reason when I TrackIntArray onto a custom made IIntArray and the data changes in the IIntArray on the server it isn't updating the client. Is that now its supposed to work? Or do I manually have to edit DetectAndSendChanges? https://github.com/Beardlessbrady/Currency-Mod/blob/master-1.16/src/main/java/com/beardlessbrady/gocurrency/blocks/vending/VendingContainer.java#L87 Edited March 13, 20214 yr by BeardlessBrady
March 15, 20214 yr The logic is flawed. When an IIntArray is tracked, it creates a new IntReferenceHolder which send the data from the client to the server. To know where to store the data, it grabs the index of the reference holder from the container and sends that over with the changed value. So, if you do not have the same number of reference holders on both sides, then you will either be missing data or having always empty data.
March 15, 20214 yr Author Hmm. I swear I do have the same reference holders on both sides, yet it isn't updating at all
March 15, 20214 yr Author I moved my containers constructors around and now trackIntArray is called on both ends, it is still not working. https://github.com/Beardlessbrady/Currency-Mod/blob/master-1.16/src/main/java/com/beardlessbrady/gocurrency/blocks/vending/VendingContainer.java#L95
March 15, 20214 yr Author Ok so it seems to sync if I set it on client or server in the CONTAINER but if I change it in the CONTAINER SCREEN it actually doesn't even seem to be going over to the client data in the container for some reason... For example: Using a button to change the value https://github.com/Beardlessbrady/Currency-Mod/blob/master-1.16/src/main/java/com/beardlessbrady/gocurrency/blocks/vending/VendingContainerScreen.java#L49 Edited March 15, 20214 yr by BeardlessBrady
March 16, 20214 yr Author Alright. It seems that even if I send a packet from client to server to update it, it does infact update the server side but it isn't then sending the data back to the client end. https://github.com/Beardlessbrady/Currency-Mod/blob/master-1.16/src/main/java/com/beardlessbrady/gocurrency/blocks/vending/VendingContainerScreen.java#L50 Although it is commented out, I have tried it not commented...with no luck
March 16, 20214 yr Author In terms of getting the tile from the openContainer I am not seeing any method or way to get a tile entity from openContainer. With my issue I initially was having the message just flip the value (if 0 set as 1, vice versa), then I was just messing around to see if I could get it working by only setting it to 1. Anyways I have it commented out here: https://github.com/Beardlessbrady/Currency-Mod/blob/master-1.16/src/main/java/com/beardlessbrady/gocurrency/network/MessageVendingStateData.java#L54 But just tried it uncommented, and commenting out the other parts with no luck
March 16, 20214 yr Author Yes you are correct. I suppose my issue is more pulling the data from inside the containerScreen. If I try to get the data in the containerScreen it just returns 0 as if it wasn't changed.
March 16, 20214 yr Author For example if I just output the data via init() in the clientScreen, click the button, close and reopen the GUI to run the init() method, it is still zero. Also in terms of what you said earlier about getting the tile on the client side. Yes I can add whatever method I want to the container but I don't see how running a get tile method on the client container (itself) would get the tile?
March 17, 20214 yr Author Thanks for the help, I really do appreciate it! Is there a way to detect in the containerScreen or container when one of the tracked data is changed on the client so it can trigger something in the containerScreen. If I try to do it with the mouseClick button in the containerScreen it seems like the mouseClick is called before the data is updated on the client side, so it uses the previous data value. In terms of putting the tile in the constructor I run into the 'new' way to register things in Forge not being happy: https://github.com/Beardlessbrady/Currency-Mod/blob/master-1.16/src/main/java/com/beardlessbrady/gocurrency/init/CommonRegistry.java#L49 How would I include the tile here? Edited March 17, 20214 yr by BeardlessBrady
March 17, 20214 yr Author Didn't you say not to send the pos through the constructor? That is how Im currently getting the tile?
March 17, 20214 yr Author On 3/16/2021 at 3:07 PM, diesieben07 said: Firstly, do not send the tile entity position and then blindly trust it on the server, this will allow cheaters to set the data for any tile entity. Simply get the player's openContainer on the server and get the tile entity from that. Instead send the windowId of the Container and compare it, to make sure the container has not been closed in between. Am I understanding this incorrectly?
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.