1

So I am making a datapack for custom enchantments. I want to make it where every time I use /trigger , then the command will be executed once. However, at the same time the objective value used in /trigger will be kept the same without continuously executing the /execute command in my tick.mcfunction. Is there a solution to this problem?

2 Answers 2

2

Create two scoreboards. One for the trigger and one normal one. In every tick you check if the value of both scoreboards are the same and run your function only if they are not:

# tick.mcfunction
execute as @a unless score @s name = @s name_trigger run function foo

# foo.mcfunction
tellraw @a [{"text":"My score is "},{"score":{"name":"*","objective":"name"}}]
scoreboard players operation @s name = @s name_trigger
scoreboard players enable @s name_trigger
1
0

You can add a tag to the item, and execute only if the item does NOT have the tag:

execute as @a[nbt={Inventory:[{Slot:100b}]},nbt=!{Inventory:[{Slot:100b,tag:{realistic:1}}]}] run item modify entity @s armor.feet minecraft:replace_boots

This will execute at any player wearing boots that do not have the tag. Then in the item modifier, add any attributes or enchantments you like. Alternatively, you could just use /tag instead of item modify.

In this way, you should be able to execute this command every tick with little to no lag. Perfect for custom enchantments.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .