-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9247aac
commit cd19f42
Showing
6 changed files
with
38 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 8 additions & 9 deletions
17
src/main/java/net/permutated/flickerfix/mixin/MixinGameRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
package net.permutated.flickerfix.mixin; | ||
|
||
import net.permutated.flickerfix.FlickerFix; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.effect.MobEffects; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.permutated.flickerfix.FlickerFix; | ||
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; | ||
|
||
import java.util.Optional; | ||
|
||
@SuppressWarnings({"java:S1118", "java:S1610"}) | ||
@SuppressWarnings("java:S1118") | ||
@Mixin(GameRenderer.class) | ||
public abstract class MixinGameRenderer { | ||
|
||
@Inject(method = "getNightVisionScale", at = @At("HEAD"), cancellable = true) | ||
private static void getNightVisionScale(LivingEntity livingEntityIn, float entitylivingbaseIn, CallbackInfoReturnable<Float> cir) { | ||
int i = Optional.ofNullable(livingEntityIn.getEffect(MobEffects.NIGHT_VISION)) | ||
.map(MobEffectInstance::getDuration).orElse(0); | ||
|
||
cir.setReturnValue(i > FlickerFix.fadeTicks ? FlickerFix.brightness : i * FlickerFix.fadeRate); | ||
MobEffectInstance instance = livingEntityIn.getEffect(MobEffects.NIGHT_VISION); | ||
if (instance != null && !instance.isInfiniteDuration()) { | ||
int i = instance.getDuration(); | ||
cir.setReturnValue(i > FlickerFix.fadeTicks ? FlickerFix.brightness : i * FlickerFix.fadeRate); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters