Jump to content

Recommended Posts

Posted (edited)

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 by BeardlessBrady
Posted

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.

Posted (edited)

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 by BeardlessBrady
Posted

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

Posted

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

Posted

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?

Posted (edited)

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 by BeardlessBrady
Posted
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.

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.