1

I've recently added some new commands into a .mcfunction, since 1.12 is now out. What I wanted was that if the player ran directly into a block, it destroys it, now that works with this command:

execute @a ~ ~ ~ detect ~1 ~ ~ minecraft:wool 7 setblock ~1 ~ ~ minecraft:air 0 destroy

But my only problem, is that it only works from 1 side, not all 4 sides of the block. Can anyone help me out? I really only want it to work from the front, left, right and back sides.

Example: (Sorry it's an MS Paint Example. But it's the only way I can kind of explain, the arrows represent which way the player will run into the block.)

Thanks, Daniel

1
  • detect ~1 ~ ~ only detects a block on one side of the player (regardless of where he's looking), so it's one out of four to guess correctly and it's always the same side. You can either check all sides of the player or try a command detecting the direction a player is facing.
    – dly
    Commented Jun 9, 2017 at 16:35

1 Answer 1

0

To detect a block from all sides, you have to apply all test cases; basically, four commands blocks; one for each side and have them chainned.

execute @a ~ ~ ~ detect ~1 ~ ~ minecraft:wool 7 setblock ~1 ~ ~ minecraft:air 0 destroy
execute @a ~ ~ ~ detect ~-1 ~ ~ minecraft:wool 7 setblock ~-1 ~ ~ minecraft:air 0 destroy
execute @a ~ ~ ~ detect ~ ~ ~1 minecraft:wool 7 setblock ~ ~ ~1 minecraft:air 0 destroy
execute @a ~ ~ ~ detect ~ ~ ~-1 minecraft:wool 7 setblock ~ ~ ~-1 minecraft:air 0 destroy
1
  • Thank's so much! That worked perfectly! :) Commented Jun 11, 2017 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.