8

I want to know what it is called and I would like a list of things (or a link to a list of things) you can do with it. I only know @p[score_name_min=1].

I want to know if there is something like: @p[activingeffect???].

I'm building something that will only affect the player if he has no active effect, e.g. give speed when the player does not have a speed effect yet.

I would like to use only 1 command:

/effect @p[No speed effect] 1 1.
1
  • In programming it's called a "predicate" or "condition". No idea what Minecraft calls it. Commented Dec 17, 2015 at 11:06

1 Answer 1

9

That thing is called target selector argument.

As of Mineraft 1.8.9, there are 20 different arguments available for use:

x, y, z         coordinates
r, rm           radius (max, min)
m               game mode
c               count
l, lm           experience level (max, min)
score_name      max score
score_name_min  min score
team            team name
name            entity name
dx, dy, dz      volume dimensions
rx, rxm         vertical rotation (max, min)
ry, rym         horizontal rotation (max, min)
type            entity type

The 1.9 snapshot 15w32b added another argument.

tag             scoreboard tag

As you can see, there is no way to check for active effects using target selector arguments. Checking for an entity's active effects can only be done by looking at it's data tag, e.g. checking if it matches {ActiveEffects:[{Id:1b}]}. The /effect command is not able to do that by itself, which means that you won't be able to do what you describe in a single command.

Using scoreboards, you can "translate" data tag matching into a score or a tag (1.9 only), which you can then use with target selector arguments.

Create a dummy objective to store the score:

/scoreboard objectives add hasSpeed dummy

Create a 20Hz. clock (setblock/fill clock, in 1.9, use repeat/chain command blocks) and run the following commands:

/scoreboard players set @a hasSpeed 0
/scoreboard players set @a hasSpeed 1 {ActiveEffects:[{Id:1b}]}

Afterwards, you can run

/effect @a[score_hasSpeed=0] 1 1

on the same clock.

6
  • It not /scoreboard players set @a hasSpeed 1 {ActiveEffects:[{Id:minecraft:speed}]} Commented Dec 17, 2015 at 13:35
  • 1
    It should be /scoreboard players set @a hasSpeed 1 {ActiveEffects:[{Id:1b}]} Commented Dec 17, 2015 at 13:36
  • @MinerNBuilder you are right. I have trouble keeping track of where I use numerical IDs and where the name works with potions. Note that you can suggest an edit to an answers yourself. It will be reviewed by high-rep (2000+) users, so make sure to put in a good reason.
    – MrLemon
    Commented Dec 17, 2015 at 13:39
  • Just a friendly suggestion, from now on, don't use "as of 1.x" until the official release of "1.x", since mojang may add or change something in a later snapshot, meaning your answer would be invalid for "1.x". Instead, say the snapshot version ("[year]w[week][extra identifier]", Ex:"15w43b"). If you want to make it easier to understand, try something like "as of 15w43b (1.9 snapshot), " Just a suggestion to keep your answers valid. It's a small detail, but it could be infuriating to someone who finds this later on. Commented Dec 26, 2015 at 11:01
  • @sharpturn Good point. However, the 1.9 snapshots have been feature-complete for a while now, and changes to this list before the official release are very unlikely.
    – MrLemon
    Commented Dec 26, 2015 at 12:28

You must log in to answer this question.

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