GUI where you can only place certain items or tags

Started by RexCerv on

Topic category: Help with modding (Java Edition)

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
GUI where you can only place certain items or tags

PLEASE ONLY ANSWER IF YOU KNOW THE ANSWER BECAUSE IT IS MORE LIKELY THAT YOU WILL SEE THIS IF THERE ARE NO USELESS ANSWERS

So I wanted to make a GUI and for testing, I made only 1 slot, in this slot I wanted to know if it's possible to specify only to accept certain items, so I first added a random block in the specification and then going to the code and deleting it, then I tried adding the stuff I want to specify where the random block was (and yes I did Import all of the items and delete completely the other block). And because it didn't work, I was wondering if there's a way to do it with procedures or just coding, maybe I did it wrong. By the way, I'm in 2021.1, Minecraft Version 1.16. 

(If anyone didn't understand what I meant, here's an example: Imagine I want to only be able to put Gold, Diamond, Iron, Coal, etc on 1 slot, but I can't put other items like dirt or other things. And yes MCreator does let me specify items per slot, but it only lets me specify 1 item, when I want to specify at least 10.)

Last seen on 06:22, 13. Mar 2023
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Idk exactly how, but you…
Tue, 05/10/2022 - 01:39

Idk exactly how, but you should replace the "Blocks.Coal_Ore.asItem" with getting the item tag you want to use there. I need to figure this out for myself as well. It looks like it should be "Tags.Item.?" Idk what to put in the "?" yet. I will try to figure it out.

Last seen on 13:03, 29. Oct 2022
Joined Jul 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Did You find  Out How To Do…
Wed, 08/03/2022 - 19:47

Did You find  Out How To Do This ?

Last seen on 21:54, 13. Feb 2024
Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I REALLY need this, have you…
Wed, 01/04/2023 - 03:59

I REALLY need this, have you found it out yet?

 

Last seen on 15:10, 24. Dec 2023
Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm using MCreator 2022.3…
Fri, 02/10/2023 - 19:41

I'm using MCreator 2022.3 for 1.19.2

In the workspace right click your GUI and select "lock/unlock mod element", then double click and open the GUIMenu.java, search for the custom slots, it should look like this (I'll use the minecraft arrow for example):

this.customSlots.put(0, this.addSlot(new SlotItemHandler(internal, 0, 44, 31) {
@Override
public boolean mayPlace(ItemStack stack) {
return (Items.ARROW == stack.getItem());
}
}));

Now what you need to do is add the items you want:

this.customSlots.put(0, this.addSlot(new SlotItemHandler(internal, 0, 44, 31) {
    @Override
    public boolean mayPlace(ItemStack stack) {
       return (Items.ARROW == stack.getItem() || ProjectLkModItems.SARTORIUM_ARROW.get() == stack.getItem() || Items.SPECTRAL_ARROW == stack.getItem() || Items.TIPPED_ARROW == stack.getItem());
    }
}));

You just need to add || between them, to get the vanilla items hold left control + left click on Items in "return (Items.ARROW" MCreator should open the items list, after all that press control + W so the code can fix and get the right imports, now just save the code and be happy.