Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fuzs.aquaacrobatics.entity.player.IPlayerResizeable;
import com.fuzs.aquaacrobatics.proxy.CommonProxy;
import com.fuzs.aquaacrobatics.util.math.MathHelperNew;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.MobEffects;
Expand Down Expand Up @@ -71,6 +72,17 @@ public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @N

@SubscribeEvent
public void onRenderFogDensity(EntityViewRenderEvent.FogDensity event) {
switch (ConfigHandler.BlocksConfig.waterFogMode) {
case AA_EXP2:
handleExp2Fog(event);
break;
case VANILLA_LINEAR:
handleLinearFog(event);
break;
}
}

private void handleExp2Fog(EntityViewRenderEvent.FogDensity event) {
Entity eventEntity = event.getEntity();
if(eventEntity instanceof EntityLivingBase && ((EntityLivingBase)eventEntity).isPotionActive(MobEffects.BLINDNESS))
return;
Expand All @@ -91,6 +103,39 @@ public void onRenderFogDensity(EntityViewRenderEvent.FogDensity event) {
}
}

// Based on Minecraft 1.21.7
static final float FOG_END = 96.0F;
static final float FOG_START = -8.0F;
private void handleLinearFog(EntityViewRenderEvent.FogDensity event) {
Entity eventEntity = event.getEntity();
if (eventEntity instanceof EntityLivingBase && ((EntityLivingBase) eventEntity).isPotionActive(MobEffects.BLINDNESS)) {
return;
}

if (event.getState().getMaterial() == Material.WATER && !shouldSkipFogOverride(eventEntity.getEntityWorld())) {
GlStateManager.setFog(GlStateManager.FogMode.LINEAR);

float renderDistanceInBlocks = Minecraft.getMinecraft().gameSettings.renderDistanceChunks * 16.0f;
float fogEnd = Math.min(renderDistanceInBlocks, FOG_END);

if (eventEntity instanceof EntityPlayer) {
EntityPlayer playerEntity = (EntityPlayer) eventEntity;
float waterVision = ((IPlayerResizeable) playerEntity).getWaterVision();
fogEnd *= Math.max(0.25F, waterVision);
Biome biome = playerEntity.world.getBiome(playerEntity.getPosition());
if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.SWAMP)) {
fogEnd *= 0.85F;
}
}

GlStateManager.setFogStart(FOG_START);
GlStateManager.setFogEnd(fogEnd);
event.setCanceled(true);
}
}



/* LOW to override mods like Biomes O' Plenty which force their own underwater fog color */
@SubscribeEvent(priority = EventPriority.LOW)
public void onRenderFogColor(EntityViewRenderEvent.FogColors event) {
Expand Down Expand Up @@ -135,7 +180,7 @@ public void onRenderFogColor(EntityViewRenderEvent.FogColors event) {
if (playerEntity.isPotionActive(MobEffects.BLINDNESS)) {
int potionDuration = playerEntity.getActivePotionEffect(MobEffects.BLINDNESS).getDuration();
if (potionDuration < 20) {
blindnessFactor *= (1.0F - (float)i / 20.0F);
blindnessFactor *= (1.0F - (float)potionDuration / 20.0F);
} else {
blindnessFactor = 0.0D;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public static class BlocksConfig {
@Config.Name("New Water Fog")
@Config.Comment("Use the new fog rendering in 1.13+.")
public static boolean newWaterFog = true;

@Config.Name("New Water Fog Render Mode")
@Config.Comment("Water fog render mode, available options: AA_EXP2, VANILLA_LINEAR")
public static WaterFogMode waterFogMode = WaterFogMode.AA_EXP2;
}

public static class MiscellaneousConfig {
Expand Down Expand Up @@ -205,4 +209,8 @@ public enum PlayerBlockCollisions {
STANDARD, APPROXIMATE, EXACT
}

public enum WaterFogMode {
AA_EXP2, VANILLA_LINEAR
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fuzs.aquaacrobatics.AquaAcrobatics;
import com.fuzs.aquaacrobatics.client.handler.NoMixinHandler;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.FMLCommonHandler;
Expand Down Expand Up @@ -38,13 +37,15 @@ public class AquaAcrobaticsCore implements IFMLLoadingPlugin {
private static boolean isScreenRegistered;

/* Config options */
public static boolean disableBlockUpdateMixins;
public static boolean disableBlockUpdateMixins;
public static boolean enableSkyBoxHeightOverwrite;

public AquaAcrobaticsCore() {
SELF = this;
Configuration config = new Configuration(new File("config", "aquaacrobatics_core.cfg"));
config.load();
disableBlockUpdateMixins = config.getBoolean("DisableBlockUpdateMixins", "hacks", false, "TickCentral has a buggy ASM transformer - this will disable these mixins from being applied. Make sure bubble columns are disabled if you use this.");
enableSkyBoxHeightOverwrite = config.getBoolean("EnableSkyBoxHeightOverwrite", "hacks", false, "Enable overwriting skybox renderer height, vanilla one may cause weird black edges near the chunk border.");
config.save();

isFgDev = "true".equals(System.getProperty("aquaacrobatics.fghack"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
}
}

if (mixinClassName.equals("com.fuzs.aquaacrobatics.core.mixin.client.RenderGlobalMixin")) {
if (!AquaAcrobaticsCore.enableSkyBoxHeightOverwrite) {
return false;
}
AquaAcrobaticsCore.LOGGER.error("Overwriting vanilla skybox height as requested in config.");
return true;
}

if(mixinClassName.equals("com.fuzs.aquaacrobatics.core.mixin.client.BlockAliasesBubbleColumnMixin")) {
return doesClassExist("optifine.OptiFineForgeTweaker");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.fuzs.aquaacrobatics.core.mixin.client;

import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.RenderGlobal;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(RenderGlobal.class)
public abstract class RenderGlobalMixin {
@Redirect(
method = "renderSky(FI)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/multiplayer/WorldClient;getHorizon()D"
)
)
public double getHorizon(WorldClient instance) {
return 0.0D;
}
}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/mixins.aquaacrobatics.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"client.ModelBipedMixin",
"client.ModelFluidMixin",
"client.RenderBoatMixin",
"client.RenderGlobalMixin",
"client.RenderPlayerMixin",
"client.PlayerControllerMPMixin"
],
Expand Down