2

So I'm trying to build a custom map, and I don't want people to be entering nether if someone would build a portal.

With only command blocks or just commands, is it be possible for the nether portal not teleport you anywhere, teleport you a few blocks away from it, or just teleport you back into the map's center? (In singleplayer)

2
  • I assume survival, and 1.8, right?
    – user139899
    Commented Feb 27, 2016 at 17:53
  • Well, the player who is playing the map, is going to be in survival, yes. And the map is going to be in 1.9, but I assume 1.8 solutions might also work
    – MrWhiteee
    Commented Feb 27, 2016 at 17:55

1 Answer 1

2

First, have a repeating command block set to Always Active testing for a minecraft:portal block(the purple part of the nether portal):

/execute @p ~ ~ ~ testforblock ~ ~ ~ minecraft:portal

It will point into another repeating command block, also Always Active, and it will also be set to Conditional, using /spreadplayers to teleport them 2-4 blocks out of the portal.

/execute @p ~ ~ ~ spreadplayers ~ ~ 2 4 true @p

The reason /execute is used is to teleport them within a 2-4 block range of where they are currently.

5
  • Whoops, I typed /execute @p ~ ~ ~ spreadplayers ~ ~ 2 4 true wrong. Fixed.
    – user139899
    Commented Feb 27, 2016 at 18:12
  • Thanks, I kind of changed the second command into teleporting a player into map's center, because for some reason the spreadplayers command didn't work.
    – MrWhiteee
    Commented Feb 27, 2016 at 18:12
  • Yea, I changed it wrong again, lol. The correct command is /execute @p ~ ~ ~ spreadplayers ~ ~ 2 4 true @p. But your way works too!
    – user139899
    Commented Feb 27, 2016 at 18:13
  • 2
    @p will not work for multiplayer, since it only targets the player closest to the command block. Use @a and @a[c=1] in the execute and subsequent commands, respectively, instead.
    – MrLemon
    Commented Feb 27, 2016 at 20:31
  • 2
    Also, you can condense this to a single command by using execute's detect scheme instead of testforblock: /execute @a ~ ~ ~ detect ~ ~ ~ minecrat:portal -1 spreadplayers ~ ~ 2 4 true @a[c=1].
    – MrLemon
    Commented Feb 27, 2016 at 20:33

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.