How do I create indestructible terrain? [duplicate]

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?


Solution 1:

You could replicate this by doing three things:

  1. 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).

  1. 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.

  1. 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 the CanPlaceOn 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).

Solution 2:

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.