Makes the hotbar and experience/jump bars slide in and out.
This commit is contained in:
@@ -205,6 +205,50 @@ public class TimerUtils
|
|||||||
setAlpha(1.0F);
|
setAlpha(1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the offset from the bottom of the screen that the hotbar
|
||||||
|
* receives.
|
||||||
|
*
|
||||||
|
* @return The offset the hotbar uses.
|
||||||
|
*/
|
||||||
|
public static int getHotbarTranslation()
|
||||||
|
{
|
||||||
|
return (int) (22F * (1 - Main.getAlpha(hotbarTime)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the offset from the bottom of the screen that the experience bar
|
||||||
|
* receives.
|
||||||
|
*
|
||||||
|
* @return The offset the experience bar uses.
|
||||||
|
*/
|
||||||
|
public static int getExperienceTranslation()
|
||||||
|
{
|
||||||
|
return (int) ((12F + (22 - getHotbarTranslation())) * (1 - Main.getAlpha(experienceTime))) + getHotbarTranslation();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the offset from the bottom of the screen that the jump bar
|
||||||
|
* receives.
|
||||||
|
*
|
||||||
|
* @return The offset the jump bar uses.
|
||||||
|
*/
|
||||||
|
public static int getJumpTranslation()
|
||||||
|
{
|
||||||
|
return (int) ((12F + (22 - getHotbarTranslation())) * (1 - Main.getAlpha(jumpTime))) + getHotbarTranslation();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the offset that the status bars (health, hunger, etc.) gets from
|
||||||
|
* their usual position.
|
||||||
|
*
|
||||||
|
* @return The offset.
|
||||||
|
*/
|
||||||
|
public static float getHealthTranslation()
|
||||||
|
{
|
||||||
|
return 7 * (1 - Math.max(Main.getAlpha(experienceTime), Main.getAlpha(jumpTime))) + 22 * (1 - Main.getAlpha(hotbarTime));//Math.min(, getHotbarTranslation());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run whenever the player clicks a mouse button. This brings the hands into
|
* Run whenever the player clicks a mouse button. This brings the hands into
|
||||||
* view, and briefly brings the health and hunger into view if the held item
|
* view, and briefly brings the health and hunger into view if the held item
|
||||||
@@ -386,7 +430,7 @@ public class TimerUtils
|
|||||||
*
|
*
|
||||||
* @since 0.1-1.16.4-fabric
|
* @since 0.1-1.16.4-fabric
|
||||||
*/
|
*/
|
||||||
public static boolean drawMountHealth()
|
public static boolean drawMountHealth(MatrixStack stack)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* When the health percentage falls to this level or below, the
|
* When the health percentage falls to this level or below, the
|
||||||
@@ -431,6 +475,10 @@ public class TimerUtils
|
|||||||
|
|
||||||
if (mountTime > 0)
|
if (mountTime > 0)
|
||||||
{
|
{
|
||||||
|
stack.push();
|
||||||
|
stack.translate(0F,
|
||||||
|
getHealthTranslation(),
|
||||||
|
0F);
|
||||||
setAlpha(Main.getAlpha(mountTime));
|
setAlpha(Main.getAlpha(mountTime));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -663,8 +711,9 @@ public class TimerUtils
|
|||||||
* @return If true, then cancel drawing the jump bar.
|
* @return If true, then cancel drawing the jump bar.
|
||||||
*
|
*
|
||||||
* @since 0.1-1.16.4-fabric
|
* @since 0.1-1.16.4-fabric
|
||||||
|
* @param stack
|
||||||
*/
|
*/
|
||||||
public static boolean drawJumpbar()
|
public static boolean drawJumpbar(MatrixStack stack)
|
||||||
{
|
{
|
||||||
MinecraftClient mc = MinecraftClient.getInstance();
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
ClientPlayerEntity entity;
|
ClientPlayerEntity entity;
|
||||||
@@ -687,6 +736,8 @@ public class TimerUtils
|
|||||||
}
|
}
|
||||||
if (jumpTime > 0)
|
if (jumpTime > 0)
|
||||||
{
|
{
|
||||||
|
stack.push();
|
||||||
|
stack.translate(0F, TimerUtils.getJumpTranslation(), 0F);
|
||||||
setAlpha(Main.getAlpha(jumpTime));
|
setAlpha(Main.getAlpha(jumpTime));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -701,7 +752,7 @@ public class TimerUtils
|
|||||||
*
|
*
|
||||||
* @since 0.1-1.16.4-fabric
|
* @since 0.1-1.16.4-fabric
|
||||||
*/
|
*/
|
||||||
public static boolean drawExperience()
|
public static boolean drawExperience(MatrixStack stack)
|
||||||
{
|
{
|
||||||
MinecraftClient mc = MinecraftClient.getInstance();
|
MinecraftClient mc = MinecraftClient.getInstance();
|
||||||
ClientPlayerEntity entity;
|
ClientPlayerEntity entity;
|
||||||
@@ -731,6 +782,8 @@ public class TimerUtils
|
|||||||
}
|
}
|
||||||
if (experienceTime > 0)
|
if (experienceTime > 0)
|
||||||
{
|
{
|
||||||
|
stack.push();
|
||||||
|
stack.translate(0F, TimerUtils.getExperienceTranslation(), 0F);
|
||||||
setAlpha(Main.getAlpha(experienceTime));
|
setAlpha(Main.getAlpha(experienceTime));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -953,8 +1006,11 @@ public class TimerUtils
|
|||||||
*
|
*
|
||||||
* @since 0.1-1.16.4-fabric
|
* @since 0.1-1.16.4-fabric
|
||||||
*/
|
*/
|
||||||
public static void recolorHotbar()
|
public static void recolorHotbar(MatrixStack stack)
|
||||||
{
|
{
|
||||||
|
RenderSystem.pushMatrix();
|
||||||
|
stack.push();
|
||||||
|
RenderSystem.translatef(0F, TimerUtils.getHotbarTranslation(), 0F);
|
||||||
setAlpha(Main.getAlpha(hotbarTime));
|
setAlpha(Main.getAlpha(hotbarTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package markil3.immersive_hud.mixin;
|
package markil3.immersive_hud.mixin;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.hud.InGameHud;
|
import net.minecraft.client.gui.hud.InGameHud;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
@@ -95,7 +97,7 @@ public class HudHook
|
|||||||
int x,
|
int x,
|
||||||
CallbackInfo callbackInfo)
|
CallbackInfo callbackInfo)
|
||||||
{
|
{
|
||||||
if (TimerUtils.drawJumpbar())
|
if (TimerUtils.drawJumpbar(stack))
|
||||||
{
|
{
|
||||||
callbackInfo.cancel();
|
callbackInfo.cancel();
|
||||||
}
|
}
|
||||||
@@ -115,6 +117,7 @@ public class HudHook
|
|||||||
int x,
|
int x,
|
||||||
CallbackInfo callbackInfo)
|
CallbackInfo callbackInfo)
|
||||||
{
|
{
|
||||||
|
stack.pop();
|
||||||
/*
|
/*
|
||||||
* Resets the color so that nothing else is bothered.
|
* Resets the color so that nothing else is bothered.
|
||||||
*/
|
*/
|
||||||
@@ -136,7 +139,7 @@ public class HudHook
|
|||||||
int x,
|
int x,
|
||||||
CallbackInfo callbackInfo)
|
CallbackInfo callbackInfo)
|
||||||
{
|
{
|
||||||
if (TimerUtils.drawExperience())
|
if (TimerUtils.drawExperience(stack))
|
||||||
{
|
{
|
||||||
callbackInfo.cancel();
|
callbackInfo.cancel();
|
||||||
}
|
}
|
||||||
@@ -156,12 +159,38 @@ public class HudHook
|
|||||||
int x,
|
int x,
|
||||||
CallbackInfo callbackInfo)
|
CallbackInfo callbackInfo)
|
||||||
{
|
{
|
||||||
|
stack.pop();
|
||||||
/*
|
/*
|
||||||
* Resets the color so that nothing else is bothered.
|
* Resets the color so that nothing else is bothered.
|
||||||
*/
|
*/
|
||||||
TimerUtils.resetAlpha();
|
TimerUtils.resetAlpha();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the position of the status bars as the ones below them move up
|
||||||
|
* and down.
|
||||||
|
*
|
||||||
|
* @param stack - The matrix stack used.
|
||||||
|
*
|
||||||
|
* @return The same matrix stack, with a new matrix pushed onto it.
|
||||||
|
*/
|
||||||
|
@ModifyVariable(method = "renderStatusBars(Lnet/minecraft/client/util" +
|
||||||
|
"/math/MatrixStack;)V", at = @At("HEAD"))
|
||||||
|
public MatrixStack startStatus(MatrixStack stack)
|
||||||
|
{
|
||||||
|
stack.push();
|
||||||
|
stack.translate(0F, TimerUtils.getHealthTranslation(), 0F);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyVariable(method = "renderStatusBars(Lnet/minecraft/client/util" +
|
||||||
|
"/math/MatrixStack;)V", at = @At("TAIL"))
|
||||||
|
public MatrixStack finishStatus(MatrixStack stack)
|
||||||
|
{
|
||||||
|
stack.pop();
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether or not to draw the mount's health.
|
* Determines whether or not to draw the mount's health.
|
||||||
*
|
*
|
||||||
@@ -175,7 +204,7 @@ public class HudHook
|
|||||||
cancellable = true)
|
cancellable = true)
|
||||||
public void startMountHealth(MatrixStack stack, CallbackInfo callbackInfo)
|
public void startMountHealth(MatrixStack stack, CallbackInfo callbackInfo)
|
||||||
{
|
{
|
||||||
if (TimerUtils.drawMountHealth())
|
if (TimerUtils.drawMountHealth(stack))
|
||||||
{
|
{
|
||||||
callbackInfo.cancel();
|
callbackInfo.cancel();
|
||||||
}
|
}
|
||||||
@@ -196,6 +225,7 @@ public class HudHook
|
|||||||
/*
|
/*
|
||||||
* Resets the color so that nothing else is bothered.
|
* Resets the color so that nothing else is bothered.
|
||||||
*/
|
*/
|
||||||
|
stack.pop();
|
||||||
TimerUtils.resetAlpha();
|
TimerUtils.resetAlpha();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,15 +266,15 @@ public class HudHook
|
|||||||
/**
|
/**
|
||||||
* Makes the actual adjustment to the hotbar as needed.
|
* Makes the actual adjustment to the hotbar as needed.
|
||||||
*
|
*
|
||||||
* @param matrices - The matrix drawing stack.
|
* @param f - The original transparency
|
||||||
* @param callbackInfo
|
* @param stack - The matrix stack
|
||||||
*
|
*
|
||||||
* @version 0.2-1.16.4-fabric
|
* @version 0.2-1.16.4-fabric
|
||||||
* @since 0.1-1.16.4-fabric
|
* @since 0.1-1.16.4-fabric
|
||||||
*/
|
*/
|
||||||
@ModifyVariable(method = "renderStatusEffectOverlay" +
|
@ModifyVariable(method = "renderStatusEffectOverlay" +
|
||||||
"(Lnet/minecraft/client/util/math/MatrixStack;)V", at =
|
"(Lnet/minecraft/client/util/math/MatrixStack;)V", at =
|
||||||
@At(value = "STORE"), ordinal = 1)
|
@At(value = "STORE"))
|
||||||
public float updatePotion(float f,
|
public float updatePotion(float f,
|
||||||
MatrixStack stack)
|
MatrixStack stack)
|
||||||
{
|
{
|
||||||
@@ -309,14 +339,14 @@ public class HudHook
|
|||||||
MatrixStack matrices,
|
MatrixStack matrices,
|
||||||
CallbackInfo callbackInfo)
|
CallbackInfo callbackInfo)
|
||||||
{
|
{
|
||||||
TimerUtils.recolorHotbar();
|
TimerUtils.recolorHotbar(matrices);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets any changes from drawing the hotbar.
|
* Resets any changes from drawing the hotbar.
|
||||||
*
|
*
|
||||||
* @param tickDelta
|
* @param tickDelta
|
||||||
* @param matrices - The matrix drawing stack.
|
* @param stack - The matrix drawing stack.
|
||||||
* @param callbackInfo
|
* @param callbackInfo
|
||||||
*
|
*
|
||||||
* @version 0.2-1.16.4-fabric
|
* @version 0.2-1.16.4-fabric
|
||||||
@@ -324,9 +354,11 @@ public class HudHook
|
|||||||
*/
|
*/
|
||||||
@Inject(method = "renderHotbar", at = @At(value = "TAIL"))
|
@Inject(method = "renderHotbar", at = @At(value = "TAIL"))
|
||||||
public void finishHotbar(float tickDelta,
|
public void finishHotbar(float tickDelta,
|
||||||
MatrixStack matrices,
|
MatrixStack stack,
|
||||||
CallbackInfo callbackInfo)
|
CallbackInfo callbackInfo)
|
||||||
{
|
{
|
||||||
|
RenderSystem.popMatrix();
|
||||||
|
stack.pop();
|
||||||
/*
|
/*
|
||||||
* Resets the color so that nothing else is bothered.
|
* Resets the color so that nothing else is bothered.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user