mojira.dev
MC-124383

Can't get the state of a lever

In 1.12 and before, I could get the sate of a lever with testforblock, but in 1.13, it seems like minecraft thinks that levers are not block entities and/or don't have states.
Specifically:
/data get block <x> <y> <z> lever.powered
reports "The target block is not a block entity", and
/execute if block <x> <y> <z> lever{powered:1b}
always returns false

Do I have something wrong with my commands?

Comments 1

/data is only used for block entities such as chests, furnaces, command blocks, etc. Block entities and block states are two completely different things. Levers are not block entities.

To test for a block state, you can define them in brackets connected to the block argument.

/execute if block <x> <y> <z> minecraft:lever[powered=true] ...

To test for a tag in a block entity, you can define them in curly brackets connected to the block argument.

/execute if block <x> <y> <z> minecraft:furnace{BurnTime:100} ...

steveswales

(Unassigned)

Unconfirmed

Minecraft 18w03b

Retrieved