Skip to content

Commit

Permalink
Option to increase fog radius when in the Crimson Isles (#856)
Browse files Browse the repository at this point in the history
* Add option to increase fog radius when in the Crimson Isles
  • Loading branch information
IBeHunting authored Jul 29, 2024
1 parent 9625ea4 commit 5ed3e88
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.build())
.build())

// Extend nether fog
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.crimsonIsle.extendNetherFog"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.crimsonIsle.extendNetherFog.@Tooltip")))
.binding(config.crimsonIsle.extendNetherFog,
() -> config.crimsonIsle.extendNetherFog,
newValue -> config.crimsonIsle.extendNetherFog = newValue)
.controller(ConfigUtils::createBooleanController)
.build())

.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class CrimsonIsleConfig {
@SerialEntry
public Dojo dojo = new Dojo();

@SerialEntry
public boolean extendNetherFog = true;


public static class Kuudra {
@SerialEntry
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package de.hysky.skyblocker.mixins;

import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.systems.RenderSystem;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.config.configs.CrimsonIsleConfig;
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.block.enums.CameraSubmersionType;
import net.minecraft.client.render.BackgroundRenderer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.FogShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(BackgroundRenderer.class)
public abstract class BackgroundRendererMixin {

/**
* Moves fog farther away from the player when in the crimson isles.
* This sets it to be the same distance as what you would see in the overworld (every other skyblock island)
*/
@Inject(method = "applyFog", at = @At("RETURN"))
private static void applyFogModifyDistance(CallbackInfo ci, @Local(argsOnly = true) Camera camera, @Local(argsOnly = true) BackgroundRenderer.FogType fogType, @Local(argsOnly = true, ordinal = 0) float viewDistance, @Local(argsOnly = true) boolean thickFog) {
final CameraSubmersionType cameraSubmersionType = camera.getSubmersionType();
CrimsonIsleConfig config = SkyblockerConfigManager.get().crimsonIsle;

if (Utils.isOnSkyblock() && config.extendNetherFog && cameraSubmersionType == CameraSubmersionType.NONE && thickFog) {
float start;
if (fogType == BackgroundRenderer.FogType.FOG_SKY) {
start = 0.0f;
} else {
start = viewDistance - Math.clamp(viewDistance / 10.0f, 4.0f, 64.0f);
}

RenderSystem.setShaderFogStart(start);
RenderSystem.setShaderFogEnd(viewDistance);
RenderSystem.setShaderFogShape(FogShape.CYLINDER);
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

"skyblocker.config.crimsonIsle": "Crimson Isle",

"skyblocker.config.crimsonIsle.extendNetherFog": "Extend Nether Fog",
"skyblocker.config.crimsonIsle.extendNetherFog.@Tooltip": "When in the Crimson Isle, prevents fog from appearing closer to the player as it does in vanilla nether biomes.",

"skyblocker.config.crimsonIsle.kuudra": "Kuudra",

"skyblocker.config.crimsonIsle.kuudra.arrowPoisonThreshold": "Arrow Poison Warning Threshold",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/skyblocker.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_21",
"client": [
"AbstractInventoryScreenMixin",
"BackgroundRendererMixin",
"BatEntityMixin",
"ClientPlayerEntityMixin",
"ClientPlayNetworkHandlerMixin",
Expand Down

0 comments on commit 5ed3e88

Please sign in to comment.