-1

This is similar in a way to the following question, but the solution the MBraedley gave didn't work for me. As the linked post says, I've also tried the many ! values in front of the coordinates etc., to no avail.

Essentially, I'm creating a "safe zone" area for the spawn (regardless of spawn protection settings) of my realm, similarly to that of survival servers like what LemonCloud had. I've got detecting in the area down, but now I need it for those outside the area.

  • 1
    Can you tell us why my answer doesn't work? Are you on Java Edition 1.13? Because my solution won't work for that version without some changes. Are you running all three commands in a single tick and in the proper order? Because if not, it might not work. Is there an error? I can't fix the error if I don't know what it is. – MBraedley Apr 21 at 17:59
  • Sorry I hadn't specified that! I thought I did. The solution I needed had to be running continuously on a repeating command block, which means the issue that the OP of the linked post brought up to you did in fact happen since it wasn't a single tick. – EarthToAccess Apr 21 at 18:14
  • 1
    All you need to do is have all three commands in a single chain, and set the first block to repeating. Or better yet, put those commands in a function and set it to run every game tick. These are all pretty straight forward command block concepts. If you don't know how to run multiple commands in a single tick, you should ask that instead. – MBraedley Apr 21 at 18:25
3

You didn't specify why the solution in the linked post didn't work for you, but in 1.13 there's actually a better solution:

/execute as @a unless entity @s[x=…,y=…,z=…,dx=…,dy=…,dz=…] run <command>
  • I had added a comment above, I thought i had said why at first. Sorry about that! In the meantime, I'll test it out and see if it works. – EarthToAccess Apr 21 at 18:15
  • 1
    Presumably it should be unless entity @s[...], not unless @s[...] – pppery Jul 14 at 0:22
  • 1
    @pppery Correct. I should go through all my answers one day and check if they actually work. I usually write them on the go, from memory. – Fabian Röling Jul 14 at 7:38
  • To be fair, I usually do the same thing, both with my answers and my 1.13 syntax comments. – pppery Jul 14 at 13:58

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.