Started by
Kaanatorium
on
Topic category: Help with Minecraft modding (Java Edition)
Hey everyone,
I’m working on my mod in MCreator 2025.2 (NeoForge 1.21.1).
Right now, I’m trying to check if the item inside a specific slot (for example slot 1 of a custom GUI) is a specific potion, like a Potion of Healing.
Here’s what I tried so far in a procedure:
Question:
👉 What’s the correct way in MCreator to check if an item in a slot is a specific potion (e.g. minecraft:healing)?
Do I need to use tags, NBT, or some built-in function?
Thanks in advance for any help! 🙏
this block is probably what you're looking for,
This doesn't exactly work, even if it's another potion, it works when I use it like this. For example, it also works on poison potions even though I selected swiftness.
Oh yeah I see, try this, i hope it works in 1.21.1 i only have 1.21.4 right now.
potion.getComponents().get(DataComponents.POTION_CONTENTS).is(Potions.AWKWARD)change the
AWKWARDpart to the potion you want it can be,When I tried it without the red block, I got the following error. If the red block isn’t just for display, I have a question — how can I select the “Local:potion” option? It appears empty when I click on it.
Task :compileJava FAILEDC:\...\procedures\AddPotionTimeProcedure.java:10: error: cannot find symbol if (potion.getComponents().get(DataComponents.POTION_CONTENTS).is(Potions.AWKWARD)) {^symbol: variable potionlocation: class AddPotionTimeProcedure1 errorFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':compileJava'.> Compilation failed; see the compiler output below.C:\...\procedures\AddPotionTimeProcedure.java:10: error: cannot find symbol if (potion.getComponents().get(DataComponents.POTION_CONTENTS).is(Potions.AWKWARD)) {^symbol: variable potionlocation: class AddPotionTimeProcedure1 error* Try:> Check your code and dependencies to fix the compilation error(s)> Run with --scan to get full insights.BUILD FAILED in 636ms6 actionable tasks: 1 executed, 5 up-to-dateConfiguration cache entry reused.BUILD FAILEDit's a local variable you make them here, in this case it has to be an itemstack called potion.
after making the variable you have to grab a new variable block from the Custom variables tab
This method didn’t work either, I think I’ll try a different approach, but thank you anyway.
this worked for me can you show me your procedure?
did you change the custom code snippet?
No, i don't.
and you don't get any errors when you use it?
No, when I use it, the game closes and gives an error.
and the error is..?