I am making my Adventure map, and i have one problem. I want to create a block what can be placed on diamond ore, for example, and when player destroy it, he could place it again.
-
4Possible duplicate of An item to break only SPECIFIED blocks? and How can I make a block only be placed on certain other blocks– ppperyCommented May 22, 2020 at 20:02
-
@pppery It seems like those will only answer half the question (which makes it a question that needs focus), but is the other part (make a block that can be destroyed and deployed again) addressed in a question? I wasn't able to find one.– JoachimCommented May 23, 2020 at 7:52
-
1@Joachim Making crafted items usable in adventure mode?– ppperyCommented May 23, 2020 at 15:45
2 Answers
Using certain tags when using the /give command in minecraft you can allow certain blocks/tools to be placed/broken To break blocks:
/give @p minecraft:stone_shovel 1 0 {CanDestroy:[minecraft:dirt, minecraft:gravel, minecraft:soulsand]}
The gravel, dirt, and soulsand can be replaced with your desired blocks to be able to break.
To place:
/give @p minecraft:gravel 1 0 {CanPlaceOn:["minecraft:stone","minecraft:stonebrick"]}
This will allow the player to only place the block on "stone" and "stone brick"
To be more advanced you could run a testfor when the player breaks an item it could execute the command:
/give @p minecraft:gravel 1 0 {CanPlaceOn:["minecraft:stone","minecraft:stonebrick"]}
Then when they break the block they would get the block, and have it able to be placed on specific blocks.
Lets say that your "block" is emerald ore, you can give them an item/tool like this:
/give @p minecraft:diamond_pickaxe 1 0 {CanDestroy:[minecraft:emerald_ore]}
Then you could testfor that the emerald ore has been broken. Then you could execute the command:
/give @p minecraft:gravel 1 0 {CanPlaceOn:["minecraft:diamond_ore"]}
There you go!
-
Please don't add signatures to your posts; they're noise, and don't belong.– FrankCommented Jun 16, 2016 at 22:01
Since blocks can't store data tags, you can't have the block retain information like CanPlaceOn tags when broken from the world. What you'd have to do instead is detect when the player has the right block type (by setting a scoreboard tag when their inventory data tag contains that item), then /clear'ing it from their inventory and /give them a copy of the block with the CanPlaceOn tag you want.