mirror of
https://github.com/kami-blue/client
synced 2025-02-21 15:56:50 +00:00
parent
5ebd120fa4
commit
8ec2522062
@ -4,6 +4,7 @@ import com.google.common.base.Predicate;
|
||||
import me.zeroeightsix.kami.module.ModuleManager;
|
||||
import me.zeroeightsix.kami.module.modules.misc.NoEntityTrace;
|
||||
import me.zeroeightsix.kami.module.modules.render.AntiFog;
|
||||
import me.zeroeightsix.kami.module.modules.render.Brightness;
|
||||
import me.zeroeightsix.kami.module.modules.render.NoHurtCam;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
@ -62,12 +63,12 @@ public class MixinEntityRenderer {
|
||||
|
||||
@Redirect(method = "updateLightmap", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;isPotionActive(Lnet/minecraft/potion/Potion;)Z"))
|
||||
public boolean isPotionActive(EntityPlayerSP player, Potion potion) {
|
||||
return (nightVision = ModuleManager.isModuleEnabled("Brightness")) || player.isPotionActive(potion);
|
||||
return (nightVision = Brightness.shouldBeActive()) || player.isPotionActive(potion);
|
||||
}
|
||||
|
||||
@Redirect(method = "updateLightmap", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/EntityRenderer;getNightVisionBrightness(Lnet/minecraft/entity/EntityLivingBase;F)F"))
|
||||
public float getNightVisionBrightnessMixin(EntityRenderer renderer, EntityLivingBase entity, float partialTicks) {
|
||||
if (nightVision) return 1;
|
||||
if (nightVision) return Brightness.getCurrentBrightness();
|
||||
return renderer.getNightVisionBrightness(entity, partialTicks);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,16 @@
|
||||
package me.zeroeightsix.kami.module.modules.render;
|
||||
|
||||
import me.zeroeightsix.kami.command.Command;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import scala.actors.threadpool.Arrays;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Created by 086 on 12/12/2017.
|
||||
@ -9,4 +19,99 @@ import me.zeroeightsix.kami.module.Module;
|
||||
@Module.Info(name = "Brightness", description = "Makes everything brighter!", category = Module.Category.RENDER)
|
||||
public class Brightness extends Module {
|
||||
|
||||
Setting<Boolean> transition = register(Settings.b("Transition", true));
|
||||
Setting<Float> seconds = register(Settings.floatBuilder("Seconds").withMinimum(0f).withMaximum(10f).withValue(1f).withVisibility(o -> transition.getValue()).build());
|
||||
Setting<Transition> mode = register(Settings.enumBuilder(Transition.class).withName("Mode").withValue(Transition.SINE).withVisibility(o -> transition.getValue()).build());
|
||||
|
||||
Stack<Float> transitionStack = new Stack<>();
|
||||
|
||||
private static float currentBrightness = 0;
|
||||
private static boolean inTransition = false;
|
||||
|
||||
private void addTransition(boolean isUpwards) {
|
||||
if (transition.getValue()) {
|
||||
int length = (int) (seconds.getValue() * 20);
|
||||
float[] values;
|
||||
switch (mode.getValue()) {
|
||||
case LINEAR:
|
||||
values = linear(length, isUpwards);
|
||||
break;
|
||||
case SINE:
|
||||
values = sine(length, isUpwards);
|
||||
break;
|
||||
default:
|
||||
values = new float[]{0};
|
||||
}
|
||||
for (float v : values) {
|
||||
transitionStack.add(v);
|
||||
}
|
||||
|
||||
inTransition = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnable() {
|
||||
super.onEnable();
|
||||
addTransition(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
setAlwaysListening(true);
|
||||
super.onDisable();
|
||||
addTransition(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (inTransition) {
|
||||
if (transitionStack.isEmpty()) {
|
||||
inTransition = false;
|
||||
setAlwaysListening(false);
|
||||
currentBrightness = isEnabled() ? 1 : 0;
|
||||
} else {
|
||||
currentBrightness = transitionStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float[] createTransition(int length, boolean upwards, Function<Float, Float> function) {
|
||||
float[] transition = new float[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
float v = function.apply(((float) i / (float) length));
|
||||
if (upwards) v = 1 - v;
|
||||
transition[i] = v;
|
||||
}
|
||||
return transition;
|
||||
}
|
||||
|
||||
private float[] linear(int length, boolean polarity) { // length of 20 = 1 second
|
||||
return createTransition(length, polarity, d -> d);
|
||||
}
|
||||
|
||||
private float sine(float x) { // (sin(pi*x-(pi/2)) + 1) / 2
|
||||
return ((float) Math.sin(Math.PI * x - Math.PI / 2) + 1) / 2;
|
||||
}
|
||||
|
||||
private float[] sine(int length, boolean polarity) {
|
||||
return createTransition(length, polarity, this::sine);
|
||||
}
|
||||
|
||||
public static float getCurrentBrightness() {
|
||||
return currentBrightness;
|
||||
}
|
||||
|
||||
public static boolean isInTransition() {
|
||||
return inTransition;
|
||||
}
|
||||
|
||||
public static boolean shouldBeActive() {
|
||||
return isInTransition() || currentBrightness == 1; // if in transition or enabled
|
||||
}
|
||||
|
||||
public enum Transition {
|
||||
LINEAR, SINE;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user