mojira.dev
MC-299629

block_state_property predicate not working

Trying to use this command (while within a wheat block) to detect whether a wheat block is at age 7:

/execute if predicate {condition:"minecraft:block_state_property",block:"minecraft:wheat",properties:{age:"7"}} run tellraw @a "hi"

and it doesn’t work. Nothing is printed in the chat.

If I try this command instead, it does work:

/execute if block ~ ~ ~ wheat[age="7"] run tellraw @a "hi"

A location_check predicate also works:

/execute if predicate {condition:"minecraft:location_check",predicate:{block:{blocks:"wheat",state:{age:"7"}}}} run tellraw @a "hi"

So the problem seems to be with the block_state_property predicate. I attached a video showing me using these commands.

Environment

Minecraft Java Edition 1.21.7

Attachments

Comments 1

The block_state_property condition requires the loot context parameter "block state" in order to succeed. This can be provided by:

  • A loot table of type block or block_interact

  • An advancement with trigger allay_drop_item_on_block, any_block_use, default_block_use, item_used_on_block or placed_block

  • An enchantment with component hit_block

The only loot context parameters provided by /execute if predicate are "origin" and "this entity".

daenvil

(Unassigned)

Unconfirmed

(Unassigned)

1.21.7

Retrieved