69 lines
		
	
	
	
		
			2.3 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			69 lines
		
	
	
	
		
			2.3 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.client.renderer.fog.environment;
 | |
| 
 | |
| import net.fabricmc.api.EnvType;
 | |
| import net.fabricmc.api.Environment;
 | |
| import net.minecraft.client.Camera;
 | |
| import net.minecraft.client.multiplayer.ClientLevel;
 | |
| import net.minecraft.util.ARGB;
 | |
| import net.minecraft.util.CubicSampler;
 | |
| import net.minecraft.util.Mth;
 | |
| import net.minecraft.world.level.biome.BiomeManager;
 | |
| import net.minecraft.world.phys.Vec3;
 | |
| import org.joml.Vector3f;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public abstract class AirBasedFogEnvironment extends FogEnvironment {
 | |
| 	@Override
 | |
| 	public int getBaseColor(ClientLevel level, Camera camera, int renderDistance, float partialTick) {
 | |
| 		float f = Mth.clamp(Mth.cos(level.getTimeOfDay(partialTick) * (float) (Math.PI * 2)) * 2.0F + 0.5F, 0.0F, 1.0F);
 | |
| 		BiomeManager biomeManager = level.getBiomeManager();
 | |
| 		Vec3 vec3 = camera.getPosition().subtract(2.0, 2.0, 2.0).scale(0.25);
 | |
| 		Vec3 vec32 = level.effects()
 | |
| 			.getBrightnessDependentFogColor(
 | |
| 				CubicSampler.gaussianSampleVec3(vec3, (ix, j, kx) -> Vec3.fromRGB24(biomeManager.getNoiseBiomeAtQuart(ix, j, kx).value().getFogColor())), f
 | |
| 			);
 | |
| 		float g = (float)vec32.x();
 | |
| 		float h = (float)vec32.y();
 | |
| 		float i = (float)vec32.z();
 | |
| 		if (renderDistance >= 4) {
 | |
| 			float j = Mth.sin(level.getSunAngle(partialTick)) > 0.0F ? -1.0F : 1.0F;
 | |
| 			Vector3f vector3f = new Vector3f(j, 0.0F, 0.0F);
 | |
| 			float k = camera.getLookVector().dot(vector3f);
 | |
| 			if (k > 0.0F && level.effects().isSunriseOrSunset(level.getTimeOfDay(partialTick))) {
 | |
| 				int l = level.effects().getSunriseOrSunsetColor(level.getTimeOfDay(partialTick));
 | |
| 				k *= ARGB.alphaFloat(l);
 | |
| 				g = Mth.lerp(k, g, ARGB.redFloat(l));
 | |
| 				h = Mth.lerp(k, h, ARGB.greenFloat(l));
 | |
| 				i = Mth.lerp(k, i, ARGB.blueFloat(l));
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		int m = level.getSkyColor(camera.getPosition(), partialTick);
 | |
| 		float n = ARGB.redFloat(m);
 | |
| 		float k = ARGB.greenFloat(m);
 | |
| 		float o = ARGB.blueFloat(m);
 | |
| 		float p = 0.25F + 0.75F * renderDistance / 32.0F;
 | |
| 		p = 1.0F - (float)Math.pow(p, 0.25);
 | |
| 		g += (n - g) * p;
 | |
| 		h += (k - h) * p;
 | |
| 		i += (o - i) * p;
 | |
| 		float q = level.getRainLevel(partialTick);
 | |
| 		if (q > 0.0F) {
 | |
| 			float r = 1.0F - q * 0.5F;
 | |
| 			float s = 1.0F - q * 0.4F;
 | |
| 			g *= r;
 | |
| 			h *= r;
 | |
| 			i *= s;
 | |
| 		}
 | |
| 
 | |
| 		float r = level.getThunderLevel(partialTick);
 | |
| 		if (r > 0.0F) {
 | |
| 			float s = 1.0F - r * 0.5F;
 | |
| 			g *= s;
 | |
| 			h *= s;
 | |
| 			i *= s;
 | |
| 		}
 | |
| 
 | |
| 		return ARGB.colorFromFloat(1.0F, g, h, i);
 | |
| 	}
 | |
| }
 |