Fix cloud colors not updating

This commit is contained in:
James Seibel
2024-10-24 22:02:35 -05:00
parent d1923ee6b5
commit b09b9d1b6f
@@ -367,20 +367,31 @@ public class CloudRenderHandler
&& boxGroup.isActive())
{
// cloud color changes based on the time of day and weather so we need to get it from the level
Color cloudColor = this.level.getClientLevelWrapper().getCloudColor(renderParam.partialTicks);
Color newCloudColor = this.level.getClientLevelWrapper().getCloudColor(renderParam.partialTicks);
// all boxes should have the same color, so we can get the previous color
// using the first box
// all boxes should have the same color, so we can get their current color
// via the first box
DhApiRenderableBox firstBox = boxGroup.get(0);
Color currentColor = firstBox.color;
Color currentBoxColor = firstBox.color;
// only trigger an update if the color changed
if (!cloudColor.equals(currentColor))
// update the boxes if their color should be changed
if (!newCloudColor.equals(currentBoxColor))
{
// Note: cloud instances may share boxes
// because of that this method may only need to be called once per all clouds
for (DhApiRenderableBox box : boxGroup)
{
box.color = cloudColor;
box.color = newCloudColor;
}
}
// trigger an update if this cloud section has a different color
// TODO merge all cloud VBOs so we only need to trigger this once
if (!cloudParams.previousColor.equals(newCloudColor))
{
cloudParams.previousColor = newCloudColor;
boxGroup.triggerBoxChange();
}
@@ -535,6 +546,9 @@ public class CloudRenderHandler
public long lastFrameTime = System.currentTimeMillis();
/** used so we can trigger a VBO update when necessary */
public Color previousColor = Color.WHITE;
// constructor //