mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Fixed batponies' vision giving strange results on higher brightness settings
This commit is contained in:
parent
abe8142482
commit
26b0f3567e
5 changed files with 45 additions and 49 deletions
|
@ -0,0 +1,35 @@
|
||||||
|
package com.minelittlepony.unicopia.client;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.EquinePredicates;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
|
public class BatEyesApplicator {
|
||||||
|
|
||||||
|
public static final BatEyesApplicator INSTANCE = new BatEyesApplicator();
|
||||||
|
|
||||||
|
private boolean batEyesApplied;
|
||||||
|
|
||||||
|
private final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
public void enable() {
|
||||||
|
if (client.world != null) {
|
||||||
|
PlayerEntity player = client.player;
|
||||||
|
if (!player.hasStatusEffect(StatusEffects.NIGHT_VISION) && EquinePredicates.PLAYER_BAT.test(player)) {
|
||||||
|
player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 1, 1, false, false));
|
||||||
|
batEyesApplied = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disable() {
|
||||||
|
if (batEyesApplied) {
|
||||||
|
client.player.removeStatusEffect(StatusEffects.NIGHT_VISION);
|
||||||
|
batEyesApplied = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -52,7 +52,7 @@ public class UnicopiaClient implements ClientModInitializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getWorldBrightness(float initial) {
|
public static float getWorldBrightness(float initial) {
|
||||||
return initial > 0 ? 3 : 2;
|
return 0.6F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,6 +7,7 @@ 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.EquinePredicates;
|
||||||
|
import com.minelittlepony.unicopia.client.BatEyesApplicator;
|
||||||
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
||||||
import net.minecraft.client.render.Camera;
|
import net.minecraft.client.render.Camera;
|
||||||
import net.minecraft.client.render.GameRenderer;
|
import net.minecraft.client.render.GameRenderer;
|
||||||
|
@ -27,8 +28,15 @@ abstract class MixinGameRenderer implements AutoCloseable, SynchronousResourceRe
|
||||||
|
|
||||||
@Inject(method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V",
|
@Inject(method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V",
|
||||||
at = @At("HEAD"))
|
at = @At("HEAD"))
|
||||||
private void onRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
private void beforeRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
||||||
UnicopiaClient.getCamera().ifPresent(c -> matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(c.calculateRoll())));
|
UnicopiaClient.getCamera().ifPresent(c -> matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(c.calculateRoll())));
|
||||||
|
BatEyesApplicator.INSTANCE.enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V",
|
||||||
|
at = @At("RETURN"))
|
||||||
|
private void afterRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
||||||
|
BatEyesApplicator.INSTANCE.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F",
|
@Inject(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F",
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.mixin.client;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.EquinePredicates;
|
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.client.render.LightmapTextureManager;
|
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
|
|
||||||
@Mixin(value = LightmapTextureManager.class, priority = 999)
|
|
||||||
abstract class MixinLightmapTextureManager implements AutoCloseable {
|
|
||||||
|
|
||||||
private @Shadow boolean dirty;
|
|
||||||
private @Shadow @Final MinecraftClient client;
|
|
||||||
|
|
||||||
private boolean batEyesApplied;
|
|
||||||
|
|
||||||
@ModifyVariable(method = "update(F)V", at = @At(value = "HEAD"), argsOnly = true)
|
|
||||||
private float beforeUpdate(float delta) {
|
|
||||||
if (dirty && client.world != null) {
|
|
||||||
PlayerEntity player = client.player;
|
|
||||||
if (!player.hasStatusEffect(StatusEffects.NIGHT_VISION) && EquinePredicates.PLAYER_BAT.test(player)) {
|
|
||||||
player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 1, 1, false, false));
|
|
||||||
batEyesApplied = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModifyVariable(method = "update(F)V", at = @At(value = "RETURN"), argsOnly = true)
|
|
||||||
private float afterUpdate(float delta) {
|
|
||||||
if (batEyesApplied) {
|
|
||||||
client.player.removeStatusEffect(StatusEffects.NIGHT_VISION);
|
|
||||||
batEyesApplied = false;
|
|
||||||
}
|
|
||||||
return delta;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -41,7 +41,6 @@
|
||||||
"client.MixinItem",
|
"client.MixinItem",
|
||||||
"client.MixinItemModels",
|
"client.MixinItemModels",
|
||||||
"client.MixinKeyboardInput",
|
"client.MixinKeyboardInput",
|
||||||
"client.MixinLightmapTextureManager",
|
|
||||||
"client.MixinLivingEntityRenderer",
|
"client.MixinLivingEntityRenderer",
|
||||||
"client.MixinMouse",
|
"client.MixinMouse",
|
||||||
"client.MixinPlayerEntityRenderer",
|
"client.MixinPlayerEntityRenderer",
|
||||||
|
|
Loading…
Reference in a new issue