#(kiomy_) Check if inventory contains a list of items

27 messages · Page 1 of 1 (latest)

versed hornet
#

I was reading previous discussions in this chat about how to find items in an inventory. Seems like using this is the answer;```yaml
<context.inventory.quantity_item[(<matcher>)]>

But in my case, i need to find a list of items. Kinda like a cooking recipe. Some of which items are custom. I usually find those custom items with:```yaml
 <context.item.contains[oraxen:id=string:ORAXEN_ITEM_ID]>

Not sure how to make an if statement that returns true if all the items of the recipe are present.
Any idea? Thank you ❤️

gilded skiffBOT
#

(kiomy_) Check if inventory contains a list of items

gilded skiffBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

desert wigeon
#

!t contains

mental vaporBOT
# desert wigeon !t contains
Cannot Specify Searched Tag

Multiple possible tags: <AreaObject.contains[<location>]>, <ListTag.contains[<element>|...]>, <MapTag.contains[<key>|...]>, <yaml[<id>].contains[<path>]>, <ListTag.contains_any[<element>|...]>, <InventoryTag.contains_item[<matcher>]>, <InventoryTag.contains.lore[(strict:)<element>|...]>, <ElementTag.contains_text[<element>]>, <ListTag.contains_match[<matcher>]>, <CuboidTag.contains_cuboid[<cuboid>]>, <ListTag.contains_single[<element>]>, <InventoryTag.contains.display[(strict:)<element>]>, <ElementTag.contains_any_text[<element>|...]>, <ElementTag.contains_all_text[<element>|...]>, <PolygonTag.contains_inclusive[<location>]>, <InventoryTag.contains_item[<matcher>].quantity[<#>]>, <InventoryTag.contains.lore[(strict:)<element>|...].quantity[<#>]>, <ListTag.contains_case_sensitive[<element>]>, <InventoryTag.contains.display[(strict:)<element>].quantity[<#>]>, <ListTag.contains_any_case_sensitive[<element>|...]>, ...

desert wigeon
#

^ ItemTag.contains isn't a thing, it's getting the raw object ItemTag text and checking if it contains that

#

!t ItemTag.raw_nbt

mental vaporBOT
desert wigeon
#

Should properly get the raw NBT map and check that

#

Either way, depends on what kind of system do you want - at it's simplest you can literlly just - if <[inv].contains_item[stone]> && <[inv].contains_item[dirt]> && <[inv].contains_item[glass]>

versed hornet
#

Well, it would be best to have multiple recipes, this is why i want to iterate through. To also be able to create lists. Also some of the items can be only recognized by their nbt tags because are custom items.

So if i don't badly understand i can still read the raw_nbt and that should return... a string?

#

can i do .contain with the raw_nbt to see the content of a container?

#

So, InventoryTag.raw_nbt.contains[oraxen:id=string:ORAXEN_ITEM_ID]

#

if there was a map function returning an array after the foreach would be easier task ig

#

i could just return yes or no for each item

#

and if all yes then proceed

desert wigeon
desert wigeon
#

You can see MapTag.get to get the value of a key, which you can then compare - <[item].raw_nbt.get[oraxen:id]> == string:ORAXEN_ITEM_ID

#

And if the item may not have that you can use a fallback, <[item].raw_nbt.get[oraxen:id].if_null[]> to make it return an empty element if it can't find an oraxen id

versed hornet
#

Oh i see. Well, seems like useful information. I'll try to solve my issue based on this

#

maybe i'll keep the ticket open in case I keep having issues with the same topic

#

thanks for your answer @desert wigeon

desert wigeon
#

No worries! even if you do close it it'll still say here, so you can always reopen it if you want to