Fix color blending averages

This commit is contained in:
tibs 2022-01-10 10:27:41 -05:00
parent f885301e64
commit bf13d88263
Signed by untrusted user who does not match committer: tibs
GPG key ID: 047833989F50F88F

View file

@ -29,14 +29,13 @@ public class WaterCauldronBlockEntity extends BlockEntity {
newColor[1] = (int) (colorComponents[1] * 255.0f);
newColor[2] = (int) (colorComponents[2] * 255.0f);
var workingColor = hasColor() ? color : new int[]{0, 0, 0};
if (hasColor()) {
var avgColor = new int[3];
avgColor[0] = (workingColor[0] + newColor[0]) / 2;
avgColor[1] = (workingColor[1] + newColor[1]) / 2;
avgColor[2] = (workingColor[2] + newColor[2]) / 2;
avgColor[0] = (color[0] + newColor[0]) / 2;
avgColor[1] = (color[1] + newColor[1]) / 2;
avgColor[2] = (color[2] + newColor[2]) / 2;
var avgMax = (Ints.max(workingColor) + Ints.max(newColor)) / 2.0f;
var avgMax = (Ints.max(color) + Ints.max(newColor)) / 2.0f;
var maxOfAvg = (float) Ints.max(avgColor);
var gainFactor = avgMax / maxOfAvg;
@ -44,6 +43,9 @@ public class WaterCauldronBlockEntity extends BlockEntity {
color[0] = (int) (avgColor[0] * gainFactor);
color[1] = (int) (avgColor[1] * gainFactor);
color[2] = (int) (avgColor[2] * gainFactor);
} else {
color = newColor;
}
markDirty();
rebuildBlock();