Detecting when an item is placed in a GUI slot

Started by Xbraxusx on Wed, 08/19/2020 - 00:29

Topic category: Help with MCreator software

Last seen on 15:25, 16. Sep 2021
Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Detecting when an item is placed in a GUI slot
Wed, 08/19/2020 - 00:29

I'm currently working on a trade system similar to villagers using an entity and I want it work like so:

You put an item in the input slot. It detects that it's there and gives you an item in output slot. If you take the output you lose the input.

I'm having trouble correctly detecting when an item is inputed into a slot in a GUI. I used the "When slot contents change" procedure call but that detects the slot before the change and not after, so when I say if item is in slot, it ends up false and when I remove the item, it turns true and functions as normal. I tried saying if not item is in slot, but that made the procedure go off as soon as the inventory was opened.

Using a button won't work for what I want to do because I need the item to be visible to you when you input your currency item.

Last seen on 20:39, 25. Jul 2021
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Does the villager have an…
Fri, 08/21/2020 - 01:29

Does the villager have an inventory for the trades?

If so, you can test:

"on entity tick"

if entity subtype YourVillager:

     If item in slot 0 of entity is ()

           Set item () in slot (whatever) of entity