2

I want to use a command block that detects if there is a gold block in the player's inventory and replace it with a gold block that can only be placed on grass.

How it looks

Now, here is what I'm doing: I started a redstone clock which connects to a command block which has this command to clear all gold blocks.

clear @p gold_block

Then I have a comparator that takes that signal and points into another command block that gives the player a gold block that can only be placed on grass.

give @p gold_block 1 0 {CanPlaceOn:[grass]}

What happens is that this special gold block also gets removed by the previous command block. I've tried to give the gold block a name with the display tag, but I don't know how to configure the command to give the block both tags (Display & Can PlaceOn).

1

Try to give to the first gold block a name:

/give @p gold_block 1 0 {display:{Name:"a name"}}

And then run the /clear command like this:

/clear @p gold_block 0 1 {display:{Name:"a name"}}

This command will clear only the golden block that has the name "a name".

Now give your SPECIAL BLOCK, but with another name:

/give @p gold_block 1 0 {CanPlaceOn:[grass],display:{Name:"SPECIAL BLOCK"}}

You need to put another name that the clear command block doesn't affect.

  • Thanks, this helped a lot! But now, I'm running into another problem. When i place down the special gold block with the special property and then I try to break it again with a goldblock breaking pickaxe i gave myself but it just turns into a normal gold block again! Do you have any idea how to prevent this or is it just like that forever? – Aysidia Jun 19 '16 at 8:03
  • I don't think if it's possible. Unfortunately , the entity item form cannot be renamed , like an inventory item can be. Anyway I am sure this problem has a solution :D – iDoomfull Jun 19 '16 at 9:48
  • Here is even more detail to my contraption: I want to place down gold blocks on a spot which if broken with a special pickaxe they get cleared and replaced on your inventory with the same gold block with the special property (CanPlaceOn) – Aysidia Jun 19 '16 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.