How do I create unbreakable blocks?

How do I create unbreakable blocks? - High angle of wet dirty roller for painting on plastic cap from paint on floor

I am creating a map on Minecraft, and I want the players to break certain blocks like trees, but I don't want them to break other blocks like stone bricks. Is there any command that can help me?



Best Answer

You could put a player in Adventure mode using this command (in Java Edition 1.13+):

/gamemode adventure @p

Then, you would give them items with the CanDestroy or CanPlaceOn tags. Remember to use the exact capitalization as shown.

CanDestroy NBT tag

This is an example of the CanDestroy NBT tag, which allows people in Adventure mode to destroy any of the blocks in that list, but not any other ones:

/give @p minecraft:wooden_pickaxe{CanDestroy:["minecraft:stone"]}

Here is what appears when hovering over the item that lets you know what the item can destroy:

CanDestroy item tooltip

CanPlaceOn NBT tag

This is an example of the CanPlaceOn NBT tag, which allows you to place that block/item on any surface. For example, if the CanPlaceOn NBT tag included minecraft:stone, you could place the block (which is dirt in the example command) with that NBT tag on any of the blocks in the list above. Here is the example:

/give @p minecraft:dirt{CanPlaceOn:["minecraft:stone"]}

This is what would appear when hovering over the item to let you know what you can place the block/item on:

CanPlaceOn tooltip

Tag Support

Both CanDestroy and CanPlaceOn support tags. Tags represent a group of blocks/items and can be used in place of them. The following commands mean the same thing:

/give @p minecraft:stone_axe{CanDestroy:["#minecraft:planks"]}
/give @p minecraft:stone_axe{CanDestroy:["minecraft:oak_planks", "minecraft:spruce_planks", "minecraft:birch_planks", "minecraft:jungle_planks", "minecraft:acacia_planks", "minecraft:dark_oak_planks"]}

In earlier versions, specifying a block also included its other data values. For example, specifying Stone would also affect Diorite, Polished Diorite, Andesite, Polished Andesite, Granite, and Polished Granite. However, Java Edition 1.13 and higher require the use of tags instead.

Your Request

What you have requested can be achieved using the following /give command:

/give @p minecraft:iron_axe{CanDestroy:["#minecraft:logs","#minecraft:leaves"]}

This will allow the player to destroy the current 6 types of logs, wood, stripped logs, stripped wood, and leaves.

Here is the tooltip of the iron axe:

Requested item's tooltip

It repeats the blocks twice because dark oak and acacia logs and leaves have a different block name than oak, spruce, birch, and jungle logs and leaves.




Pictures about "How do I create unbreakable blocks?"

How do I create unbreakable blocks? - Unrecognizable child playing jenga at home
How do I create unbreakable blocks? - Top view of anonymous barefoot boy and girl in casual clothes sitting on floor carpet and playing with wooden blocks of jenga tower game
How do I create unbreakable blocks? - Content Asian children building wooden tower on floor at home



Is there a way to make blocks unbreakable in Minecraft?

Steps to build an Indestructible House
  • Build the Floor. First, start by building the floor of your house out of bedrock. ...
  • Build the Walls. Next, build the walls of your house out of bedrock. ...
  • Build the Roof. ...
  • Add the Torches. ...
  • Add the Iron Door. ...
  • Add a Redstone Device to open Iron Door.


  • How do you make an indestructible building in Minecraft?

    Simply set up a repeating command block requiring no redstone that replaces the block every time it is destroyed. Make sure you replace the coordinates ( x , y , and z ) with the coordinates of the block, and block with the block ID (such as minecraft:stone ).




    More answers regarding how do I create unbreakable blocks?

    Answer 2

    There is a crazy way of doing this: Replace every block you want to be "invincible" by a barrier block, and summon invisible ArmorStand's at their position with the designated block on their head.

    This works great, if you want to have only a few blocks, to be indestructable, but is completely overkill, if you want to create a whole wall.

    But if you want, for example, 1 cobblestone block, to be unbreakable, but all other cobblestone blocks to be breakable, this is the best you can do (and the only thing, I think)

    Answer 3

    Mining Fatigue or corrupt Haste can do this for you. In an area you want to protect, you can simply apply the effect there but remove it everywhere else. Here is the command to place in a repeating command block requiring no redstone to apply protection to the whole world:

    /effect @a minecraft:haste 129 10000
    

    Answer 4

    Instant Replacement

    Simply set up a repeating command block requiring no redstone that replaces the block every time it is destroyed.

    This is an image of what the command block would look like:

    Correct settings and command

    This is the command you use:

    /setblock <x> <y> <z> <block> replace
    

    Make sure you replace the coordinates (x, y, and z) with the coordinates of the block, and block with the block ID (such as minecraft:stone).

    When the block is broken, it will be instantly replaced with a block of the same type:

    Behavior if working

    Answer 5

    You could constantly place and destroy the block so they cant destroy it:

    /setblock ~ ~ ~ stone(or whatever block)
    /setblock ~ ~ ~ air

    or use the fill command instead of the setblock

    Answer 6

    How to make it so you can only break tree logs and leaves in adventure mode:
    Copy one command at a time and run each command in your map.

    1.13:

    /give @p diamond_axe{CanDestroy:["minecraft:oak_log","minecraft:oak_leaves"]}
    /give @p shears{CanDestroy:["minecraft:leaves"]}
    

    1.12 and under:

    /give @p diamond_axe 1 0 {CanDestroy:["minecraft:log","minecraft:leaves"]}
    /give @p shears{CanDestroy:["minecraft:leaves"]}
    

    Answer 7

    Falling Block in Barrier

    You can use the summon command to place a floating falling block inside a barrier. This has some drawbacks, mainly that falling blocks are entities and that they drop after a while.

    Floating falling block inside a barrier

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Ksenia Chernaya, Ketut Subiyanto, Ketut Subiyanto, Ketut Subiyanto