When item put in slot event trigger

Status
Migrated
Issue description

In GUI, slots event can be

- When Slot content change

- When Item taken from slot

- When item transfered to slot (shift click)

 

What i would like is when We put item in slot

Issue comments

When the item change or when item is put in it, Thats different

The 1st one can be either replacing the item inside or when you put and remove it, it will trigger in any case, but we are talking about ONLY putting item

fyi, "when slot content changed" will get triggered when a user puts items into an input slot, but the called procedure will not see the newly added itemstack because the contents have not been updated to the client side.

idk about 1.15.x or higher, but in 1.12.2, when you generate code for a gui with input slots, adding a detectAndSendChanges() line into onSlotChanged() will fix that.

HI. I think this is the right ticket to use. I am new to MC, so I apologize if this is still covered somewhere else. But I think I know what the deal was/is here. I have made a GUI with a slot (nearly for the same idea above) and have it called from a mob. I am using 2020.4. The problem is, the trigger events (likely logically??) cross call each other. I wrote a simple procedure to output to player chat which procedure trigger was called:

For simplicity I will refer to "When slot contents change" as (1); "When item taken from slot" as (2); and "When transferred from slot (shift-click)" as (3).

Here are my observations:

a) when I right-click on my mob, the "When slot contents change" (1) is automatically called ONCE, whether or not if I have a block (item) in the slot. -Why? the slot contents (as far as I would have understood it) did not change since I only opened the GUI. (they are likely dynamically re-populated, but dont have any java skills). This is not the expected behaviour, is it(?), I expect it not to be called, since I only opened the GUI and did not manually change the slot contents.

b) left or right clicking on the slot (when GUI is open of course) calls (1). This occurs only ONCE per click. (seems fine, makes sense)

c) adding a block to the slot calls (1) TWICE! i.e. (1)(1)

d) removing a block from the slot calls (1)(2)(1)

e) shift+left or right click calls (3)(1)(1)(2)

I made a summary with screenshot images of my GUI code and the output, but I dont know where I should upload them to. If that would be helpful, I would gladly do it, since I am really stuck as I am referencing ENBT variables and want only one procedure to be called (triggered) per trigger type. Even if we say that (1) occurs when you add or remove something, it should not be being called twice.

Any ideas anyone?

 

For this part, Java modding support:

I made a summary with screenshot images of my GUI code and the output, but I dont know where I should upload them to. If that would be helpful, I would gladly do it, since I am really stuck as I am referencing ENBT variables and want only one procedure to be called (triggered) per trigger type. Even if we say that (1) occurs when you add or remove something, it should not be being called twice.

Not many check tracker for new comments so asking this on forums would be better