Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better night vision #10

Merged
merged 2 commits into from
Feb 28, 2024
Merged
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
15 changes: 15 additions & 0 deletions src/main/java/club/sk1er/patcher/config/PatcherConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ public class PatcherConfig extends Config {
)
public static boolean smartFullbright = true;

@Switch(
name = "Disable Night Vision",
description = "Completely disables the effects of night vision.",
category = "Miscellaneous", subcategory = "Overlays"
)
public static boolean disableNightVision = false;

@Switch(
name = "Cleaner Night Vision",
description = "Makes the night vision effect fade out instead of a flashing effect.",
category = "Miscellaneous", subcategory = "Overlays"
)
public static boolean cleanerNightVision = false;

@Switch(
name = "Nausea Effect",
description = "Remove the nether portal effect appearing when clearing nausea.",
Expand Down Expand Up @@ -1417,6 +1431,7 @@ public PatcherConfig() {

try {
addDependency("smartFullbright", "fullbright");
addDependency("cleanerNightVision", "disableNightVision", () -> !disableNightVision);
addDependency("unfocusedFPSAmount", "unfocusedFPS");
addDependency("instantFullscreen", "windowedFullscreen");
addDependency("consecutiveCompactChat", "compactChat");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package club.sk1er.patcher.mixins.features;

import club.sk1er.patcher.config.PatcherConfig;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.Potion;
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.CallbackInfoReturnable;

@Mixin(EntityRenderer.class)
public class EntityRendererMixin_NightVisionEffect {
@Inject(method = "getNightVisionBrightness", at = @At("HEAD"), cancellable = true)
private void cleanerNightVision(EntityLivingBase entitylivingbaseIn, float partialTicks, CallbackInfoReturnable<Float> cir) {
if (PatcherConfig.disableNightVision) {
cir.setReturnValue(0F);
return; // let's avoid checking for cleaner night vision if we're going to disable night vision anyway
}
if (PatcherConfig.cleanerNightVision) cir.setReturnValue(!(entitylivingbaseIn.getActivePotionEffect(Potion.nightVision).getDuration() < 200) ? 1.0F : (float) entitylivingbaseIn.getActivePotionEffect(Potion.nightVision).getDuration() / 200F);
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"features.EntityPlayerSPMixin_NauseaEffect",
"features.EntityRendererMixin_CameraPerspective",
"features.EntityRendererMixin_NametagBackground",
"features.EntityRendererMixin_NightVisionEffect",
"features.EntityRendererMixin_ParallaxFix",
"features.EntityRendererMixin_ShadowedNametags",
"features.EntityRendererMixin_ViewBobbing",
Expand Down
Loading