#1.20.1 storage item id list

1 messages · Page 1 of 1 (latest)

oblique folio
#

i have a problem
execute as @a[nbt={Inventory:[{id:"minecraft:netherite_sword"}]}]
i want to replace bold part to checking object in storage, i hear we can go through the list but how idk (in storage i have many IDs, and i dont want do commands for each item)

wraith kernelBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

mellow mirage
#

@oblique folio does the list of item ids to check for change?

oblique folio
#

do you mean will i change it?

mellow mirage
#

if it doesn't, don't do macros, don't use storage. Use a predicate and just hardcode each item, way better for performance.

There are no easy ways to loop through a list and combining that loop with a macro is going to tank performance.

mellow mirage
#

a predicate is a json file. It is used to describe a check that returns true or false and can be a list of conditions or other predicates.

#

even with the list of item ids in storage, since you want to check on a single item (I think?) you would first have to write some function that loops through the list.

Then call another function which looks like:
$execute as @a[nbt={Inventory:[{id:$(id)}]}]
This can be called like:
function ns:check_for_item with {id:"minecraft:stone"}
or
function ns:check_for_item with storage ns:something your_path

oblique folio
#

$? im on 1 20 1

mellow mirage
#

Instead of doing this, consider creating a predicate that checks for the list of items you want to check for. If this list is not fixed... I don't think there are any easy ways to do so

#

ah you are trying to do something you cant do in that case

#

so your way to go is predicates

#

unless this list in storage can be changed by your datapack somehow.

oblique folio
#

and where i can write ids

mellow mirage
#

but in all honesty, if you are not more precise with the actual goal of this... you can't get a better answer.

oblique folio
#

thx

mellow mirage
#

example start file:

{
    "condition": "minecraft:any_of",
    "terms": [
        {
            "condition": "minecraft:entity_properties",
            "entity": "this",
            "predicate": {
                "type": "minecraft:player",
                "nbt": "{Inventory:[{id:\"minecraft:netherite_sword\"}]}"
            }
        }
    ]
}
#

You can add the other items to the terms list. As it say on the top this predicate would check if any of the terms is true.

#

The type can be ommitted if you want to specifically check for other entities with an inventory

#

The answer to your original question is that you can't in 1.20.1 as far as I can tell.

oblique folio
#

execute as @a[nbt={Inventory:[{id:"minecraft:netherite_sword"}]}] at @s run clear @s netherite_sword 64

mellow mirage
#

One thing you could do is enable/disable it for items in the term list, each term can be an all_of where one is the inventory check and one is a score check.

as for removing only a specific type of item, in 1.20.1 that needs hardcoding.

mellow mirage
#

if enabling/disabling isn't required you could instead make an item tag in your datapack for all items to filter. This also allows a single clear command like:

clear @s #ns:tag_name

#

Example: /clear @s #minecraft:doors removes all doors from your inventory. whether this is an oak, acacia, iron or spruce door. Trapdoors are not in this tag however.

oblique folio
mellow mirage
#

that is why I am asking, be more precise. The use of storage right now would be very hard (especially with player inventories)

oblique folio
#

i detect item, i spawn stone, copy nbt (and id of item) to stone, clear item in inventory

mellow mirage
#

if you are looking to change the content of a chest however

oblique folio
#

and because that i dont want delete items

#

they can be need for other players with other rpg class (nbt)

#

i made this system but with SelectedItem for weapons

#

but artifacts may be used without main hand

#

sorry for my bad english

mellow mirage
#

So you want a class to be unable to use certain items?

#

or "disable" items that don't belong to that class.

oblique folio
#

this is 2 same questions?

#

i have a few classes

#

delete all items for other classes i dont need

#

only drop

#

how to unable use artifacts what can be dressed on the accessory slots i dont have ideas

mellow mirage
#

you mean armor?

oblique folio
#

no

#

modded slots

#

not that is general

#

players cant dress up items without their been in inventory (or hotbar)

#

i need leave for a two hours

#

sorry

mellow mirage
#

I don't think I can help much with this, I feel like you are better off trying to change or configure the mod itself rather than using a datapack to customize it.

#

I still don't get what you actually are trying to modify, but that won't change soon because I do not know the mod.

wraith kernelBOT
# wraith kernel <@&1201956957406109788>

<@&1166082198152159386> <@&1202694677766348840>

🙇 Helpers Arise!

Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)

oblique folio
#

brief information:
i want to make an RPG server but i don't want players of a certain class to use a certain list of items of other classes. i can't delete them because it's a server. i already made a system for weapons (via selected item) but there might be a problem with accessories and armor because they can be used or worn without the main hand.

Below I will indicate my test system for SelectedItem and highlight in bold what I need to change so as not to write 4 commands for each item.
execute as @a[nbt={SelectedItem:{id:"minecraft:command_block"}}] at @s run summon item ~ ~ ~ {Item:{id:"minecraft:stone",Count:1b},Tags:["dropped"],PickupDelay:30}
execute as @a[nbt={SelectedItem:{id:"minecraft:command_block"}}] run data modify entity @e[type=item,tag=dropped,limit=1] Item set from entity @s SelectedItem
execute as @a[nbt={SelectedItem:{id:"minecraft:command_block"}}] at @s run tag @e[type=item,sort=nearest,limit=1] remove dropped
execute as @a[nbt={SelectedItem:{id:"minecraft:command_block"}}] at @s run clear @s minecraft:command_block 64

orchid blaze
#

Well highlighting doesn't work in code blocks, as you can see

oblique folio
#

oh sorry

orchid blaze
#

But don't use NBT checks for this, use predicates. That will allow you to check multiple/all slots for the items

#

Just code block and don't worry about the bold

#

Also, loosely related, you can optimize this code a fair bit. Instead of executing as all players every line, you can just do one line that is execute as @a at @s run <new function>, and have the new function run all these commands but just with execute if entity @s[...]

#

Or, when you change to predicates, execute if predicate ...

orchid blaze
#

Predicates are separate JSON files that you can define conditions in, then when you check them with execute if predicate, they will be either true or false.

#

You can make one with Misode, and put it in data/<namespace>/predicates

ocean islandBOT
#
Tool: Misode
About

Misode's Datapack Generators are useful when creating files such as loot tables, predicates, advancement, worldgen files, and more!

oblique folio
orchid blaze
#

You would make the predicate check multiple items or slots

#

Using an any_of predicate type

oblique folio
#

Now I can detect but how can I clear that item what I detect? Player can pickup few items monentally

orchid blaze
#

Do separate predicate checks for each item, then

#

Rather than all in one

oblique folio
#

OK, thx