This commit is contained in:
gnembon committed 2025-10-16 16:27:50 +02:00
1 parent 005faee612
commit 0b2ffaca95
3 files changed
+17 -10

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ org.gradle.configuration-cache=false
# Fabric Properties
# check https://fabricmc.net/develop/
minecraft_version=25w41a
minecraft_version=25w42a
loader_version=0.17.3
jsr305_version=3.0.2
fabric_version=0.134.0+1.21.9
@@ -1,10 +1,10 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.client.renderer.DimensionSpecialEffects;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
//import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.attribute.EnvironmentAttribute;
import net.minecraft.world.attribute.EnvironmentAttributeProbe;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -14,12 +14,12 @@ public class LevelRenderer_fogOffMixin
{
@Redirect(method = "renderLevel", require = 0, expect = 0, at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/DimensionSpecialEffects;isFoggyAt(II)Z"
target = "Lnet/minecraft/world/attribute/EnvironmentAttributeProbe;getValue(Lnet/minecraft/world/attribute/EnvironmentAttribute;F)Ljava/lang/Object;"
))
private boolean isReallyThick(DimensionSpecialEffects skyProperties, int x, int z)
private <Value> Value isReallyThick(EnvironmentAttributeProbe instance, EnvironmentAttribute<Value> environmentAttribute, float f)
{
if (CarpetSettings.fogOff) return false;
return skyProperties.isFoggyAt(x, z);
if (CarpetSettings.fogOff) return (Value) Boolean.FALSE;
return instance.getValue(environmentAttribute, f);
}
}
@@ -16,6 +16,8 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.attribute.EnvironmentAttribute;
import net.minecraft.world.attribute.EnvironmentAttributes;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
@@ -25,11 +27,12 @@ public class BiomeInfo
{{
put("tags", (w, b) -> ListValue.wrap(w.registryAccess().lookupOrThrow(Registries.BIOME).getTags().filter(p -> p.stream().anyMatch(h -> h.value() == b)).map(ValueConversions::of)));
put("temperature", (w, b) -> NumericValue.of(b.getBaseTemperature()));
put("fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFogColor()));
// todo add per postion query for environmental attributes as well
put("fog_color", (w, b) -> fromEnvironmentalAttribute(w, b, EnvironmentAttributes.FOG_COLOR));
put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFoliageColorOverride().orElse(4764952))); // client Biome.getDefaultFoliageColor
put("sky_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getSkyColor()));
put("sky_color", (w, b) -> fromEnvironmentalAttribute(w, b, EnvironmentAttributes.SKY_COLOR));
put("water_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterColor()));
put("water_fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getWaterFogColor()));
put("water_fog_color", (w, b) -> fromEnvironmentalAttribute(w, b, EnvironmentAttributes.WATER_FOG_COLOR));
put("humidity", (w, b) -> NumericValue.of(Vanilla.Biome_getClimateSettings(b).downfall()));
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0), w.getSeaLevel()).name().toLowerCase(Locale.ROOT)));
put("features", (w, b) -> {
@@ -43,4 +46,8 @@ public class BiomeInfo
);
});
}};
private static Value fromEnvironmentalAttribute(ServerLevel w, Biome b, EnvironmentAttribute<Integer> fogColor) {
return ValueConversions.ofRGB(b.getAttributes().applyModifier(fogColor, w.dimensionType().attributes().applyModifier(fogColor, fogColor.defaultValue())));
}
}