Fix Color Particle API
Checks particle datatype instead of particle type.
Fixes #10872
To me, it doesn't make sense to allow calling color(Color,float) for non DustOptions types. The float size doesn't apply to stuff like ENTITY_EFFECT.
Currently, all colour methods lead to this as shown below, hence I didn't want to make changes to make big changes to the existing API as seen below.
public ParticleBuilder color(@Nullable Color color) {
return color(color, 1);
}
@NotNull
public ParticleBuilder color(int r, int g, int b) {
return color(Color.fromRGB(r, g, b));
}
@NotNull
public ParticleBuilder color(final int rgb) {
return color(Color.fromRGB(rgb));
}
I'll go ahead and add that size doesn't apply to ENTITY_EFFECT unless you prefer for me to change up the first colour method to make that execute it for the datatype of COLOR.
EDIT: Something like this...
public ParticleBuilder color(@Nullable Color color) {
if (datatype == DustOptions) {
return color(color, 1)
}
if (datatype != Color) {
throw "This particle cannot have a color"
}
if (color == null) {
return data(null)
}
return data(color)
}
This actually wouldn't work too since entity_effect take an argb integer and not a rgb so you would need to support both format in color(int) and handle conflict when the alpha channel is not set (for rgb it should be opaque, for argb it should be transparent). I still believe there's no issue here except maybe the method name which is too generic but people should use #data directly for entity_effect.
This actually wouldn't work too since entity_effect take an argb integer and not a rgb so you would need to support both format in color(int) and handle conflict when the alpha channel is not set (for rgb it should be opaque, for argb it should be transparent). I still believe there's no issue here except maybe the method name which is too generic but people should use #data directly for entity_effect.
I've gone ahead and added the ARGB and tested it with DUST and normal Color and it works with both.
I'm unsure whether I should be changing anything within the color(color, size) function or whether it is fine as I am a bit confused so a bit of clarification would help.