Jump to content

[SOLVED] Dedicated Server Gui Refresh Issue [1.15.2-31.2.0]


Ipsissimus418

Recommended Posts

(I initially asked for help of Discord where Gigaherz referenced his transferStackInSlot method which I've tried, however I'm still having issue, so I'm posting here with more context)

 

I have a few machines with inventory slots and have implemented the whole transferStackInSlot with both my own and then Gigaherz version.

With an internal server moving items manually from the inventory to the input slot of the machine or via transferStackInSlot works fine. GUI updates immediately and there are no visual issues.

 

I've retested with a dedicated server and client and now things dont work so well.

 

There are a few issues

* delay between moving the item and the gui refreshing

* original itemstack remains attached to the cursor or with shift-click visually moves to another slot in the inventory

 

eg. manual version

Drag an item stack of 10 items into the machine slot

Machine starts processing

A few seconds later the destination slot renders the stack (handleSetSlot breakpoint not hit for about 4 seconds on the client)

Stack is still visually in the dragged state and I can place it in the inventory

Double clicking this fake stack makes it vanish.

 

eg. Shift-click version

Shift click item from toolbar to machine

Machine starts processing, destination slot is empty

A few seconds later the destination slot renders the stack (handleSetSlot breakpoint not hit for about 4 seconds on the client)

Stack visually moves to the player inventory

Double clicking this fake stack makes it vanish.

 

The 4 second delay to the handleSetSlot seems to line up with the time for the machine to process one item and therefore decrement the input stack size.

 

I would almost say that the slot numbering on the dedicated server and client are different.

There are no issues with a standalone client and internal server.

 

Container code https://github.com/Ipsis/Woot/blob/1.15.x/src/main/java/ipsis/woot/modules/squeezer/blocks/DyeSqueezerContainer.java

TileEntity code https://github.com/Ipsis/Woot/blob/1.15.x/src/main/java/ipsis/woot/modules/squeezer/blocks/DyeSqueezerTileEntity.java

 

I know I've overlooked something but I completely stumped as to what.

I had other issues related to dedicated server which I've fixed  when  registering of the containers.

So any pointers as to what might be going on here.

 

Thanks

Ipsis

Edited by Ipsissimus418
Add handleSetSlot comments
Link to comment
Share on other sites

Been doing some more debugging - including a completely fresh Intellj checkout.

 

Items being inserted via a hopper while the gui is open work correctly - probably because they modify the destination stack size.

You can correctly remove (manually or shift-click) an item from the machine inventory.

The issue is limited to items going into the single slot of the machine either via mouse drag or via shift-click on the item.

 

I've rewritten the container slot handling and the tlle entity inventory using other people's code as an example but nothing seems to fix it.

 

It looks very much like when the item is dragged into the machine slot via the gui, then the slot update packet is not being sent to the client. The update only happens when something else causes the machine inventory stack to change eg. item processed, that the client is refreshed. And even when that happens only the destination slot is refreshed, not the source slot or the dragged stack.

(And by that I mean that I've broken it in some way).

 

Link to comment
Share on other sites

After a good day of debugging I have my answer.

Server was working perfectly.

It was the client that was failing.

When the client was processing the Container.slotClick it does the following

slot6.getItemStackLimit

    SlotItemHandler.getItemStackLimit

        Get a full stack and try to insert it into the IItemHandler

            calls isValidItemForSlot which on the client was returning false.

 

My isItemValidForSlot looks up the recipes loaded on startup to see if the item is a valid input. When running with an internal server, this input item list was being created by my code by the server part. However on a standalone client, it was always empty as the server code isn't there to fill it.

Therefore the client updated the gui with a an empty itemstack as the item wasn't valid.

 

My transferStackInSlot also used this input item validation code, which is why it didn't work.

 

By removing this input slot validation just now, then it all works. So back to adding some code to make the validation work on both sides.

 

I hadn't appreciated that the item validation was being performed by client code, but that seems to be because the client is refreshing the stacks to show the user in the gui. The server only corrects those stack if the client shows something that is out of sync with its knowledge.

 

Well that is my understanding of what is going on, so I go and fix my code and be more appreciative of the differences between the client and server operation.

    

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.

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.