Ender IO Zoo

Ender IO Zoo

968k Downloads

Solar panel generating factor is not reasonable

Abastro opened this issue ยท 2 comments

commented

In the code, TileEntitySolarPanel#calculateLightRatio() is using saved light value and skylight subtracted.
But why multiplying cos(sunAngle) then?

public static float calculateLightRatio(World world, int x, int y, int z) {`
    int lightValue = world.getSavedLightValue(EnumSkyBlock.Sky, x, y, z) - world.skylightSubtracted;
    float sunAngle = world.getCelestialAngleRadians(1.0F);

    if(sunAngle < (float) Math.PI) {
      sunAngle += (0.0F - sunAngle) * 0.2F;
    } else {
      sunAngle += (((float) Math.PI * 2F) - sunAngle) * 0.2F;
    }

    lightValue = Math.round(lightValue * MathHelper.cos(sunAngle));

    lightValue = MathHelper.clamp_int(lightValue, 0, 15);
    return lightValue / 15f;
}

I think multiplying World#getSunBrightnessFactor() and getSavedLightValue would be sufficient for that.

commented

Sunlight is only dimmer at the very beginning and end of the day. The solar panel is meant to be slightly more realistic in that the actual angle of the sun affects the power production. What you propose would have it generate 100% of its power for 90% of the day, instead of the current linear increase/decrease.

commented

Oh I might misunderstand that method.
Then, for compatibility I should create some method on forge managing pure skylight value.