How do I make terrain that has not been placed by a player be immune to things? Example: TNT, mining. Also, how do I make blocks that have been placed by a player able to be mined/blown up?
3 Answers
You could replicate this by doing three things:
- Set all players to Adventure Mode (Gamemode 2).
In adventure mode, players cannot break blocks (but can still interact with interactibles like buttons, doors and levers).
- Give every player a special item that can only break a subset of blocks.
You can give players tools that allow them to break specific blocks in Adventure mode.
See this answer for more details. If figuring out the syntax isn't your thing, use this.
- Make sure players only have access to the specific allowed blocks.
By restricting the block pool and giving players a tool that only allows to break them, you've effectively restricted players to whatever blocks they've placed.
Ensure the blocks you've given them has theCanPlaceOn
flag for every block.
Or you could go code your own Bukkit plugin to do that, because this is something niche (not commonly done, or if at all).
-
Thanks but adventure mode doesn't work for tnt does it? Anything I can do for explosions to not hurt terrain only things players have placed?– tannerCommented Sep 13, 2019 at 4:00
-
2Adventure mode works with TNT if you don't give players access to TNT. Commented Sep 13, 2019 at 5:05
-
If I'm not wrong, you can change the "toughness" of a block using behaviour packs Commented Sep 13, 2019 at 5:40
The closest to what you want (without mods) is probably spawn protection. Every dedicated server has a setting of how far around the spawn you want to have spawn protection, in this area only players with a certain permission level are able to place or break blocks.
https://www.gamergeeks.nz/apps/minecraft/give-command-generator
This website lets you create specific tools that can have enchantments or only able to break types of blocks.
Select the item, and then press advanced settings. Then under the Adventure mode tab you can select what blocks you can break with that tool. You must be in Adventure mode for this to work.
Alternatively you could build that spawn area somewhere else, and then use the clone command that will clone that spawn area to another location. Make sure the clone command is on an infinite loop to prevent it from being broken.