Custom Villager Trades [With procedures]

Started by K3vax on Fri, 09/20/2019 - 22:49

Topic category: Bugs and solutions

Last seen on 04:39, 30. Sep 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Custom Villager Trades [With procedures]
Fri, 09/20/2019 - 22:49

Hey, everyone!

 

So I am aware that we can't simply add custom trades with villagers or with created villagers. But I am making a mod with a special villager that opens up a GUI for trades.

 

Now in the GUI, the player can choose from a selection of buttons to make a trade. I've added a procedure where the GUI would then close, the 'currency' item is removed from the player's inventory and the 'product' item is then added in.

 

Now when I try this in-game, the button doesn't do anything.

Does anyone know how to make this work?

The custom procedure

Last seen on 15:19, 15. Oct 2019
Joined Jan 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
If you're using it for GUI…
Fri, 09/20/2019 - 22:56

If you're using it for GUI with slots, bind it with a block that has inventory, even if its a non unobtainable block, as long as its binded to a block you'll be fine, then you can make the entity open the gui, and it will work.

Last seen on 04:39, 30. Sep 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Can you show an example? I…
Sat, 09/21/2019 - 07:46

Can you show an example? I have no clue what you mean

Last seen on 23:57, 15. Oct 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
K3vax, DaleksOfSkar is right…
Sat, 09/21/2019 - 21:57

K3vax, DaleksOfSkar is right. Currently the way to do trading is through blocks that have inventory.

However, I found a way through which you can trade with a mob without the use of any blocks.

From: https://mcreator.net/forum/53182/very-strange-things-happen-when-working-gui-procedures?page=1

GUI:

Input slot (0) > Picture of diamond > Picture of  trade_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
Last seen on 04:39, 30. Sep 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Where did you get your AND…
Fri, 09/27/2019 - 22:22

Where did you get your AND piece?

Last seen on 00:39, 16. Oct 2019
Joined Aug 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Logic Operations -> First…
Wed, 10/09/2019 - 23:28

Logic Operations -> First procedure Block -> Click on "=" -. Choose "AND"