mojira.dev
MC-261096

Tropical fish spawn with black colors since 1.19.3

Based on 1.13 patch notes, tropical fish were meant to only with 15 colors. Black was excluded because it can make the eyes hard to see. However, since 1.19.3 (to my current knowledge), tropical fish can spawn with black colors. 

 

This can affect both the base color and pattern.

 

Images attached show tropical fish that have spawned in my survival world. 

Linked issues

Attachments

Comments 6

I recently started a project to collect all tropical fish variants and noticed this as well. Black can be found as both base/pattern color. I play Java, version 1.19.4.
Tbh I hope it will become a feature and not a bug, they're very cool fishes.

It's something I have noticed since 1.19.3. Very cool fish but I am collecting them in in my survival world, just in case they become version exclusive rares. 

An attachment with a disallowed file extension has been removed from this ticket.

Executable files and documents are not allowed as attachments.
Please attach crash reports, log files and screenshots as they are instead of pasting them into a document.
-- I am a bot. This action was performed automatically! If you think it was incorrect, please notify us on Discord or Reddit

I hope they keep this as a feature and not as a bug, I collect tropical fish in my hardcore world, and the ones that are partly black do spawn naturally (1.19.3 and 1.19.4), and they are some of the coolest ones (attached image shows some of the ones i have found).

[media]

Took me a few hours to find one with black colors but can confirm in 1.20.4

Also here is some code analysis (Code is decompiled using Mojang Intermediary mappings):

This bug was introduced in 1.19.3 (as the poster correctly notes). The code for tropical fish variants was rewritten then and the way the random color was generated got changed too.

There is an array at DyeColor.values which contains 16 colors with black being the last (the 15th if you start counting from 0). Pre-1.19.3, a random number was generated from 0-14 for the color, meaning black (the color in the 15th place) was never chosen. However, when the code was rewritten, that behavior was not maintained due to an oversight. Now, instead of using random.nextInt(15), it uses net.minecraft.Util.getRandom, which returns a random element of whatever array is passed into it. This means that black is a valid color for the base color or pattern color to be now, which was not intended.

The below code is from 1.19.2 (before the bug): each property (in order: base, pattern, base color, pattern color) is randomly generated, then squashed into one value which is later interpreted elsewhere. Note that the last two (base color and pattern color) use a number from 0-15:

else {
        this.isSchool = false;
        var6 = var10.nextInt(2);
        var7 = var10.nextInt(6);
        var8 = var10.nextInt(15);
        var9 = var10.nextInt(15);
    }
this.setVariant(var6 | var7 << 8 | var8 << 16 | var9 << 24);
return var4;

 

Since 1.19.3, the above code now looks like this, where Util.getRandom is called instead of random.nextInt:

else {
        this.isSchool = false;
        TropicalFish.Pattern[] var9 = TropicalFish.Pattern.values();
        DyeColor[] var10 = DyeColor.values();
        TropicalFish.Pattern var11 = Util.getRandom(var9, var7);
        DyeColor var12 = Util.getRandom(var10, var7);
        DyeColor var13 = Util.getRandom(var10, var7);
        var6 = new TropicalFish.Variant(var11, var12, var13);
    }
this.setPackedVariant(var6.getPackedId());
return var4;

 

The DyeColor.values array is below:

{WHITE, ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, GRAY, LIGHT_GRAY, CYAN, PURPLE, BLUE, BROWN, GREEN, RED, BLACK}

I know they aren't supposed to exist, but I fail to see why this would be a problem that needs fixing. It gives more variety to the game and does not negatively affect gameplay. And as other people said, they look cool. It doesn't matter that the eyes are hard to see; if you don't like them, then don't catch them; this game gives you the freedom to make that choice.

 

This is one of those cases, like ice-boats, where "it's not a bug, it's a feature".

Please keep these black fishies around!

Nature17

(Unassigned)

Community Consensus

Platform

Normal

Mob spawning

1.19.4, 1.20.4, 24w05b

Retrieved