4

I have a huge problem: I want to set a players HPLUranium score to 9 whenever he wears an anti-radiation suit - easy, I do this like that:

scoreboard players set @p HPLUranium 9 {Inventory:[{Slot:103b,id:minecraft:leather_helmet,tag:{display:{Name:Nuclear Helmet,color:10066328}}},{Slot:102b,id:minecraft:leather_chestplate,tag:{display:{Name:Nuclear Tunic,color:10066328}}},{Slot:101b,id:minecraft:leather_leggings,tag:{display:{Name:Nuclear Pants,color:10066328}}},{Slot:100b,id:minecraft:leather_boots,tag:{display:{Name:Nuclear Boots,color:10066328}}}]}

But the problem is... how do I make him LOSE this 9 whenever it's not true? Like Conditional command block but opposite, command block that only runs when the one behind him say "false".

I tried to make command block repeating setting HPLUranium to 0, and next to it Chain command block with command showed up there, but it was sometimes changing to 0 for... maybe a tick long when it should be 9, it may cause problems.

Any ideas how to run command if player IS NOT MATCHING DataTag?

  • 1
    The method you already tried is the only method I think that there is, but it should always work. – Jacques Marais Jan 29 '16 at 17:13
  • Not sure, becouse as I said sometimes 9 changes to 0 for a few ticks long... it may be a problem :/ – HardnerPL Jan 29 '16 at 17:29
  • @HardnerPL in that case, your setup is wrong somehow. There should not be any flickering involved. Two chain command blocks triggering after one another should work. – MrLemon Jan 29 '16 at 17:30
  • @MrLemon You're right i guess, looks like it can't be a problem - i made repeating command block trying to kill me if it's 0, but even if it "changed" to 0 i wasn't killed :) – HardnerPL Jan 29 '16 at 17:47
  • 2
    Possible duplicate of How to use exclamation marks in Minecraft commands? – pppery May 24 at 15:59
1

Have a repeating command block with the following command and keep note of its coordinates:

testfor @p {Inventory:[{Slot:103b,id:minecraft:leather_helmet,tag:{display:{Name:Nuclear Helmet,color:10066328}}},{Slot:102b,id:minecraft:leather_chestplate,tag:{display:{Name:Nuclear Tunic,color:10066328}}},{Slot:101b,id:minecraft:leather_leggings,tag:{display:{Name:Nuclear Pants,color:10066328}}},{Slot:100b,id:minecraft:leather_boots,tag:{display:{Name:Nuclear Boots,color:10066328}}}]}

Then, have another repeating command block with the following command, replacing X, Y, and Z with the coordinates of the first repeating command block:

testforblock X Y Z command_block -1 {SuccessCount:0}

and it will point to a last repeating command block set to Conditional with the following command:

scoreboard players set @p HPLUranium 0

All command blocks should be set to Always Active.

When the first command block fails, the second command succeeds because the SuccessCount is 0. This causes the third command block to activate, because conditional command blocks activate when a command block pointing into them succeeds.

When the player is wearing the anti-radiation suit, the second command block will fail because SuccessCount will not be 0, and the player's HPLUranium score will not change.

| improve this answer | |

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.