forked from IrisShaders/Iris
-
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.
Fix incompatibility with Night Vision Flash Be Gone
This was caused by the origins night vision effect compatibility code. Fixes IrisShaders#1115
- Loading branch information
1 parent
f615e21
commit 812954b
Showing
4 changed files
with
48 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
29 changes: 29 additions & 0 deletions
29
src/main/java/net/coderbot/iris/mixin/MixinGameRenderer_NightVisionCompat.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.coderbot.iris.mixin; | ||
|
||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.world.effect.MobEffects; | ||
import net.minecraft.world.entity.LivingEntity; | ||
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; | ||
|
||
// Priority of 1010 (> 1000) to run after other mod mixins. In particular, Night Vision Flash Be Gone overwrites this | ||
// method, so we need to run after it so that our injection silently fails instead of crashing the game. | ||
@Mixin(value = GameRenderer.class, priority = 1010) | ||
public class MixinGameRenderer_NightVisionCompat { | ||
// Origins compatibility: Allows us to call getNightVisionScale even if the entity does not have night vision. | ||
// This injection gives a chance for mods injecting at HEAD to return a modified night vision value. | ||
// | ||
// It's optional because of Night Vision Flash Be Gone overwriting this method, but having this injection | ||
// succeed avoids a lot of spurious (but silently caught) NullPointerExceptions. | ||
@Inject(method = "getNightVisionScale", at = @At(value = "INVOKE", | ||
target = "Lnet/minecraft/world/effect/MobEffectInstance;getDuration()I"), cancellable = true, | ||
require = 0) | ||
private static void iris$safecheckNightvisionStrength(LivingEntity livingEntity, float partialTicks, | ||
CallbackInfoReturnable<Float> cir){ | ||
if (livingEntity.getEffect(MobEffects.NIGHT_VISION) == null) { | ||
cir.setReturnValue(0.0f); | ||
} | ||
} | ||
} |
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