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.
This commit is contained in:
Markil3
2021-03-26 10:52:14 -06:00
parent a357b924d8
commit c5c62a0675
3 changed files with 139 additions and 74 deletions

View File

@@ -155,7 +155,9 @@ public class ConfigManager
private final TimeValues hungerTime;
private final TimeValues effectTime;
private final ForgeConfigSpec.IntValue crosshairTime;
private final ForgeConfigSpec.BooleanValue hideCrosshair;
private final ForgeConfigSpec.IntValue handTime;
private final ForgeConfigSpec.BooleanValue hideHands;
private final ForgeConfigSpec.BooleanValue showArmor;
private final ForgeConfigSpec.DoubleValue minHealth;
private final ForgeConfigSpec.IntValue minHunger;
@@ -182,6 +184,10 @@ public class ConfigManager
6 * TICKS_PER_SECOND,
0,
10 * 60 * TICKS_PER_SECOND);
this.hideCrosshair =
configSpecBuilder.translation(
"immersive_hud.configGui.hideCrosshair.title")
.define("hideCrosshair", true);
this.handTime =
configSpecBuilder.translation(
"immersive_hud.configGui.handTime.title")
@@ -189,6 +195,10 @@ public class ConfigManager
30 * TICKS_PER_SECOND,
0,
10 * 60 * TICKS_PER_SECOND);
this.hideHands =
configSpecBuilder.translation(
"immersive_hud.configGui.hideHands.title")
.define("hideHands", true);
this.showArmor = configSpecBuilder.translation(
"immersive_hud.configGui.showArmor.title")
.define("showArmor", true);
@@ -282,6 +292,16 @@ public class ConfigManager
return this.crosshairTime.get();
}
/**
* 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.get();
}
/**
* Obtains the time that the hands are allowed to display.
*
@@ -292,6 +312,16 @@ public class ConfigManager
return this.handTime.get();
}
/**
* 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.get();
}
/**
* Checks whether the armor bar should render.
*
@@ -334,6 +364,16 @@ public class ConfigManager
this.crosshairTime.set(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.set(hide);
}
/**
* Sets the time that the hands are allowed to display.
*
@@ -344,6 +384,16 @@ public class ConfigManager
this.handTime.set(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.set(hide);
}
/**
* Determines whether the armor bar should render.
*

View File

@@ -24,7 +24,6 @@ import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.Hand;
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
@@ -297,6 +296,10 @@ public class TimerUtils
{
float HAND_UP_TIME = 20F;
boolean hideHands =
ConfigManager.getInstance().hideHands();
if (hideHands)
{
switch (hand)
{
case OFF_HAND:
@@ -349,6 +352,7 @@ public class TimerUtils
}
break;
}
}
return false;
}
@@ -383,6 +387,10 @@ public class TimerUtils
boolean changed = false;
boolean canceled = false;
boolean hideCrosshair =
ConfigManager.getInstance().hideCrosshair();
if (hideCrosshair)
{
if (mc.objectMouseOver != null && mc.objectMouseOver.getType() != RayTraceResult.Type.MISS)
{
if (mc.objectMouseOver.getType() == RayTraceResult.Type.ENTITY)
@@ -412,6 +420,7 @@ public class TimerUtils
{
crosshairTime -= ticks;
}
}
return canceled;
}
@@ -474,7 +483,8 @@ public class TimerUtils
}
else if (effectinstance.getDuration() <= BLINK_TIME + potion.getFadeInTime())
{
effectAlpha = -(effectinstance.getDuration() - BLINK_TIME) / 22F + 0.454F;
effectAlpha =
-(effectinstance.getDuration() - BLINK_TIME) / 22F + 0.454F;
}
else
{
@@ -757,7 +767,8 @@ public class TimerUtils
* Only makes a change if the player is healthy. Otherwise,
* the bar is shown.
*/
if (health / maxHealth > HEALTH_BOUNDARY && !mc.player.isPotionActive(Effects.WITHER) && !mc.player.isPotionActive(Effects.POISON))
if (health / maxHealth > HEALTH_BOUNDARY && !mc.player.isPotionActive(
Effects.WITHER) && !mc.player.isPotionActive(Effects.POISON))
{
if (healthTime > 0)
{

View File

@@ -19,7 +19,9 @@
"option.immersive_hud.effectFadeIn": "Potion Fade In Time",
"option.immersive_hud.effectFadeOut": "Potion Fade Out Time",
"option.immersive_hud.crosshairTime": "Crosshair Display Time",
"option.immersive_hud.hideCrosshair": "Hide Crosshair",
"option.immersive_hud.handTime": "Hand Display Time",
"option.immersive_hud.hideHands": "Hide Hands",
"option.immersive_hud.minHealth": "Minimum Health Fade",
"option.immersive_hud.minHunger": "Minimum Hunger Fade",
"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.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.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.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.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"