Skip to content

Commit

Permalink
Fix requested changes and switch playerMood to camera entity
Browse files Browse the repository at this point in the history
  • Loading branch information
OverlordsIII committed Feb 7, 2021
1 parent 3bc5343 commit 41cc7fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.coderbot.iris.texunits.TextureUnit;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
Expand Down Expand Up @@ -51,6 +52,7 @@ public static void addCommonUniforms(UniformHolder uniforms, IdMap idMap) {
.uniform1i(PER_FRAME, "heldBlockLightValue", new HeldItemLightingSupplier(Hand.MAIN_HAND))
.uniform1i(PER_FRAME, "heldBlockLightValue2", new HeldItemLightingSupplier(Hand.OFF_HAND))
.uniform1f(PER_FRAME, "nightVision", CommonUniforms::getNightVision)
.uniform1f(PER_FRAME, "screenBrightness", () -> client.options.gamma)
.uniform1f(PER_TICK, "playerMood", CommonUniforms::getPlayerMood);;
}

Expand All @@ -71,10 +73,11 @@ private static float getBlindness() {
}

private static float getPlayerMood() {
if (client.player == null) {
if (!(client.cameraEntity instanceof ClientPlayerEntity)) {
return 0.0F;
}
return client.player.getMoodPercentage();

return ((ClientPlayerEntity)client.cameraEntity).getMoodPercentage();
}

private static float getNightVision() {
Expand All @@ -85,9 +88,11 @@ private static float getNightVision() {
LivingEntity livingEntity = (LivingEntity) cameraEntity;

if (livingEntity.getStatusEffect(StatusEffects.NIGHT_VISION) != null) {

return GameRenderer.getNightVisionStrength(livingEntity, CapturedRenderingState.INSTANCE.getTickDelta());
}
}

return 0.0F;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public static void addViewportUniforms(UniformHolder uniforms) {
uniforms
.uniform1f(PER_FRAME, "viewHeight", WINDOW::getHeight)
.uniform1f(PER_FRAME, "viewWidth", WINDOW::getWidth)
.uniform1f(PER_FRAME, "aspectRatio", ViewportUniforms::getAspectRatio)
.uniform1f(PER_FRAME, "screenBrightness", () -> client.options.gamma);
.uniform1f(PER_FRAME, "aspectRatio", ViewportUniforms::getAspectRatio);
}

/**
Expand Down

0 comments on commit 41cc7fe

Please sign in to comment.