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 11:25:55 -06:00
parent 83d17c1037
commit 2eff4a4bb2
3 changed files with 107 additions and 53 deletions

View File

@@ -84,7 +84,9 @@ public class ConfigManager
private TimeValues hungerTime = new TimeValues();
private TimeValues effectTime = new TimeValues();
private int crosshairTime = 6 * TICKS_PER_SECOND;
private boolean hideCrosshair = true;
private int handTime = 30 * TICKS_PER_SECOND;
private boolean hideHands = true;
private boolean showArmor = true;
private double minHealth = 0.5;
private int minHunger = 17;
@@ -186,6 +188,16 @@ public class ConfigManager
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.
*
@@ -196,6 +208,16 @@ public class ConfigManager
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.
*
@@ -238,6 +260,16 @@ public class ConfigManager
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.
*
@@ -248,6 +280,16 @@ public class ConfigManager
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.
*

View File

@@ -354,48 +354,52 @@ public class TimerUtils
{
final float HAND_UP_TIME = 20F;
switch (hand)
boolean hideHands = ConfigManager.getInstance().hideHands();
if (hideHands)
{
case OFF_HAND:
if (offHandTime == 0 && !offHandLock)
switch (hand)
{
return true;
}
else if (!offHandLock && (mapLock & 0b01) == 0)
{
if (offHandTime > 0)
case OFF_HAND:
if (offHandTime == 0 && !offHandLock)
{
offHandTime -= ticks;
return true;
}
if (offHandTime < HAND_UP_TIME)
else if (!offHandLock && (mapLock & 0b01) == 0)
{
GlStateManager.translatef(0,
(float) (-1.0F * (HAND_UP_TIME - offHandTime) /
HAND_UP_TIME),
0);
if (offHandTime > 0)
{
offHandTime -= ticks;
}
if (offHandTime < HAND_UP_TIME)
{
GlStateManager.translatef(0,
(float) (-1.0F * (HAND_UP_TIME - offHandTime) /
HAND_UP_TIME),
0);
}
}
}
break;
case MAIN_HAND:
if (mainHandTime == 0 && !mainHandLock)
{
return true;
}
else if (!mainHandLock && (mapLock & 0b10) == 0)
{
if (mainHandTime > 0)
break;
case MAIN_HAND:
if (mainHandTime == 0 && !mainHandLock)
{
mainHandTime -= ticks;
return true;
}
if (mainHandTime < HAND_UP_TIME)
else if (!mainHandLock && (mapLock & 0b10) == 0)
{
GlStateManager.translatef(0,
(float) (-1.0F * (HAND_UP_TIME - mainHandTime) /
HAND_UP_TIME),
0);
if (mainHandTime > 0)
{
mainHandTime -= ticks;
}
if (mainHandTime < HAND_UP_TIME)
{
GlStateManager.translatef(0,
(float) (-1.0F * (HAND_UP_TIME - mainHandTime) /
HAND_UP_TIME),
0);
}
}
break;
}
break;
}
return false;
}
@@ -418,37 +422,41 @@ public class TimerUtils
boolean changed = false;
boolean canceled = false;
if (mc.hitResult != null && mc.hitResult
.getType() != HitResult.Type.MISS)
boolean hideCrosshair = ConfigManager.getInstance().hideCrosshair();
if (hideCrosshair)
{
if (mc.hitResult.getType() == HitResult.Type
.ENTITY)
if (mc.hitResult != null && mc.hitResult
.getType() != HitResult.Type.MISS)
{
if (((EntityHitResult) mc.hitResult).getEntity() != entity
.getVehicle())
if (mc.hitResult.getType() == HitResult.Type
.ENTITY)
{
if (((EntityHitResult) mc.hitResult).getEntity() != entity
.getVehicle())
{
changed = true;
}
}
else
{
changed = true;
}
}
if (changed || mainHandLock || offHandLock || crosshairTime
> 0)
{
setAlpha(Main.getAlpha(crosshairTime > 0 ?
crosshairTime :
CROSSHAIR_TIME, CROSSHAIR_TIME, 0, 0));
}
else
{
changed = true;
canceled = true;
}
if (crosshairTime > 0)
{
crosshairTime -= ticks;
}
}
if (changed || mainHandLock || offHandLock || crosshairTime
> 0)
{
setAlpha(Main.getAlpha(crosshairTime > 0 ?
crosshairTime :
CROSSHAIR_TIME, CROSSHAIR_TIME, 0, 0));
}
else
{
canceled = true;
}
if (crosshairTime > 0)
{
crosshairTime -= ticks;
}
return canceled;
}