Minecraft – Is it possible to disable nether in minecraft

minecraft-commandsminecraft-java-edition

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)

Best Answer

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.