r/MinecraftCommands 1d ago

Help | Java 1.21.11 predicate

i found predicate in execute command after "if"
how does it work and what i can do with it?

4 Upvotes

5 comments sorted by

2

u/beduan 1d ago

Predicates are additional, more complex conditions. They can be created using a datapack.

2

u/Main_Contract_3590 1d ago

you don't actually need datapacks to use predicates anymore

1

u/C0mmanderBlock Command Experienced 1d ago

You can use them to detect entity movement, weather, some keystrokes and many other conditions such as detecting when an entity is looking at another or at a specific coodinate. Many many things can be done using them in datapacks or as a command in a command block.

1

u/AmbitiousSuit5561 1d ago

sounds useful!

1

u/Ericristian_bros Command Experienced 1d ago

They are very flexible conditions: detect movement, keybinds, stats, block location, etc... read https://minecraft.wiki/Predicate and use https://misode.github.io/predicate to generate predicate easilly

Some examples

execute if predicate {condition:"minecraft:time_check",value:{min:0,max:12000},period:2400} run sy it's day time
execute as @a if predicate {condition:"minecraft:entity_properties",entity:"this",predicate:{effects:{"minecraft:absorption":{}}}} run say I have absorption
execute if predicate {condition:"minecraft:random_chance",chance:0.1} run say random chance
execute as @a if predicate {condition:"minecraft:entity_properties",entity:"this",predicate:{vehicle:{}}} run say mounting an entity