Very strange things happen when working with GUI procedures.

Started by StellaeLux on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Very strange things happen when working with GUI procedures.

The GUI is simple:

One input slot (0), One button, One output slot (1).

When a player places in an item (say diamonds) inside of the input slot and press the button, the same amount of another item (say dirt?) appears in the output slot and the input slots gets cleared.

The button has the following procedure attached:

------------------------------------------------------------------------

if Get number of items from slot 0 of inventory [nameOfInventory] >= 1 AND Get item from slot 0 of inventory [nameOfInvetory] = [Diamond] 
//If there's 1 or more diamonds in slot 0

do Set Get number of items from slot 0 of inventory [nameOfInventory] [Dirt] in slot 1 of inventory [nameOfInventory] 
//Place that amount of dirt in slot 1

do Remove Get number of items from slot 0 of inventory [nameOfInventory] items from slot 0 of inventory [nameOfInventory] 
//Remove that amount of diamonds from slot 0

------------------------------------------------------------------------

What I was expecting is that upon pressing the button, slot 0 would become empty. Slot 1 would have Dirt and you'd simply drag that dirt into your inventory.

But this is what happened:

1. When pressing the button, the Dirt appears, but when you press it, it disappears and the Diamonds are back in slot 0...

2. When pressing the button, the Dirt appears. When Shift Clicking the Dirt, you make it jump into your inventory. Upon closing your inventory, your Dirt will disappear, leaving you with neither diamonds nor dirt.

3. When pressing the button, the Dirt appears. When Shift Clicking the Dirt, you make it jump into your inventory. If you now press the dirt, it will disappear and your diamonds (that were previously gone) will now be back inside of input slot 0.

4. When leaving your diamonds inside of input slot 0 and closing the GUI (with e), the diamonds will be dropped automatically, but cannot be picked up (not even by a hopper).

Are these behaviours bugs? 

Last seen on 15:27, 10. Oct 2022
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
can i have a screenshot of…
Fri, 09/20/2019 - 14:11

can i have a screenshot of the procedure and the gui? If so i could help resolve this issue hopefully.

Last seen on 15:27, 10. Oct 2022
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
crap, can you upload those…
Fri, 09/20/2019 - 14:29

crap, can you upload those images to https://pasteboard.co ? im currently at school so stuff commit dies on most sites.

Last seen on 15:27, 10. Oct 2022
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I would make it so its "If"…
Fri, 09/20/2019 - 14:39

I would make it so its "If" item in slot 0 is diamond AND "get number of items from slot 0" is > or = 1 AND item in slot 3 is air OR item in slot 3 is Dirt
"Do" Set items in slot 3 to "Get number of items in slot 3" +1

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Still the same issue. It may…
Fri, 09/20/2019 - 14:59

Still the same issue. It may be related to the Mac version? (1.9.0)

 

I discovered that when you:

1. Press the + button --> Shift click the Dirt into your inventory --> reopening GUI will make the dirt disappear out of Your inventory... but..

