How do I make an unbreaking Diamond Pickaxe that can only break Obsidian in MCPE? [duplicate]

I am trying to create a diamond pickaxe with two effects. I would like it to be Unbreaking, and that it can only break Obsidian. The problem is, I'm not sure how to go about it.

Can someone help me with this?


Solution 1:

For the breaking obsidian part, use this command:

/give @s diamond_pickaxe 1 0 {"can_destroy":{"blocks":["obsidian"]}}

If that doesn’t work, try using @p instead of @s.

Unfortunately in PE, giving enchanted items using commands is not possible. You could use this command if you are holding the pickaxe:

/enchant @s unbreaking [level:int]

Again, use @p if @s doesn’t work. [level:int] is the level of unbreaking you want the pickaxe to be (from 0 to 2, where 0 is level 1).

See this answer for more information.