Minecraft – Make certain blocks indestructible in creative mode (Minecraft Java 20w10a)

minecraft-commandsminecraft-java-edition

I've recently built a creative superflat world with one layer of bedrock for testing redstone contraptions. I'm constantly annoyed of accidentally breaking bedrocks and having to replace it each time. I did some google searches but only found reference to setting gamemode to adventure or anti-griefing in survival.

The baseline is, I want an indestructible floor that I can't accidentally break in creative Minecraft.

  • Version: single player (not server) Minecraft Java 20w10a

Best Answer

All blocks can be broken in Creative mode. If you wanted a horizontal border, you could use the world border for that, but even that can be bypassed in Spectator mode.

The best solution is probably to replace the ground at all times. Put this command into a repeating command block:

execute at @a run fill ~-5 0 ~-5 ~5 0 ~5 bedrock replace air

This replaces air with bedrock a certain range around every player at the lowest height level.

The only remaining problem then is that you can still fall through the block when you break it while standing on it. This is probably a bug, I created a report about it: https://bugs.mojang.com/browse/MC-174386

You can work around it using this additional command:

execute as @a at @s if entity @s[y=0,dy=0] run tp @s ~ 1 ~

This teleports you to height y=1 whenever you are at height y=0.

You should only get a feedback message from the first command whenever you break a bedrock block and from the second one whenever you start falling through the block, but if you still want to get rid of this output, you can disable command block feedback in general:

/gamerule commandBlockOutput false