mojira.dev
MC-121740

@r (random) selector does not work for non-players anymore

The bug

The type argument can no longer be used for the @r selector to select non-player entities.

How to reproduce

  1. Make sure there are other entities in the world

  2. Use the following command

    /say @r[type=!player]

Code analysis

From this comment

The following is based on a decompiled version of Minecraft snapshot 17w45b (obfuscated) decompiled using CFR v122

This is because the class cx.java, which appears to parse selectors, sets the properties l, presumably named selectsNonPlayer or equivalent when deobfuscated to false. The relevant code is as follows:

else if (c2 == 'r') {
    this.k = 1;
    this.l = false; //Should be true
    this.y = i;
}

Linked issues

Comments 18

I can confirm that this doesn’t work in most situations (IE @r with entities doesn’t work)

@@unknown did you mean to comment on a different report or is your comment missing a "not" (even then "in most situations" looks wrong) since this report is about something not working

The following is based on a decompiled version of Minecraft snapshot 17w45b (obfuscated) decompiled using CFR v122

This is because the class `cx.java`, which appears to parse selectors, sets the properties `l`, presumably named `selectsNonPlayer` or equivalent when deobfuscated to false. The relevant code is as follows:

else if (c2 == 'r') {
    this.k = 1;
    this.l = false; //Should be true
    this.y = i;
}

@@unknown thank you very much. I included it in the description, I hope you are fine with that.

@Marcono1234 I meant to say ‘not’. Sorry about that.

8 more comments

In 18w07c, using @r[type=... now gives a syntax error "Option 'type' isn't applicable here"

Confirmed in 18w11a. Do you want me to keep checking this or is it generally accepted that it's going to eventually be marked as Works as Intended?

We don't need weekly updates, no. We're happy about them, but especially for minor stuff like this it's not important.

can be achieved through @e and type, limit and sort attributes. sort=[nearest|furthest|random|arbitrary]

/say @r[type=!player] can be done with /say @e[type=!player,limit=1,sort=random]

WAI, it's now achieved via @e[type=!player,limit=1,sort=random]

marcono1234

migrated

Confirmed

player, selector

Minecraft 17w45a, Minecraft 17w48a, Minecraft 17w50a, Minecraft 18w01a, Minecraft 18w02a, Minecraft 18w03b, Minecraft 18w06a, Minecraft 18w11a, Minecraft 18w19a, Minecraft 18w20c

Retrieved