AjjMC/ajjgui

Question: Modifying item slot widget

Closed this issue · 3 comments

I try to create an automated UI that allows input and for example transform this input into something different after a certain time. To my knowledge, I need to change the NBT of the marker and perform a reload after doing so, but this results into invalid interactions and a broken UI.

Selector: @n[type=marker,tag=ajjgui.gui_origin]
Commands:

# Clearing top item slot 
data modify entity @s data.gui[0][{Slot:11}] merge value {id:"minecraft:structure_void",components:{"minecraft:custom_model_data":20,"minecraft:custom_data":{ajjgui:{state:0}}}}
data modify entity @s data.gui[0][{Slot:15}] merge value {id:"minecraft:structure_void",components:{"minecraft:custom_model_data":20,"minecraft:custom_data":{ajjgui:{state:0}}}}

# Set item in bottom item slot
$data modify entity @s data.gui[0][{Slot:22}] merge value {id:"minecraft:$(type)", components:{"minecraft:custom_data":{chapter3.lab:1b,NoDrop:1b,ajjgui:{state:1}},"minecraft:hide_tooltip":{}}}
function ajjgui:_reload

The function above is triggered as soon as the process is ready and the yellow glass disappears.
Mockup UI, black squares are inputs
grafik
Interaction Video: https://github.com/user-attachments/assets/21c4a658-6bfc-4815-ba85-d8671a33a95c

AjjMC commented

The problem is that you are using an Int data type for Slot (e.g., Slot:11) instead of a Byte (e.g., Slot:11b) as the marker does not correct data types automatically. Once you change that and recompile the GUI, it should work.

Thank you a lot! What a silly overside from me...

Btw, in the modify value section, the examples still have the capitalized GUI path instead of the now used lowercase gui path

AjjMC commented

I fixed it. Thank you!