Skip to content

Commit

Permalink
Merge pull request #10 from MicrocontrollersDev/night-vision
Browse files Browse the repository at this point in the history
better night vision
  • Loading branch information
ImToggle authored Feb 28, 2024
2 parents 429dffa + 7f77ff5 commit 92609f1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
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

0 comments on commit 92609f1

Please sign in to comment.