Yarn: WololoGoal purpleSheepPredicate is named wrongly

Created on 10 May 2020  ·  11Comments  ·  Source: FabricMC/yarn

The purpleSheepPredicate actually checks if the sheep is blue.

bug refactor

Most helpful comment

Max, this should be put in documentation not the actual name. The name should be short and concise and reflect what it does.

All 11 comments

What it's doing is checking if the original colour combined with the new colour makes purple.

@MAX1234567890 that can't be the case. It is a predicate on a sheep not two colors.

The second colour is always red. Hence it checks sheep->colour + red == purple (ie sheep->colour == blue)

Although that is true it is a misleading way to put it.
```java
private final TargetPredicate purpleSheepPredicate = (new TargetPredicate()).setBaseMaxDistance(16.0D).includeInvulnerable().setPredicate((livingEntity) -> {
return ((SheepEntity)livingEntity).getColor() == DyeColor.BLUE;
});

The second colour is always red. Hence it checks sheep->colour + red == purple (ie sheep->colour == blue)

That is a complete misunderstanding of the game's logic.

That TargetPredicate is used to test if the evoker should wololo the sheep, i.e. the Sheep MUST be blue:

List<SheepEntity> list = EvokerEntity.this.world.getTargets(SheepEntity.class, this.purpleSheepPredicate, EvokerEntity.this, EvokerEntity.this.getBoundingBox().expand(16.0D, 4.0D, 16.0D));
if (list.isEmpty()) {
    return false;

Also a further look into the goal shows the sheep is never meant to turn purple, but red as shown in castSpell

I know it doesn't turn purple, but the predicate, already knowing the sheep will turn red, checks if the original colour of the sheep combined with the new colour of the sheep is purple. Basically, the evoker is using a { return purple - x; } construction, but the evoker's favourite colour is red, so he only wants to turn sheep red. so he has to make sure that red = purple - the original colour, i.e. the colour is blue.

http://www.clipartbest.com/cliparts/aiq/Mb5/aiqMb5AiM.jpeg

Hmm, is there anything documenting that specific backstory? wiki for example?

I feel in this case, the logic should dictate the name, but a nice bit of humourous javadoc about that could be fun

Not directly, but given that a) it is officially stated that Evokers built redstone and b) the fact that Vexes are red as well is what lead me to that conclusion. It's also important to keep in mind the symbolic nature of the purple: the Evoker is the only Illager (including Vexes and Witches) not to have any purple on it, which leads to the idea that the Illager is "computing" purple - sheep's colour to turn them red.

Max, this should be put in documentation not the actual name. The name should be short and concise and reflect what it does.

Lol why the heck are you concerned about implementation details if the implementation details are confusing and not helpful. Just call it convertibleSheepPredicate, why are you going to brainfart about a color nonsense

Also blame mezz for this thing. Yarn has been much smarter since luckily, naming things in more efficient ways.
https://github.com/FabricMC/yarn/commit/5c6c0c71d1480a36e1d3c2a8f2adf859e307cbc6#diff-b6376ebd10e80e5e322fb28f766d47c4R44

The details aren't confusing and its very clear what is being done though. It checks if the sheep is blue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

liach picture liach  ·  4Comments

Runemoro picture Runemoro  ·  4Comments

asiekierka picture asiekierka  ·  3Comments

Runemoro picture Runemoro  ·  4Comments

enbrain picture enbrain  ·  4Comments