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

Exiting GUI via button replaces block above container #2

Open
aestellic opened this issue Jun 28, 2024 · 0 comments
Open

Exiting GUI via button replaces block above container #2

aestellic opened this issue Jun 28, 2024 · 0 comments

Comments

@aestellic
Copy link

When exiting a GUI using a button with ajjgui.exit set to 1b, the block above the container is set to air, regardless of what block was there previously.

Looking at ajjgui/function/utils/exit_gui, the following is run at the active GUI marker when the exit button is clicked:

clone ~ ~ ~ ~ ~ ~ ~ ~1 ~
setblock ~ ~ ~ minecraft:air
clone ~ ~1 ~ ~ ~1 ~ ~ ~ ~
setblock ~ ~1 ~ minecraft:air
execute on vehicle if entity @s[type=minecraft:chest_boat,tag=ajjgui.gui_ported] run function ajjgui:control/close_gui_ported

One potential solution would be to store the block at some arbitrary location (X, Y, Z) via clone, then cloning it back once the GUI has been closed, as follows:

clone ~ ~1 ~ ~ ~1 ~ X Y Z
clone ~ ~ ~ ~ ~ ~ ~ ~1 ~
setblock ~ ~ ~ minecraft:air
clone ~ ~1 ~ ~ ~1 ~ ~ ~ ~
clone X Y Z X Y Z ~ ~1 ~
execute on vehicle if entity @s[type=minecraft:chest_boat,tag=ajjgui.gui_ported] run function ajjgui:control/close_gui_ported

However, this has the obvious disadvantage of requiring an absolute location which is always loaded in order to function. While this condition could be met via the shulker box generated by the install function, if two GUIs were closed during the same tick, a race condition would likely occur. Alternatively, the id and NBT of the block could be copied to a temporary storage and then restored after ajjgui/function/utils/exit_gui runs. Unfortunately, this solution would not work for non-block entities, as their id is not accesible via NBT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant