Artifacts

Artifacts

31M Downloads

[1.21.1] Permanent night vision blocks other items and /effect command from giving infinite night vision

kwpugh opened this issue ยท 7 comments

commented

I have an item that provides infinite night vision that can be toggled on/off. With Artifacts present, the icon for night vision is displayed but the visual is not changed. Also, using the /effect vanilla command for infinite duration shows the icon and particles but the visual does not change. The night vision potion does work.
My mod is Gobber and the item is the Ring of Vision
This is on NeoForge. I will also try fabric.

To Reproduce
Steps to reproduce the behavior:

  1. go into game and use the /effect give command for night vision with infinite duration
  2. screen does not change

Game Environment
Please provide details about the game environment, either by crash report/logs or by detailing it below. Try to reproduce the issue without irrelevant mods first. Otherwise, include a complete list of mods or the name and version of the modpack you're using.

  • Artifacts: [12.0.4]
  • Forge/Fabric Api: [21.1.8]
  • [Gobber 2.10.13]
commented

Goggles Night Vision vs full vanilla effect, is this intentional?

2024-08-12_10 28 58
2024-08-12_10 29 15

commented

[UPDATE]

I tried on fabric and it does the same thing.
I also noticed that the goggles give night vision duration of 00:01, which makes it very dim. That is why I switched my item to infinite to get full effect and avoid and flicker/fade.

commented

In case this is helpful, my infinite night vision is controlled by a utility class and a mixin to player tick

https://gist.github.com/kwpugh/4ef03585a0b681387aa0fa0eed424e79
https://gist.github.com/kwpugh/d6902d722afd95b9285962cdd0fbb4af

commented

I think the problem is in your GameRendererMixin class.

commented

the original method you mixin to
public static float getNightVisionScale(LivingEntity livingEntity, float nanoTime) { MobEffectInstance mobeffectinstance = livingEntity.getEffect(MobEffects.NIGHT_VISION); return !mobeffectinstance.endsWithin(200) ? 1.0F : 0.7F + Mth.sin(((float)mobeffectinstance.getDuration() - nanoTime) * (float) Math.PI * 0.2F) * 0.3F; }

calls endsWinthin()
public boolean endsWithin(int duration) { return !this.isInfiniteDuration() && this.duration <= duration; }

which checks for infinite effect
public boolean isInfiniteDuration() { return this.duration == -1; }

which has a value of -1.

Since your mixin overrides the original value coming from getNightVisionScale() and I don't think it cover a -1 value in the conditionals.

If I'm understanding the code correctly.

commented

Thanks for the detailed report!
You're correct in that I didn't take into account that infinite effects have a negative duration. I've uploaded a patch to fix this issue.

commented

Thank you.