I'm trying to make an adventure game, and I'm making springs, but I can't seem to get the /testfor command to work. What do I do?

  • What's the whole command you tried? Mar 12 at 8:47
  • /testfor @a[x=(xpos) y=(ypos) z=(zpos) r=1] Mar 23 at 13:46
  • After that I use a fill command. Mar 23 at 13:50

You need to use /execute

/execute @a[x=6,y=3,z=10,dx=1,dy=0,dz=1] ~ ~ ~ effect @s levitation 1 1 true

Within the target selector @a[] you specify the starter coordinates with x=, y=, z=, and then the distance with dx=, dy=, dz=. the dx dy dz is the difference, so if x=10 and dx=5 you test for an area from 10 to 15, and this works the same for the other once as well both for positive numbers and negative.

  • There's a slight problem there. I use Edu edition. And I've tried the dx, dy, and dz. It just says syntax error. Plus, I'm using a fill command with sticky pistons and slime blocks. Not an effect command. Mar 23 at 13:50
  • I'll try it out in the Edu version later. It sould work. Just let me know: Do you intend to fill in the pistons and slimes at the same time or with a delay? Mar 23 at 16:09
  • I intend to fill the block under the sticky piston with a redstone block. Mar 23 at 17:35
  • The command works fine for me, you can also replace the dz, dy ,dz with r=1. And replace effect etc. with fill x y z x2 y2 z2 redstone_block, but if you'r only setting one block you should use setblock x y z redstone_block instead. Mar 23 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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