Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setStack() and removeStack() doesnt really work... #253

Open
Jasper6671 opened this issue Nov 15, 2024 · 1 comment
Open

setStack() and removeStack() doesnt really work... #253

Jasper6671 opened this issue Nov 15, 2024 · 1 comment
Labels
question Further information is requested

Comments

@Jasper6671
Copy link

I have made a GUI with LibGui which has 2 Item Slots(1 Input, 2 Output). It halso has a button and when i click it it should remove the input item and add a Item to the Output Slot but its doesnt really do it. It shows that the Input Item is not in the slot anymore and it also shows The Output Item correctly until i click somewhere in the inventory . Then it resets the inventory so that the output item disappears and the input item again in the input slot.

Hope someone can help me with that :)
Code(GuiDesc): https://pastebin.com/Z1ZQKQZK
Video:

Uploading 2024-11-14 21-38-45.mp4…

@Jasper6671 Jasper6671 added the bug Something isn't working label Nov 15, 2024
@Juuxel
Copy link
Member

Juuxel commented Nov 19, 2024

You can't really modify inventory contents from the logical client (this includes setStack), as the logical server fully controls and manages inventories.

Instead, you need to send a packet or a LibGui screen message from the client (button.setOnClick(() -> { /* from here */ })) to the server telling it that the button has been pressed. The server can then modify the block inventory.

Also: avoid doing file IO like deleteIfExists directly on the render thread in button click listeners etc, it can freeze the screen which is frustrating for players.

@Juuxel Juuxel added question Further information is requested and removed bug Something isn't working labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants