Minecraft – How to test for block change

minecraft-commandsminecraft-java-edition

I was trying to create a way so when someone stands on an iron pressure plate, it says hello to them in chat.

The command is:

Command block 1:

testfor -87.643 65 -67.535 heavy_weighted_pressure_plate

Command block 2:

say Welcome

But when I stood on the pressure plate nothing happened

It says:

[18:16:21] Entity '-87.442' cannot be found

Best Answer

/testfor is for entities only. If you want to check a block instead, use /testforblock.

It looks like you've copied the coordinates from your exact feet position. These may not end up rounding correctly to a block position; I'd recommend using the Looking At values instead:

Looking at coordinates

The following command will test for a heavy weighted pressure plate at (-88,65,-68), regardless of its power level:

/testforblock -88 65 -68 heavy_weighted_pressure_plate

You can then test for a specific power level with blockstates like this:

/testforblock -88 65 -68 heavy_weighted_pressure_plate power=1