Minecraft – block creation of new Nether Portals in vanilla Minecraft

minecraft-commandsminecraft-java-edition

In vanilla Minecraft, is it possible to block creation of new Nether portals? This is for a Survival/Adventure hybrid map; I want the player to have a great deal of freedom, but to control access to the Nether to portals I've placed in the world. I can ask players to not build new portals, but it would be nice to have the rule mechanically enforced.

Possibilities include: somehow detecting and destroying the Nether portal blocks when they appear; not allowing the portal to be activated in the first place, and damaging the obsidian frame; somehow "tainting" any obsidian in the world or created so it's no longer eligible to be part of a port.

I'm at a loss for what a solution might look like beyond "Probably some command blocks." Trying to /testforblock every block in the world seems impractical.

Best Answer

You should use the /fill command to replace nether portal blocks with air. You don't want this running all of the time though, only when a player uses flint and steel. First, create an objective to track when flint and steel is used:

/scoreboard objectives add usedFaS stat.useItem.minecraft.flint_and_steel

Then, run these two commands on a clock in this order to clear nether portals around the player who just used a flint and steel:

/execute @a[score_usedFaS_min=1] ~ ~ ~ /fill ~-6 ~-6 ~-6 ~6 ~6 ~6 air 0 replace portal
/scoreboard players set @a[score_usedFaS_min=1] usedFaS 0

Note that this will replace any portals nearby, so you should have something to relight the portals that you want to stay lit.