Remove unneccessary injection

This commit is contained in:
Sollace 2024-10-02 23:32:27 +01:00
parent 68820924bf
commit 5a900e8601
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 12 additions and 25 deletions

View file

@ -3,9 +3,9 @@ package com.minelittlepony.unicopia.client;
import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.EquinePredicates;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
public class BatEyesApplicator { public class BatEyesApplicator {
@ -15,11 +15,17 @@ public class BatEyesApplicator {
private final MinecraftClient client = MinecraftClient.getInstance(); private final MinecraftClient client = MinecraftClient.getInstance();
public float getWorldBrightness(float initial, LivingEntity entity, float tickDelta) {
if (!EquinePredicates.PLAYER_BAT.test(entity)) {
return initial;
}
return 0.6F;
}
public void enable() { public void enable() {
if (client.world != null) { if (client.world != null && client.player != null) {
PlayerEntity player = client.player; if (!client.player.hasStatusEffect(StatusEffects.NIGHT_VISION) && EquinePredicates.PLAYER_BAT.test(client.player)) {
if (!player.hasStatusEffect(StatusEffects.NIGHT_VISION) && EquinePredicates.PLAYER_BAT.test(player)) { client.player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, -1, 1, false, false));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 1, 1, false, false));
batEyesApplied = true; batEyesApplied = true;
} }
} }

View file

@ -53,9 +53,6 @@ public class UnicopiaClient implements ClientModInitializer {
return Pony.of(MinecraftClient.getInstance().player); return Pony.of(MinecraftClient.getInstance().player);
} }
private final Lerp rainGradient = new Lerp(0);
private final Lerp thunderGradient = new Lerp(0);
public final Lerp tangentalSkyAngle = new Lerp(0, true); public final Lerp tangentalSkyAngle = new Lerp(0, true);
public final Lerp skyAngle = new Lerp(0, true); public final Lerp skyAngle = new Lerp(0, true);
@ -103,10 +100,6 @@ public class UnicopiaClient implements ClientModInitializer {
return Unicopia.getConfig().preferredRace.get(); return Unicopia.getConfig().preferredRace.get();
} }
public static float getWorldBrightness(float initial) {
return 0.6F;
}
public UnicopiaClient() { public UnicopiaClient() {
instance = this; instance = this;
} }

View file

@ -6,7 +6,6 @@ import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.client.BatEyesApplicator; import com.minelittlepony.unicopia.client.BatEyesApplicator;
import com.minelittlepony.unicopia.client.UnicopiaClient; import com.minelittlepony.unicopia.client.UnicopiaClient;
import com.minelittlepony.unicopia.client.render.shader.ViewportShader; import com.minelittlepony.unicopia.client.render.shader.ViewportShader;
@ -17,7 +16,6 @@ import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.RotationAxis; import net.minecraft.util.math.RotationAxis;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.resource.SynchronousResourceReloader; import net.minecraft.resource.SynchronousResourceReloader;
@Mixin(value = GameRenderer.class, priority = Integer.MAX_VALUE) @Mixin(value = GameRenderer.class, priority = Integer.MAX_VALUE)
@ -46,21 +44,11 @@ abstract class MixinGameRenderer implements AutoCloseable, SynchronousResourceRe
BatEyesApplicator.INSTANCE.disable(); BatEyesApplicator.INSTANCE.disable();
} }
@Inject(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F",
at = @At("HEAD"),
cancellable = true)
private static void onGetNightVisionStrengthHead(LivingEntity entity, float tickDelta, CallbackInfoReturnable<Float> info) {
if (!entity.hasStatusEffect(StatusEffects.NIGHT_VISION)) {
info.setReturnValue(UnicopiaClient.getWorldBrightness(0));
}
}
@Inject(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F", @Inject(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F",
at = @At("RETURN"), at = @At("RETURN"),
cancellable = true) cancellable = true)
private static void onGetNightVisionStrengthReturn(LivingEntity entity, float tickDelta, CallbackInfoReturnable<Float> info) { private static void onGetNightVisionStrengthReturn(LivingEntity entity, float tickDelta, CallbackInfoReturnable<Float> info) {
if (entity.hasStatusEffect(StatusEffects.NIGHT_VISION) && EquinePredicates.PLAYER_BAT.test(entity)) { info.setReturnValue(BatEyesApplicator.INSTANCE.getWorldBrightness(info.getReturnValueF(), entity, tickDelta));
info.setReturnValue(UnicopiaClient.getWorldBrightness(info.getReturnValueF()));
}
} }
@Inject(method = "render", @Inject(method = "render",