1

Im trying to use commands blocks, scoreboards, and redstone to give all my moderators effects when they run out. I already have the system to reapply the effects if you are in the team working but now I need to test for both being on the team moderators and not having the effect in one command block.

I tried this initially:

/testfor @a {ActiveEffects:[{Id:21b,Amplifier:20b}],Team=Moderators}

But I got an error in the output of the command block:

[17:45:02] Data tag parsing failed: Unable to locate name/value separator for string: Team=Moderators

Now please keep in mind I am not in 1.9 on my server yet meaning I do not have access to any commands related to that version. I believe this concept could be used on other servers that don't want to create their own new plugins for this and may rather use command blocks such as I have.

2
  • 1
    You don't want to be using testfor, especially since you're still in 1.8, because testfor is all but useless. Also, applying the effect over and over doesn't really have any deleterious effect.
    – MBraedley
    Feb 10, 2016 at 23:14
  • There actually is indeed a problem with applying the effect over and over again I dont know if this is a bug but when I reapply it after it was already applied it resets your health back to where it was before meaning that you only gain an extra half a heart before it gets reapplied then you loose it and start over again. Feb 11, 2016 at 12:27

1 Answer 1

3

Fixing your command

Your problem here is that you are mixing up target selector arguments with data tags, and then some minor mistakes.

Target selector arguments, such as team=Moderators (lowercase!) are placed in square brackets ([]) directly with the target selector, such as @a or @p. They come in the form key=value, with a predefined set of valid keys.

Data tag matching on the other hand is looking directly at the NBT data of an entity, such as ActiveEffects. They are placed within curly brackets ({}) and come in the form of key:value. Only a fairly small subset of commands are capable of using data tags at all.

Your command in this case should be

/testfor @a[team=Moderators] {ActiveEffects:[{Id:21b,Amplifier:20b}]}

Fixing your setup

However, your whole idea is rubbish, if I may be so blunt. It looks like you are testing if there are moderators with Health Boost 20, then invert the signal and re-apply health boost. The first problem is that no moderator gets health boost unless none of the moderators currently have health boost. Actually negating data tag matching requires assigning scoreboard values based on the data tag.

For most effects, reapplying the effect all the time works just fine, e.g. run

/effect @a[team=Moderators] <effect> 1 <amplifier> true

on a fast clock (setblock/fill clock!) works just fine, and is actually way less resource-intensive than a redstone lag-machine with torches, comparators and whatnot.

However, there is an issue with reapplying Health Boost since it will reset your current health to 10 hearts all the time. If you want to reapply the effect only when needed, using /testfor, comparators and redstone is still not a good idea. Instead, you should translate the data tag into a scoreboard value which can be used in a target selector. To do that, start by creating a scoreboard objective:

/scoreboard objectives add hasEffect dummy

Create a fill/setblock clock and put the following commands in order:

/scoreboard players set @a[team=Moderators] hasEffect 0
/scoreboard players set @a[team=Moderators] hasEffect 1 {ActiveEffects:[{Id:21b,Amplifier:20b}]}
/effect @a[team=Moderators,score_hasEffects=0] minecraft:health_boost 9999 20 true
3
  • Well there is a problem where if I do reapply it all the player does not get to regenerate up to that full amount of health and I guess I forgot to mention that I did try putting the team tag as lowercase and in square brackets next to the player selector and when I did the command block gave me the error of "Too many strings" and I get what your saying about the moderators not getting the effect unless none of them have it but my server is currently private and the only moderators are a friend and I so it doesn't bother us too much! Thanks for the suggestion though Feb 11, 2016 at 11:38
  • @BrandonRankin Ahh... that's an interesting fringe-case for health boost. I added a solution to reapply the effect on a moderator by moderator basis when needed.
    – MrLemon
    Feb 11, 2016 at 12:31
  • In Minecraft 1.13, all commands can tag data tags as arguments, and data tags were incorporated into the selector syntax as nbt={...}
    – pppery
    Jul 9, 2019 at 22:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .