Compare commits

..

5 Commits

Author SHA1 Message Date
Markil3
cf4ed2d4af Fixes a conflict with other poorly-configured mods. 2021-04-06 08:42:49 -06:00
Markil3
93767421ee Gets ready for release 1.1 2021-04-01 13:08:56 -06:00
Markil3
96718b2b57 Adds the ability to always show hands and crosshairs.
Apparently, @rflambert doesn't want the hands to fade. It seemed like a good idea, so I added a configurable option to the main repo.
2021-03-26 11:15:55 -06:00
Markil3
e3c0f1d533 Catches any errors that occur when triggering events.
It is pretty annoying for the game to crash because of a GUI mod. This should reduce that.
2021-03-26 10:08:16 -06:00
Markil3
6daf696e01 Fixes a ClassCastException (#1). 2021-03-25 17:09:03 -06:00
10 changed files with 501 additions and 137 deletions

View File

@@ -11,6 +11,6 @@ cloth_version=4.11.14
modmenu_version=1.16.8 modmenu_version=1.16.8
# Mod Properties # Mod Properties
mod_version = 1.0 mod_version = 1.1.1
maven_group = markil3 maven_group = markil3
archives_base_name = immersive_hud archives_base_name = immersive_hud

View File

@@ -82,7 +82,9 @@ public class ConfigManager
private TimeValues hungerTime = new TimeValues(); private TimeValues hungerTime = new TimeValues();
private TimeValues effectTime = new TimeValues(); private TimeValues effectTime = new TimeValues();
private int crosshairTime = 6 * TICKS_PER_SECOND; private int crosshairTime = 6 * TICKS_PER_SECOND;
private boolean hideCrosshair = true;
private int handTime = 30 * TICKS_PER_SECOND; private int handTime = 30 * TICKS_PER_SECOND;
private boolean hideHands = true;
private boolean showArmor = true; private boolean showArmor = true;
private double minHealth = 0.5; private double minHealth = 0.5;
private int minHunger = 17; private int minHunger = 17;
@@ -183,6 +185,15 @@ public class ConfigManager
{ {
return this.crosshairTime; return this.crosshairTime;
} }
/**
* Checks whether the crosshairs should be hidden after a period of time.
*
* @return - Whether or not crosshairs will be hidden.
*/
public boolean hideCrosshair()
{
return this.hideCrosshair;
}
/** /**
* Obtains the time that the hands are allowed to display. * Obtains the time that the hands are allowed to display.
@@ -194,6 +205,16 @@ public class ConfigManager
return this.handTime; return this.handTime;
} }
/**
* Checks whether hands should be hidden after a period of time.
*
* @return - Whether or not hands will be hidden.
*/
public boolean hideHands()
{
return this.hideHands;
}
/** /**
* Checks whether the armor bar should render. * Checks whether the armor bar should render.
* *
@@ -236,6 +257,16 @@ public class ConfigManager
this.crosshairTime = time; this.crosshairTime = time;
} }
/**
* Sets whether the crosshairs should be hidden after a period of time.
*
* @param hide - Whether or not crosshairs will be hidden.
*/
public void hideCrosshair(boolean hide)
{
this.hideCrosshair = hide;
}
/** /**
* Sets the time that the hands are allowed to display. * Sets the time that the hands are allowed to display.
* *
@@ -246,6 +277,16 @@ public class ConfigManager
this.handTime = time; this.handTime = time;
} }
/**
* Sets whether hands should be hidden after a period of time.
*
* @param hide - Whether or not hands will be hidden.
*/
public void hideHands(boolean hide)
{
this.hideHands = hide;
}
/** /**
* Determines whether the armor bar should render. * Determines whether the armor bar should render.
* *

View File

@@ -131,6 +131,15 @@ public class ModMenu implements ModMenuApi
.setSaveConsumer(val -> instance.setCrosshairTime((int) (val * TICKS_PER_SECOND))) .setSaveConsumer(val -> instance.setCrosshairTime((int) (val * TICKS_PER_SECOND)))
.build()); .build());
general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText(
"option.immersive_hud.hideCrosshair"),
instance.hideCrosshair())
.setDefaultValue(true)
.setTooltip(new TranslatableText(
"tooltip.immersive_hud.hideCrosshair"))
.setSaveConsumer(val -> instance.hideCrosshair(val))
.build());
general.addEntry(entryBuilder.startDoubleField(new TranslatableText( general.addEntry(entryBuilder.startDoubleField(new TranslatableText(
"option.immersive_hud.handTime"), "option.immersive_hud.handTime"),
(float) instance.getHandTime() / TICKS_PER_SECOND) (float) instance.getHandTime() / TICKS_PER_SECOND)
@@ -140,6 +149,15 @@ public class ModMenu implements ModMenuApi
.setSaveConsumer(val -> instance.setHandTime((int) (val * TICKS_PER_SECOND))) .setSaveConsumer(val -> instance.setHandTime((int) (val * TICKS_PER_SECOND)))
.build()); .build());
general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText(
"option.immersive_hud.hideHands"),
instance.hideHands())
.setDefaultValue(true)
.setTooltip(new TranslatableText(
"tooltip.immersive_hud.hideHands"))
.setSaveConsumer(val -> instance.hideHands(val))
.build());
general.addEntry(entryBuilder.startDoubleField(new TranslatableText( general.addEntry(entryBuilder.startDoubleField(new TranslatableText(
"option.immersive_hud.minHealth"), "option.immersive_hud.minHealth"),
instance.getMinHealth()) instance.getMinHealth())

View File

@@ -360,6 +360,9 @@ public class TimerUtils
{ {
final float HAND_UP_TIME = 20F; final float HAND_UP_TIME = 20F;
boolean hideHands = ConfigManager.getInstance().hideHands();
if (hideHands)
{
switch (hand) switch (hand)
{ {
case OFF_HAND: case OFF_HAND:
@@ -405,6 +408,7 @@ public class TimerUtils
} }
break; break;
} }
}
return false; return false;
} }
@@ -426,6 +430,9 @@ public class TimerUtils
boolean changed = false; boolean changed = false;
boolean canceled = false; boolean canceled = false;
boolean hideCrosshair = ConfigManager.getInstance().hideCrosshair();
if (hideCrosshair)
{
if (mc.crosshairTarget != null && mc.crosshairTarget if (mc.crosshairTarget != null && mc.crosshairTarget
.getType() != HitResult.Type.MISS) .getType() != HitResult.Type.MISS)
{ {
@@ -458,6 +465,7 @@ public class TimerUtils
{ {
crosshairTime -= ticks; crosshairTime -= ticks;
} }
}
return canceled; return canceled;
} }
@@ -488,7 +496,7 @@ public class TimerUtils
LivingEntity mount; LivingEntity mount;
boolean changed = false; boolean changed = false;
if (tmp == null) if (tmp == null || !(tmp instanceof LivingEntity))
{ {
mountHealth = -1; mountHealth = -1;
mountMaxHealth = -1; mountMaxHealth = -1;

View File

@@ -21,6 +21,8 @@ import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@@ -38,6 +40,9 @@ import markil3.immersive_hud.TimerUtils;
@Mixin(ClientPlayerEntity.class) @Mixin(ClientPlayerEntity.class)
public class ClientPlayerHook public class ClientPlayerHook
{ {
private static final Logger LOGGER =
LogManager.getLogger(ClientPlayerHook.class);
/** /**
* Updates hand timing every time an attack is initiated. * Updates hand timing every time an attack is initiated.
* *
@@ -48,9 +53,20 @@ public class ClientPlayerHook
*/ */
@Inject(method = "swingHand", at = @At(value = "TAIL")) @Inject(method = "swingHand", at = @At(value = "TAIL"))
public void swingHand(Hand hand, CallbackInfo callbackInfo) public void swingHand(Hand hand, CallbackInfo callbackInfo)
{
try
{ {
TimerUtils.onClick(hand, hand == null); TimerUtils.onClick(hand, hand == null);
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.network" +
".ClientPlayerEntity#swingHand " +
"event",
e);
}
}
/** /**
* Updates hand timing every time an item is used. * Updates hand timing every time an item is used.
@@ -62,9 +78,20 @@ public class ClientPlayerHook
*/ */
@Inject(method = "setCurrentHand", at = @At(value = "TAIL")) @Inject(method = "setCurrentHand", at = @At(value = "TAIL"))
public void setCurrentHand(Hand hand, CallbackInfo callbackInfo) public void setCurrentHand(Hand hand, CallbackInfo callbackInfo)
{
try
{ {
TimerUtils.onClick(hand, hand == null); TimerUtils.onClick(hand, hand == null);
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.network" +
".ClientPlayerEntity#setCurrentHand " +
"event",
e);
}
}
/** /**
* Updates hand timing every the hand is no longer being used. * Updates hand timing every the hand is no longer being used.
@@ -75,6 +102,8 @@ public class ClientPlayerHook
*/ */
@Inject(method = "clearActiveItem", at = @At(value = "HEAD")) @Inject(method = "clearActiveItem", at = @At(value = "HEAD"))
public void clearActiveItem(CallbackInfo callbackInfo) public void clearActiveItem(CallbackInfo callbackInfo)
{
try
{ {
if (MinecraftClient.getInstance().cameraEntity instanceof LivingEntity) if (MinecraftClient.getInstance().cameraEntity instanceof LivingEntity)
{ {
@@ -82,4 +111,13 @@ public class ClientPlayerHook
.getActiveHand(), true); .getActiveHand(), true);
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.network" +
".ClientPlayerEntity#clearActiveItem " +
"event",
e);
}
}
} }

View File

@@ -23,6 +23,8 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@@ -40,6 +42,9 @@ import markil3.immersive_hud.TimerUtils;
@Mixin(HeldItemRenderer.class) @Mixin(HeldItemRenderer.class)
public class HeldItemHook public class HeldItemHook
{ {
private static final Logger LOGGER =
LogManager.getLogger(HeldItemHook.class);
/** /**
* Determines whether or not to render a certain hand. * Determines whether or not to render a certain hand.
* *
@@ -71,11 +76,22 @@ public class HeldItemHook
VertexConsumerProvider vertexConsumers, VertexConsumerProvider vertexConsumers,
int light, int light,
CallbackInfo callbackInfo) CallbackInfo callbackInfo)
{
try
{ {
if (TimerUtils.onRenderHand(hand, matrices, tickDelta)) if (TimerUtils.onRenderHand(hand, matrices, tickDelta))
{ {
callbackInfo.cancel(); callbackInfo.cancel();
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.render.item" +
".HeldItemRenderer#renderFirstPersonItem " +
"event",
e);
}
}
} }

View File

@@ -24,6 +24,8 @@ import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectInstance;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@@ -43,6 +45,8 @@ import markil3.immersive_hud.TimerUtils;
@Mixin(InGameHud.class) @Mixin(InGameHud.class)
public class HudHook public class HudHook
{ {
private static final Logger LOGGER = LogManager.getLogger(HudHook.class);
private StatusEffectInstance currentEffect; private StatusEffectInstance currentEffect;
/** /**
@@ -57,6 +61,8 @@ public class HudHook
@Inject(method = "renderCrosshair", at = @At(value = "HEAD"), @Inject(method = "renderCrosshair", at = @At(value = "HEAD"),
cancellable = true) cancellable = true)
public void startCrosshair(MatrixStack stack, CallbackInfo callbackInfo) public void startCrosshair(MatrixStack stack, CallbackInfo callbackInfo)
{
try
{ {
if (TimerUtils.drawCrosshair(MinecraftClient.getInstance() if (TimerUtils.drawCrosshair(MinecraftClient.getInstance()
.getTickDelta())) .getTickDelta()))
@@ -64,6 +70,15 @@ public class HudHook
callbackInfo.cancel(); callbackInfo.cancel();
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#startCrosshair " +
"event",
e);
}
}
/** /**
* Resets any changes from drawing the crosshair. * Resets any changes from drawing the crosshair.
@@ -76,12 +91,23 @@ public class HudHook
*/ */
@Inject(method = "renderCrosshair", at = @At(value = "TAIL")) @Inject(method = "renderCrosshair", at = @At(value = "TAIL"))
public void finishCrosshair(MatrixStack stack, CallbackInfo callbackInfo) public void finishCrosshair(MatrixStack stack, CallbackInfo callbackInfo)
{
try
{ {
/* /*
* Resets the color so that nothing else is bothered. * Resets the color so that nothing else is bothered.
*/ */
TimerUtils.resetAlpha(); TimerUtils.resetAlpha();
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderCrosshair " +
"event",
e);
}
}
/** /**
* Determines whether or not to draw the horse jump bar. * Determines whether or not to draw the horse jump bar.
@@ -97,6 +123,8 @@ public class HudHook
public void startJumpbar(MatrixStack stack, public void startJumpbar(MatrixStack stack,
int x, int x,
CallbackInfo callbackInfo) CallbackInfo callbackInfo)
{
try
{ {
if (TimerUtils.drawJumpbar(stack, if (TimerUtils.drawJumpbar(stack,
MinecraftClient.getInstance().getTickDelta())) MinecraftClient.getInstance().getTickDelta()))
@@ -104,6 +132,15 @@ public class HudHook
callbackInfo.cancel(); callbackInfo.cancel();
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderMountJumpBar " +
"event",
e);
}
}
/** /**
* Resets any changes from drawing the horse jump bar. * Resets any changes from drawing the horse jump bar.
@@ -118,6 +155,8 @@ public class HudHook
public void finishJumpbar(MatrixStack stack, public void finishJumpbar(MatrixStack stack,
int x, int x,
CallbackInfo callbackInfo) CallbackInfo callbackInfo)
{
try
{ {
stack.pop(); stack.pop();
/* /*
@@ -125,6 +164,15 @@ public class HudHook
*/ */
TimerUtils.resetAlpha(); TimerUtils.resetAlpha();
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderMountJumpBar " +
"event",
e);
}
}
/** /**
* Determines whether or not to draw the experience bar. * Determines whether or not to draw the experience bar.
@@ -140,6 +188,8 @@ public class HudHook
public void startExperience(MatrixStack stack, public void startExperience(MatrixStack stack,
int x, int x,
CallbackInfo callbackInfo) CallbackInfo callbackInfo)
{
try
{ {
if (TimerUtils.drawExperience(stack, if (TimerUtils.drawExperience(stack,
MinecraftClient.getInstance().getTickDelta())) MinecraftClient.getInstance().getTickDelta()))
@@ -147,6 +197,15 @@ public class HudHook
callbackInfo.cancel(); callbackInfo.cancel();
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderExperienceBar " +
"event",
e);
}
}
/** /**
* Resets any changes from drawing the experience bar. * Resets any changes from drawing the experience bar.
@@ -161,6 +220,8 @@ public class HudHook
public void finishExperience(MatrixStack stack, public void finishExperience(MatrixStack stack,
int x, int x,
CallbackInfo callbackInfo) CallbackInfo callbackInfo)
{
try
{ {
stack.pop(); stack.pop();
/* /*
@@ -168,6 +229,15 @@ public class HudHook
*/ */
TimerUtils.resetAlpha(); TimerUtils.resetAlpha();
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderExperienceBar " +
"event",
e);
}
}
/** /**
* Changes the position of the status bars as the ones below them move up * Changes the position of the status bars as the ones below them move up
@@ -180,9 +250,20 @@ public class HudHook
@ModifyVariable(method = "renderStatusBars(Lnet/minecraft/client/util" + @ModifyVariable(method = "renderStatusBars(Lnet/minecraft/client/util" +
"/math/MatrixStack;)V", at = @At("HEAD")) "/math/MatrixStack;)V", at = @At("HEAD"))
public MatrixStack startStatus(MatrixStack stack) public MatrixStack startStatus(MatrixStack stack)
{
try
{ {
stack.push(); stack.push();
stack.translate(0F, TimerUtils.getHealthTranslation(), 0F); stack.translate(0F, TimerUtils.getHealthTranslation(), 0F);
}
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusBars " +
"event",
e);
}
return stack; return stack;
} }
@@ -196,12 +277,23 @@ public class HudHook
"/math/MatrixStack;)V", at = @At(value = "INVOKE", target = "Lnet" + "/math/MatrixStack;)V", at = @At(value = "INVOKE", target = "Lnet" +
"/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V")) "/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"))
public void renderArmor(MatrixStack matrices, CallbackInfo callbackInfo) public void renderArmor(MatrixStack matrices, CallbackInfo callbackInfo)
{
try
{ {
if (TimerUtils.drawArmor()) if (TimerUtils.drawArmor())
{ {
TimerUtils.setAlpha(0F); TimerUtils.setAlpha(0F);
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusBars " +
"event",
e);
}
}
/** /**
* Adjusts the health GUI. * Adjusts the health GUI.
@@ -214,16 +306,28 @@ public class HudHook
"/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", "/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V",
ordinal = 0)) ordinal = 0))
public void renderHealth(MatrixStack matrices, CallbackInfo callbackInfo) public void renderHealth(MatrixStack matrices, CallbackInfo callbackInfo)
{
try
{ {
/* /*
* Resets the transparency from the previous call. * Resets the transparency from the previous call.
*/ */
TimerUtils.setAlpha(1F); TimerUtils.setAlpha(1F);
if (TimerUtils.drawHealth(MinecraftClient.getInstance().getTickDelta())) if (TimerUtils.drawHealth(MinecraftClient.getInstance()
.getTickDelta()))
{ {
TimerUtils.setAlpha(0F); TimerUtils.setAlpha(0F);
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusBars " +
"event",
e);
}
}
/** /**
* Adjusts the food GUI. * Adjusts the food GUI.
@@ -236,16 +340,28 @@ public class HudHook
"/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", "/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V",
ordinal = 1)) ordinal = 1))
public void renderFood(MatrixStack matrices, CallbackInfo callbackInfo) public void renderFood(MatrixStack matrices, CallbackInfo callbackInfo)
{
try
{ {
/* /*
* Resets the transparency from the previous call. * Resets the transparency from the previous call.
*/ */
TimerUtils.setAlpha(1F); TimerUtils.setAlpha(1F);
if (TimerUtils.drawHunger(MinecraftClient.getInstance().getTickDelta())) if (TimerUtils.drawHunger(MinecraftClient.getInstance()
.getTickDelta()))
{ {
TimerUtils.setAlpha(0F); TimerUtils.setAlpha(0F);
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusBars " +
"event",
e);
}
}
/** /**
* Resets the air GUI. * Resets the air GUI.
@@ -258,18 +374,40 @@ public class HudHook
"/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", "/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V",
ordinal = 2)) ordinal = 2))
public void renderAir(MatrixStack matrices, CallbackInfo callbackInfo) public void renderAir(MatrixStack matrices, CallbackInfo callbackInfo)
{
try
{ {
/* /*
* Resets the color so that nothing else is bothered. * Resets the color so that nothing else is bothered.
*/ */
TimerUtils.setAlpha(1F); TimerUtils.setAlpha(1F);
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusBars " +
"event",
e);
}
}
@ModifyVariable(method = "renderStatusBars(Lnet/minecraft/client/util" + @ModifyVariable(method = "renderStatusBars(Lnet/minecraft/client/util" +
"/math/MatrixStack;)V", at = @At("TAIL")) "/math/MatrixStack;)V", at = @At("TAIL"))
public MatrixStack finishStatus(MatrixStack stack) public MatrixStack finishStatus(MatrixStack stack)
{
try
{ {
stack.pop(); stack.pop();
}
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusBars " +
"event",
e);
}
return stack; return stack;
} }
@@ -285,6 +423,8 @@ public class HudHook
@Inject(method = "renderMountHealth", at = @At(value = "HEAD"), @Inject(method = "renderMountHealth", at = @At(value = "HEAD"),
cancellable = true) cancellable = true)
public void startMountHealth(MatrixStack stack, CallbackInfo callbackInfo) public void startMountHealth(MatrixStack stack, CallbackInfo callbackInfo)
{
try
{ {
if (TimerUtils.drawMountHealth(stack, if (TimerUtils.drawMountHealth(stack,
MinecraftClient.getInstance().getTickDelta())) MinecraftClient.getInstance().getTickDelta()))
@@ -292,6 +432,15 @@ public class HudHook
callbackInfo.cancel(); callbackInfo.cancel();
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderMountHealth " +
"event",
e);
}
}
/** /**
* Resets any changes from drawing the mount's health. * Resets any changes from drawing the mount's health.
@@ -304,6 +453,8 @@ public class HudHook
*/ */
@Inject(method = "renderMountHealth", at = @At(value = "TAIL")) @Inject(method = "renderMountHealth", at = @At(value = "TAIL"))
public void finishMountHealth(MatrixStack stack, CallbackInfo callbackInfo) public void finishMountHealth(MatrixStack stack, CallbackInfo callbackInfo)
{
try
{ {
/* /*
* Resets the color so that nothing else is bothered. * Resets the color so that nothing else is bothered.
@@ -311,6 +462,15 @@ public class HudHook
stack.pop(); stack.pop();
TimerUtils.resetAlpha(); TimerUtils.resetAlpha();
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderMountHealth " +
"event",
e);
}
}
/** /**
* Makes the actual adjustment to the hotbar as needed. * Makes the actual adjustment to the hotbar as needed.
@@ -322,11 +482,22 @@ public class HudHook
"(Lnet/minecraft/client/util/math/MatrixStack;)V", at = "(Lnet/minecraft/client/util/math/MatrixStack;)V", at =
@At(value = "HEAD", shift = At.Shift.AFTER)) @At(value = "HEAD", shift = At.Shift.AFTER))
public void startPotion(MatrixStack effect, CallbackInfo info) public void startPotion(MatrixStack effect, CallbackInfo info)
{
try
{ {
TimerUtils.updatePotions(MinecraftClient.getInstance().cameraEntity instanceof ClientPlayerEntity ? TimerUtils.updatePotions(MinecraftClient.getInstance().cameraEntity instanceof ClientPlayerEntity ?
((ClientPlayerEntity) MinecraftClient.getInstance().cameraEntity) : ((ClientPlayerEntity) MinecraftClient.getInstance().cameraEntity) :
null); null);
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusEffectOverlay " +
"event",
e);
}
}
/** /**
* Makes the actual adjustment to the hotbar as needed. * Makes the actual adjustment to the hotbar as needed.
@@ -341,11 +512,23 @@ public class HudHook
"Lnet/minecraft/entity/effect/StatusEffectInstance;" + "Lnet/minecraft/entity/effect/StatusEffectInstance;" +
"shouldShowIcon()Z")) "shouldShowIcon()Z"))
public boolean shouldRenderPotion(StatusEffectInstance effect) public boolean shouldRenderPotion(StatusEffectInstance effect)
{
try
{ {
currentEffect = effect; currentEffect = effect;
return TimerUtils.updatePotion(effect, return TimerUtils.updatePotion(effect,
MinecraftClient.getInstance().getTickDelta()); MinecraftClient.getInstance().getTickDelta());
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusEffectOverlay " +
"event",
e);
}
return true;
}
/** /**
* Makes the actual adjustment to the hotbar as needed. * Makes the actual adjustment to the hotbar as needed.
@@ -361,9 +544,21 @@ public class HudHook
@At(value = "STORE")) @At(value = "STORE"))
public float updatePotion(float f, public float updatePotion(float f,
MatrixStack stack) MatrixStack stack)
{
try
{ {
return TimerUtils.getPotionAlpha(currentEffect); return TimerUtils.getPotionAlpha(currentEffect);
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusEffectOverlay " +
"event",
e);
}
return 1F;
}
/** /**
* Resets any changes from drawing the potion effects. * Resets any changes from drawing the potion effects.
@@ -377,12 +572,23 @@ public class HudHook
@Inject(method = "renderStatusEffectOverlay", at = @At(value = "TAIL")) @Inject(method = "renderStatusEffectOverlay", at = @At(value = "TAIL"))
public void finishPotion(MatrixStack matrices, public void finishPotion(MatrixStack matrices,
CallbackInfo callbackInfo) CallbackInfo callbackInfo)
{
try
{ {
/* /*
* Resets the color so that nothing else is bothered. * Resets the color so that nothing else is bothered.
*/ */
TimerUtils.resetAlpha(); TimerUtils.resetAlpha();
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderStatusEffectOverlay " +
"event",
e);
}
}
/** /**
* Determines whether or not to draw the hotbar. * Determines whether or not to draw the hotbar.
@@ -399,12 +605,23 @@ public class HudHook
public void startHotbar(float tickDelta, public void startHotbar(float tickDelta,
MatrixStack matrices, MatrixStack matrices,
CallbackInfo callbackInfo) CallbackInfo callbackInfo)
{
try
{ {
if (TimerUtils.updateHotbar(tickDelta)) if (TimerUtils.updateHotbar(tickDelta))
{ {
callbackInfo.cancel(); callbackInfo.cancel();
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderHotbar " +
"event",
e);
}
}
/** /**
* Makes the actual adjustment to the hotbar as needed. * Makes the actual adjustment to the hotbar as needed.
@@ -422,9 +639,20 @@ public class HudHook
public void adjustHotbar(float tickDelta, public void adjustHotbar(float tickDelta,
MatrixStack matrices, MatrixStack matrices,
CallbackInfo callbackInfo) CallbackInfo callbackInfo)
{
try
{ {
TimerUtils.recolorHotbar(matrices); TimerUtils.recolorHotbar(matrices);
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderHotbar " +
"event",
e);
}
}
/** /**
* Resets any changes from drawing the hotbar. * Resets any changes from drawing the hotbar.
@@ -440,6 +668,8 @@ public class HudHook
public void finishHotbar(float tickDelta, public void finishHotbar(float tickDelta,
MatrixStack stack, MatrixStack stack,
CallbackInfo callbackInfo) CallbackInfo callbackInfo)
{
try
{ {
RenderSystem.popMatrix(); RenderSystem.popMatrix();
stack.pop(); stack.pop();
@@ -448,4 +678,13 @@ public class HudHook
*/ */
TimerUtils.resetAlpha(); TimerUtils.resetAlpha();
} }
catch (Exception e)
{
LOGGER.error(
"Error in running net.minecraft.client.gui.hud" +
".InGameHud#renderHotbar " +
"event",
e);
}
}
} }

View File

@@ -19,7 +19,9 @@
"option.immersive_hud.effectFadeIn": "Potion Fade In Time", "option.immersive_hud.effectFadeIn": "Potion Fade In Time",
"option.immersive_hud.effectFadeOut": "Potion Fade Out Time", "option.immersive_hud.effectFadeOut": "Potion Fade Out Time",
"option.immersive_hud.crosshairTime": "Crosshair Display Time", "option.immersive_hud.crosshairTime": "Crosshair Display Time",
"option.immersive_hud.hideCrosshair": "Hide Crosshair",
"option.immersive_hud.handTime": "Hand Display Time", "option.immersive_hud.handTime": "Hand Display Time",
"option.immersive_hud.hideHands": "Hide Hands",
"option.immersive_hud.minHealth": "Minimum Health Fade", "option.immersive_hud.minHealth": "Minimum Health Fade",
"option.immersive_hud.minHunger": "Minimum Hunger Fade", "option.immersive_hud.minHunger": "Minimum Hunger Fade",
"option.immersive_hud.showArmor": "Show Armor", "option.immersive_hud.showArmor": "Show Armor",
@@ -42,7 +44,9 @@
"tooltip.immersive_hud.effectFadeIn": "How many seconds it takes for potion icons to fade in", "tooltip.immersive_hud.effectFadeIn": "How many seconds it takes for potion icons to fade in",
"tooltip.immersive_hud.effectFadeOut": "How many seconds it takes for potion icons to fade out", "tooltip.immersive_hud.effectFadeOut": "How many seconds it takes for potion icons to fade out",
"tooltip.immersive_hud.crosshairTime": "How many seconds the crosshairs can be on screen", "tooltip.immersive_hud.crosshairTime": "How many seconds the crosshairs can be on screen",
"tooltip.immersive_hud.hideCrosshair": "Whether or not the crosshairs should be hidden after a period of time",
"tooltip.immersive_hud.handTime": "How many seconds the hands can be on screen", "tooltip.immersive_hud.handTime": "How many seconds the hands can be on screen",
"tooltip.immersive_hud.hideHands": "Whether or not hands should be hidden after a period of time",
"tooltip.immersive_hud.minHealth": "When the percentage of health goes below this level, the health bar won't fade away", "tooltip.immersive_hud.minHealth": "When the percentage of health goes below this level, the health bar won't fade away",
"tooltip.immersive_hud.minHunger": "When the hunger level goes below this level, the hunger bar won't fade away", "tooltip.immersive_hud.minHunger": "When the hunger level goes below this level, the hunger bar won't fade away",
"tooltip.immersive_hud.showArmor": "Whether or not the armor bar should display on the HUD" "tooltip.immersive_hud.showArmor": "Whether or not the armor bar should display on the HUD"

View File

@@ -28,7 +28,7 @@
}, },
"mixins": [ "mixins": [
{ {
"config": "modid.mixins.json", "config": "immersive_hud.mixins.json",
"environment": "client" "environment": "client"
} }
], ],