forked from RepoMirrors/kami-blue
Merge pull request #5 from wine/master
Make brightness use potion effect
This commit is contained in:
commit
d24cbc8067
|
@ -3,20 +3,19 @@ package me.zeroeightsix.kami.mixin.client;
|
|||
import me.zeroeightsix.kami.module.ModuleManager;
|
||||
import me.zeroeightsix.kami.module.modules.render.AntiFog;
|
||||
import me.zeroeightsix.kami.module.modules.render.NoHurtCam;
|
||||
import me.zeroeightsix.kami.util.Wrapper;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
@ -28,7 +27,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
@Mixin(EntityRenderer.class)
|
||||
public class MixinEntityRenderer {
|
||||
|
||||
Minecraft mc = Wrapper.getMinecraft();
|
||||
private boolean nightVision = false;
|
||||
|
||||
@Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;rayTraceBlocks(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/RayTraceResult;"))
|
||||
public RayTraceResult rayTraceBlocks(WorldClient world, Vec3d start, Vec3d end) {
|
||||
|
@ -55,4 +54,15 @@ public class MixinEntityRenderer {
|
|||
if (NoHurtCam.shouldDisable()) info.cancel();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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;
|
||||
return renderer.getNightVisionBrightness(entity, partialTicks);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,33 +1,14 @@
|
|||
package me.zeroeightsix.kami.module.modules.render;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
|
||||
/**
|
||||
* Created by 086 on 12/12/2017.
|
||||
* @see me.zeroeightsix.kami.mixin.client.MixinEntityRenderer
|
||||
*/
|
||||
@Module.Info(name = "Brightness", description = "Makes everything brighter!", category = Module.Category.RENDER)
|
||||
public class Brightness extends Module {
|
||||
|
||||
@Setting(name = "Brightness")
|
||||
public float brightness = 16;
|
||||
|
||||
@Setting(name = "prev_brightness", hidden = true)
|
||||
public float prevBrightness = 1;
|
||||
|
||||
@Override
|
||||
protected void onEnable() {
|
||||
prevBrightness = mc.gameSettings.gammaSetting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
mc.gameSettings.gammaSetting = brightness;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
mc.gameSettings.gammaSetting = prevBrightness;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue