2

I want it so that when an anvil gets used up, it will put another one in it's place. Someone told me to use /execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:snow 0 /setblock ~ ~-1 ~ minecraft:air 0 , but it says

"/setblock is not a valid number"

  • 1
    That command should work, if you type it exactly as written, but it does something entirely different from what you ask: It replaces snow blocks below any player with air. – MrLemon Aug 26 '16 at 7:50
  • 1
    Is this only one anvil (e.g. for an adventure map), or is this any anvil placed anywhere in the world? – MrLemon Aug 26 '16 at 7:51
  • The command itself worked perfectly fine for me. Although I'm not 100% sure what you want to do as you talk about anvils then use an example that removes snow below the player's feet, maybe explain your goal a bit more? Where is the anvil you want replaced, should it be replaced when it breaks or when it's damaged but not completely broken? – Hoi_A Aug 27 '16 at 11:17
2

If I understand correctly... You want to refill the anvil when it's broke. So use this

/execute @e[name=Anvilblock,type=ArmorStand] ~ ~ ~ detect ~ ~ ~ air 0 /setblock ~ ~ ~ anvil

The lever is only for toggle It would test for every ArmorStand that named "Anvilblock" And if you want self-repair anvil just stand on where you want it to be placed and do

/summon ArmorStand ~ ~ ~ {CustomName:Anvilblock,Invisible:1,Marker:1}

Invisible make it invisible and Marker make It's hitbox's size to 0. And when you don't want it anymore, Stand near it and do

/kill @e[type=ArmorStand,name=Anvilblock,r=2]

Be sure to turn off commandBlockOutput in /gamerule

Hope that's help!

0

This should work. It doesn't detect for ANY anvil, only one at a specific coordinate, but it will work. enter image description here Take a repeating command block (always active) and place in the command /testforblock <coords> anvil <data value1>, then place a chain command block (conditional) with /setblock <coords> anvil <data value2>

Now you'll have to find the coords yourself, but for the data values:

  • Data Value 1: 1 ; Data Value 2: 9
  • Data Value 1: 2 ; Data Value 2: 10
  • Data Value 1: 3 ; Data Value 2: 11

These are all your options for the data values, but they must be used together as a pair. Use whatever combination fits your scenario best.

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.