2. Press the + button --> Shift click the Dirt into your inventory --> Switching a random item around in your inventory --> reopening GUI will no longer make the dirt disappear. (Dragging from the 3rd slot still doesn't work).

Even if you do step 1 for a second time, the dirt you did in step 2 will stay in your inventory and only the dirt that has been there without any switching around will disappear when reopening the GUI.

Very strange.

 

 

Last seen on 15:27, 10. Oct 2022
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Maybe, this is an issue…
Fri, 09/20/2019 - 15:03

Maybe, this is an issue outside of what i can do... Maybe remove the need for the + button by using the "Update Tick" event on the block the inventory is attached to? This may fix the issue

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
A video for visualisation:…
Fri, 09/20/2019 - 15:28

A video for visualisation:

https://youtu.be/sYmPup2EGTQ

 

---

I originally did it without the + button and did it on input slot call, which is where the issue started. I fear the worst for Update Tick. It would also be less efficient code to have the state of slot 1 checked so many times.

 

Last seen on 15:27, 10. Oct 2022
Joined Jan 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I get home in about 5 hours,…
Fri, 09/20/2019 - 15:33

I get home in about 5 hours, once i do i can make you a procedure, if you'd like i can make a model and texture for your trader as well

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The texture of the model is…
Fri, 09/20/2019 - 15:50

The texture of the model is a test placeholder I slammed on for testing.

I am planning on creating a specific texture related to this mod & dimension for this mob later once the environment is finished.

I hope the procedures work for you, because I am bazzled at why the things happen the way they do in the video xD

When working with GUIs and…
Fri, 09/20/2019 - 16:44

When working with GUIs and slots, you need to bind GUI to a block and use inherited inventory for slots. You need to use procedures to manage slots of block inventory instead of GUI inventory too. This is currently the way to use GUIs.

I suggest you to check our wiki page on how to make GUIs with slots: https://mcreator.net/wiki/making-guis-slots If your GUI does not work after watching the tutorial, you might want to check our example workspace and build from there: https://mcreator.net/modification/42649/fusion-table-procedure-demo

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for the reply! I'll…
Fri, 09/20/2019 - 17:18

Thanks for the reply! I'll try the block approach.

Last seen on 20:25, 8. May 2020
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Despite all Odds, I've…
Fri, 09/20/2019 - 21:52

Despite all Odds, I've managed to come up with a Trader version that actually works without any blocks, works on a mob without inherited inventory. 

 

Inside this video, you'll see all the bugs of my initial approach:

https://www.youtube.com/watch?v=sYmPup2EGTQ&feature=youtu.be

Bug1: Dragging an item from output slot doesn't work. (Shift click does)

Bug2: After having shift-clicked the item from the output slot, reopening the GUI causes it to disappear.

Bug3: Clicking on the input slot after having removed the item from it through trading will cause it to magically reappear. (duplication)

Bug4: Adding an item directly to the player's inventory will have the give behaviour as bug 2 or occasionally makes your procedure unable to run.

Bug5: If you leave items inside of your input slot, checking the "drop automatically" option when creating the inventory will make the items drop, but they cannot be picked up.

---------------------------------------------------------------

So in order to make the mob trader work, a lot of bullets had to be dodged:

GUI:

Input slot (0) > Picture of diamond > arrow > Picture of sand > button

PROCEDURE:

Set NumOfItems to Get numbers of items from slot 0 of inventory [TraderInventory]

if Get item from slot 0 of inventory [TraderInventory] = [diamond] AND Get NumOfItems >= 1

do repeat NumOfItems times:

      spawn gem [sand] at x y z

do Clear slot 0 of inventory [TraderInventory]

do Close any UI open for the current entity

Dropping it as a Gem divorces it from being able to disappear back into the item from the input slot.

Closing the inventory after the trade makes you unable to click the input slot again which would have given you all your trade items back.

Setting your inventory option to "Don't drop", will prevent unobtainable items from being in your world. It still does mean however that if you put things in the inventory slot and decide to cancel your trade, you'll still lose your items, but a greedy trader can be an excuse for that.

---------------------------------------------------------------

This introduces 2 problems/questions. The first one comes with "Spawn gem". Spawn gem doesn't let you insert an amount. Through the repeat loop, you can repeat the spawning of the gem, however this will cause them to spawn with individual physics. Minecraft condenses items on the ground in groups from 2-5 with 64 being 5. When you spawn 64 gems in an instance, sometimes they pop out in a group of 5 visible items containing all 64, but when you're not as lucky they will appear individually before they pop into a group of 5. This has caused my Minecraft to crash once. This can of course be avoided by not allowing people to trade 64 at once, but it would be very useful if Spawn Gem could manage the spawning of gems as it can pre-emptively know in how big of a group from 2-5 it should spawn.

 

It could also be possible to simply place the 64 items directly into the player's OWN inventory (not the GUI). But doing this through the button function somehow reproduces the effect of Bug2 mentioned above (stunningly enough!)

If another function called from the button function could add the items to the player's inventory, then the items given could possibly lose association with the items from the Input Slot, allowing the dodging of the Spawn Gem all together.

I asked about that approach in: https://mcreator.net/forum/53191/passing-dependencies-another-procedure

But as things stand, it is possible with some work-arounds (: