Compare commits

..

3 Commits

Author SHA1 Message Date
Markil3
cdc1139658 Update gradle.properties 2021-08-30 22:30:05 -06:00
Markil3
2b2c81aa45 Allows some items to not trigger a hand/crosshair update.
This is helpful if one is using Firework rockets to fly around the landscape.
2021-08-30 22:10:22 -06:00
Markil3
5d7f44636b Changes how the mod handles status bars slightly.
This should somewhat increase compatibility with the AppleSkin mod.
2021-07-22 13:29:40 -06:00
26 changed files with 150 additions and 160 deletions

6
.github/workflows/build.yml vendored Executable file → Normal file
View File

@@ -12,9 +12,9 @@ jobs:
matrix: matrix:
# Use these Java versions # Use these Java versions
java: [ java: [
1.16, # Minimum supported by Minecraft 1.8, # Minimum supported by Minecraft
16, # Current Java LTS 11, # Current Java LTS
16 # Latest version 15 # Latest version
] ]
# and run on both Linux and Windows # and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest] os: [ubuntu-20.04, windows-latest]

2
.gitignore vendored Executable file → Normal file
View File

@@ -32,5 +32,3 @@ bin/
run/ run/
/logs/ /logs/
local.properties
remappedSrc/

0
LICENSE Executable file → Normal file
View File

0
README.md Executable file → Normal file
View File

15
build.gradle Executable file → Normal file
View File

@@ -1,10 +1,10 @@
plugins { plugins {
id 'fabric-loom' version '0.8-SNAPSHOT' id 'fabric-loom' version '0.5-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
sourceCompatibility = JavaVersion.VERSION_16 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_16 targetCompatibility = JavaVersion.VERSION_1_8
archivesBaseName = project.archives_base_name archivesBaseName = project.archives_base_name
version = project.mod_version + "-" + project.minecraft_version + "-fabric" version = project.mod_version + "-" + project.minecraft_version + "-fabric"
@@ -43,8 +43,13 @@ tasks.withType(JavaCompile).configureEach {
// If Javadoc is generated, this must be specified in that task too. // If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8" it.options.encoding = "UTF-8"
// Minecraft 1.17 (21w19a) upwards uses Java 16. // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
it.options.release = 16 // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
} }
java { java {

0
demo.gif Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 37 MiB

After

Width:  |  Height:  |  Size: 37 MiB

10
gradle.properties Executable file → Normal file
View File

@@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
minecraft_version=1.17 minecraft_version=1.16.4
yarn_mappings=1.17+build.1 yarn_mappings=1.16.4+build.9
loader_version=0.11.3 loader_version=0.11.1
cloth_version=5.0.34 cloth_version=4.11.14
modmenu_version=2.0.2 modmenu_version=1.16.8
# Mod Properties # Mod Properties
mod_version = 1.2 mod_version = 1.2

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

0
screenshot1.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

0
screenshot2.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 767 KiB

After

Width:  |  Height:  |  Size: 767 KiB

0
screenshot3.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

0
screenshot4.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 983 KiB

After

Width:  |  Height:  |  Size: 983 KiB

0
screenshot5.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 405 KiB

After

Width:  |  Height:  |  Size: 405 KiB

0
settings.gradle Executable file → Normal file
View File

8
src/main/java/markil3/immersive_hud/ConfigManager.java Executable file → Normal file
View File

@@ -1,19 +1,19 @@
package markil3.immersive_hud; package markil3.immersive_hud;
import static markil3.immersive_hud.Main.TICKS_PER_SECOND;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import me.shedaniel.autoconfig.AutoConfig;
import static markil3.immersive_hud.Main.TICKS_PER_SECOND;
import java.util.Arrays; import java.util.Arrays;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import me.shedaniel.autoconfig.AutoConfig;
/** /**
* Configuration manager of this mod, which reads from and writes to this mod's * Configuration manager of this mod, which reads from and writes to this mod's
* configuration file. * configuration file.

View File

0
src/main/java/markil3/immersive_hud/Main.java Executable file → Normal file
View File

162
src/main/java/markil3/immersive_hud/ModMenu.java Executable file → Normal file
View File

@@ -17,6 +17,7 @@ import me.shedaniel.clothconfig2.gui.entries.DoubleListEntry;
import static markil3.immersive_hud.Main.TICKS_PER_SECOND; import static markil3.immersive_hud.Main.TICKS_PER_SECOND;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -37,42 +38,45 @@ public class ModMenu implements ModMenuApi
"option.immersive_hud." + name + "option.immersive_hud." + name +
"MaxTime"), "MaxTime"),
(float) value.getMaxTime() / TICKS_PER_SECOND) (float) value.getMaxTime() / TICKS_PER_SECOND)
.setDefaultValue(SHOW_TIME) .setDefaultValue(SHOW_TIME)
.setMin(0) .setMin(0)
.setMax(10 * 60 * TICKS_PER_SECOND) // 10 Minutes .setMax(10 * 60 * TICKS_PER_SECOND) // 10 Minutes
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud." + name + "tooltip.immersive_hud." + name +
"MaxTime")) "MaxTime"))
.setSaveConsumer(val -> value.setMaxTime((int) (val * TICKS_PER_SECOND))) .setSaveConsumer(val -> value
.build(); .setMaxTime((int) (val * TICKS_PER_SECOND)))
.build();
DoubleListEntry fadeIn = DoubleListEntry fadeIn =
entryBuilder.startDoubleField(new TranslatableText( entryBuilder.startDoubleField(new TranslatableText(
"option.immersive_hud." + name + "option.immersive_hud." + name +
"FadeIn"), "FadeIn"),
(float) value.getFadeInTime() / TICKS_PER_SECOND) (float) value.getFadeInTime() / TICKS_PER_SECOND)
.setDefaultValue(FADE_IN) .setDefaultValue(FADE_IN)
.setMin(0) .setMin(0)
.setMax(10 * 60 * TICKS_PER_SECOND) .setMax(10 * 60 * TICKS_PER_SECOND)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud." + name + "tooltip.immersive_hud." + name +
"FadeIn")) "FadeIn"))
.setSaveConsumer(val -> value.setFadeInTime((int) (val * TICKS_PER_SECOND))) .setSaveConsumer(val -> value
.build(); .setFadeInTime((int) (val * TICKS_PER_SECOND)))
.build();
DoubleListEntry fadeOut = DoubleListEntry fadeOut =
entryBuilder.startDoubleField(new TranslatableText( entryBuilder.startDoubleField(new TranslatableText(
"option.immersive_hud." + name + "option.immersive_hud." + name +
"FadeOut"), "FadeOut"),
(float) value.getFadeOutTime() / TICKS_PER_SECOND) (float) value.getFadeOutTime() / TICKS_PER_SECOND)
.setDefaultValue(FADE_OUT) .setDefaultValue(FADE_OUT)
.setMin(0) .setMin(0)
.setMax(10 * 60 * TICKS_PER_SECOND) .setMax(10 * 60 * TICKS_PER_SECOND)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud." + name + "tooltip.immersive_hud." + name +
"FadeOut")) "FadeOut"))
.setSaveConsumer(val -> value.setFadeOutTime((int) (val * TICKS_PER_SECOND))) .setSaveConsumer(val -> value
.build(); .setFadeOutTime((int) (val * TICKS_PER_SECOND)))
.build();
cat.addEntry(maxTime); cat.addEntry(maxTime);
cat.addEntry(fadeIn); cat.addEntry(fadeIn);
@@ -87,23 +91,25 @@ public class ModMenu implements ModMenuApi
ConfigEntryBuilder entryBuilder; ConfigEntryBuilder entryBuilder;
ConfigManager instance = ConfigManager.getInstance(); ConfigManager instance = ConfigManager.getInstance();
final ConfigBuilder builder = ConfigBuilder.create() final ConfigBuilder builder = ConfigBuilder.create()
.setParentScreen(screen) .setParentScreen(screen)
.setTitle(new TranslatableText( .setTitle(new TranslatableText(
"immersive_hud.configGui.title")) "immersive_hud.configGui.title"))
.setSavingRunnable(() -> { .setSavingRunnable(() -> {
try try
{ {
if (Class.forName("me.shedaniel.autoconfig.AutoConfig") != null) if (Class
{ .forName("me.shedaniel.autoconfig.AutoConfig") != null)
AutoConfig.getConfigHolder(ConfigManagerCloth.class) {
.save(); AutoConfig
} .getConfigHolder(ConfigManagerCloth.class)
} .save();
catch (ClassNotFoundException e) }
{ }
// Do nothing catch (ClassNotFoundException e)
} {
}); // Do nothing
}
});
general = general =
builder.getOrCreateCategory(new TranslatableText( builder.getOrCreateCategory(new TranslatableText(
"category.immersive_hud.general")); "category.immersive_hud.general"));
@@ -132,66 +138,68 @@ public class ModMenu implements ModMenuApi
"option.immersive_hud" + "option.immersive_hud" +
".crosshairTime"), ".crosshairTime"),
(float) instance.getCrosshairTime() / TICKS_PER_SECOND) (float) instance.getCrosshairTime() / TICKS_PER_SECOND)
.setDefaultValue(6) .setDefaultValue(6)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud" + "tooltip.immersive_hud" +
".crosshairTime")) ".crosshairTime"))
.setSaveConsumer(val -> instance.setCrosshairTime((int) (val * TICKS_PER_SECOND))) .setSaveConsumer(val -> instance
.build()); .setCrosshairTime((int) (val * TICKS_PER_SECOND)))
.build());
general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText( general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText(
"option.immersive_hud.hideCrosshair"), "option.immersive_hud.hideCrosshair"),
instance.hideCrosshair()) instance.hideCrosshair())
.setDefaultValue(true) .setDefaultValue(true)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud.hideCrosshair")) "tooltip.immersive_hud.hideCrosshair"))
.setSaveConsumer(val -> instance.hideCrosshair(val)) .setSaveConsumer(val -> instance.hideCrosshair(val))
.build()); .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)
.setDefaultValue(30) .setDefaultValue(30)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud.handTime")) "tooltip.immersive_hud.handTime"))
.setSaveConsumer(val -> instance.setHandTime((int) (val * TICKS_PER_SECOND))) .setSaveConsumer(val -> instance
.build()); .setHandTime((int) (val * TICKS_PER_SECOND)))
.build());
general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText( general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText(
"option.immersive_hud.hideHands"), "option.immersive_hud.hideHands"),
instance.hideHands()) instance.hideHands())
.setDefaultValue(true) .setDefaultValue(true)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud.hideHands")) "tooltip.immersive_hud.hideHands"))
.setSaveConsumer(val -> instance.hideHands(val)) .setSaveConsumer(val -> instance.hideHands(val))
.build()); .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())
.setDefaultValue(0.5) .setDefaultValue(0.5)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud.minHealth")) "tooltip.immersive_hud.minHealth"))
.setSaveConsumer(val -> instance.setMinHealth(val)) .setSaveConsumer(val -> instance.setMinHealth(val))
.build()); .build());
general.addEntry(entryBuilder.startIntField(new TranslatableText( general.addEntry(entryBuilder.startIntField(new TranslatableText(
"option.immersive_hud.minHunger"), "option.immersive_hud.minHunger"),
instance.getMinHunger()) instance.getMinHunger())
.setDefaultValue(17) .setDefaultValue(17)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud.minHunger")) "tooltip.immersive_hud.minHunger"))
.setSaveConsumer(val -> instance.setMinHunger(val)) .setSaveConsumer(val -> instance.setMinHunger(val))
.build()); .build());
general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText( general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText(
"option.immersive_hud.showArmor"), "option.immersive_hud.showArmor"),
instance.shouldShowArmor()) instance.shouldShowArmor())
.setDefaultValue(true) .setDefaultValue(true)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud.showArmor")) "tooltip.immersive_hud.showArmor"))
.setSaveConsumer(val -> instance.shouldShowArmor(val)) .setSaveConsumer(val -> instance.shouldShowArmor(val))
.build()); .build());
general.addEntry(entryBuilder general.addEntry(entryBuilder
.startStrList(new TranslatableText("option.immersive_hud.ignoreList"), Arrays .startStrList(new TranslatableText("option.immersive_hud.ignoreList"), Arrays

88
src/main/java/markil3/immersive_hud/TimerUtils.java Executable file → Normal file
View File

@@ -55,7 +55,7 @@ import java.util.Set;
* Contains the logic for changing the HUD. * Contains the logic for changing the HUD.
* *
* @author Markil 3 * @author Markil 3
* @version 1.1.1-1.17-fabric * @version 0.1-1.16.4-fabric
*/ */
public class TimerUtils public class TimerUtils
{ {
@@ -174,7 +174,7 @@ public class TimerUtils
*/ */
public static void setAlpha(float alpha) public static void setAlpha(float alpha)
{ {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha); RenderSystem.color4f(1.0F, 1.0F, 1.0F, alpha);
} }
/** /**
@@ -288,9 +288,8 @@ public class TimerUtils
* 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
* is food. * is food.
* *
* @param hand - The hand being triggered * @param hand - The hand being triggered
* @param clear - Whether the hand it being enabled or disabled. * @param clear - Whether the hand it being enabled or disabled.
*
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
public static void onClick(Hand hand, boolean clear) public static void onClick(Hand hand, boolean clear)
@@ -355,11 +354,11 @@ public class TimerUtils
if (item.isFood()) if (item.isFood())
{ {
healthTime = health.getMaxTime() - (healthTime > 0 ? healthTime = health.getMaxTime() - (healthTime > 0 ?
health.getFadeInTime() : health.getFadeInTime() :
0); 0);
hungerTime = hunger.getMaxTime() - (hungerTime > 0 ? hungerTime = hunger.getMaxTime() - (hungerTime > 0 ?
hunger.getFadeInTime() : hunger.getFadeInTime() :
0); 0);
} }
} }
else else
@@ -372,11 +371,9 @@ public class TimerUtils
* Run whenever a hand is rendered in 1st person. This brings the player * Run whenever a hand is rendered in 1st person. This brings the player
* hands into and out of view as needed. * hands into and out of view as needed.
* *
* @param hand - The hand being rendered. * @param hand - The hand being rendered.
* @param matrixStack - The rendering stack. * @param matrixStack - The rendering stack.
*
* @return If true, then don't render this hand at all. * @return If true, then don't render this hand at all.
*
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
public static boolean onRenderHand(Hand hand, public static boolean onRenderHand(Hand hand,
@@ -442,7 +439,6 @@ public class TimerUtils
* needed. * needed.
* *
* @return If true, then cancel drawing the crosshair. * @return If true, then cancel drawing the crosshair.
*
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
public static boolean drawCrosshair(float ticks) public static boolean drawCrosshair(float ticks)
@@ -479,8 +475,8 @@ public class TimerUtils
> 0) > 0)
{ {
setAlpha(Main.getAlpha(crosshairTime > 0 ? setAlpha(Main.getAlpha(crosshairTime > 0 ?
crosshairTime : crosshairTime :
CROSSHAIR_TIME, CROSSHAIR_TIME, 0, 0)); CROSSHAIR_TIME, CROSSHAIR_TIME, 0, 0));
} }
else else
{ {
@@ -499,7 +495,6 @@ public class TimerUtils
* as needed. * as needed.
* *
* @return If true, then cancel drawing the mount health bar. * @return If true, then cancel drawing the mount health bar.
*
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
public static boolean drawMountHealth(MatrixStack stack, float ticks) public static boolean drawMountHealth(MatrixStack stack, float ticks)
@@ -543,8 +538,8 @@ public class TimerUtils
if (changed) if (changed)
{ {
mountTime = healthTimes.getMaxTime() - (mountTime > 0 ? mountTime = healthTimes.getMaxTime() - (mountTime > 0 ?
healthTimes.getFadeInTime() : healthTimes.getFadeInTime() :
0); 0);
} }
else if (mountTime > 0) else if (mountTime > 0)
{ {
@@ -631,7 +626,6 @@ public class TimerUtils
* Obtains how transparent * Obtains how transparent
* *
* @param effectinstance * @param effectinstance
*
* @return * @return
*/ */
public static float getPotionAlpha(StatusEffectInstance effectinstance) public static float getPotionAlpha(StatusEffectInstance effectinstance)
@@ -643,7 +637,8 @@ public class TimerUtils
if (effectinstance.getDuration() <= BLINK_TIME) if (effectinstance.getDuration() <= BLINK_TIME)
{ {
effectAlpha = effectAlpha =
MathHelper.sin(7000F / (effectinstance.getDuration() + 16F * (float) Math.PI)) * 50F / (effectinstance MathHelper.sin(7000F / (effectinstance
.getDuration() + 16F * (float) Math.PI)) * 50F / (effectinstance
.getDuration() + 100F) + 0.5F; .getDuration() + 100F) + 0.5F;
} }
else if (effectinstance.getDuration() <= BLINK_TIME + potion.getFadeInTime()) else if (effectinstance.getDuration() <= BLINK_TIME + potion.getFadeInTime())
@@ -668,7 +663,6 @@ public class TimerUtils
* needed. * needed.
* *
* @return If true, then cancel drawing the armor bar. * @return If true, then cancel drawing the armor bar.
*
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
public static boolean drawArmor() public static boolean drawArmor()
@@ -696,7 +690,6 @@ public class TimerUtils
* needed. * needed.
* *
* @return If true, then cancel drawing the health. * @return If true, then cancel drawing the health.
*
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
public static boolean drawHealth(float ticks) public static boolean drawHealth(float ticks)
@@ -740,8 +733,8 @@ public class TimerUtils
if (changed) if (changed)
{ {
healthTime = healthTimes.getMaxTime() - (healthTime > 0 ? healthTime = healthTimes.getMaxTime() - (healthTime > 0 ?
healthTimes.getFadeInTime() : healthTimes.getFadeInTime() :
0); 0);
} }
else if (healthTime > 0) else if (healthTime > 0)
{ {
@@ -772,7 +765,6 @@ public class TimerUtils
* needed. * needed.
* *
* @return If true, then cancel drawing the hunger bar. * @return If true, then cancel drawing the hunger bar.
*
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
public static boolean drawHunger(float ticks) public static boolean drawHunger(float ticks)
@@ -819,8 +811,8 @@ public class TimerUtils
if (changed) if (changed)
{ {
hungerTime = hungerTimes.getMaxTime() - (hungerTime > 0 ? hungerTime = hungerTimes.getMaxTime() - (hungerTime > 0 ?
hungerTimes.getFadeInTime() : hungerTimes.getFadeInTime() :
0); 0);
} }
else if (hungerTime > 0) else if (hungerTime > 0)
{ {
@@ -851,9 +843,7 @@ public class TimerUtils
* as needed. * as needed.
* *
* @param stack * @param stack
*
* @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
*/ */
public static boolean drawJumpbar(MatrixStack stack, float ticks) public static boolean drawJumpbar(MatrixStack stack, float ticks)
@@ -872,11 +862,11 @@ public class TimerUtils
return true; return true;
} }
if (entity.getMountJumpStrength() > 0) if (entity.method_3151() > 0)
{ {
jumpTime = jump.getMaxTime() - (jumpTime > 0 ? jumpTime = jump.getMaxTime() - (jumpTime > 0 ?
jump.getFadeInTime() : jump.getFadeInTime() :
0); 0);
} }
else if (jumpTime > 0) else if (jumpTime > 0)
{ {
@@ -900,7 +890,6 @@ public class TimerUtils
* as needed. * as needed.
* *
* @return If true, then cancel drawing the experience bar. * @return If true, then cancel drawing the experience bar.
*
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
public static boolean drawExperience(MatrixStack stack, float ticks) public static boolean drawExperience(MatrixStack stack, float ticks)
@@ -929,8 +918,8 @@ public class TimerUtils
if (changed) if (changed)
{ {
experienceTime = experience.getMaxTime() - (experienceTime > 0 ? experienceTime = experience.getMaxTime() - (experienceTime > 0 ?
experience.getFadeInTime() : experience.getFadeInTime() :
0); 0);
} }
else if (experienceTime > 0) else if (experienceTime > 0)
{ {
@@ -955,7 +944,6 @@ public class TimerUtils
* or not to draw it. * or not to draw it.
* *
* @return If true, then cancel drawing the hotbar. * @return If true, then cancel drawing the hotbar.
*
* @see #recolorHotbar(MatrixStack) * @see #recolorHotbar(MatrixStack)
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
@@ -1064,7 +1052,7 @@ public class TimerUtils
{ {
if (entity.isUsingItem() && entity if (entity.isUsingItem() && entity
.getActiveHand() != null && entity.getActiveHand() .getActiveHand() != null && entity.getActiveHand()
.ordinal() == i) .ordinal() == i)
{ {
switch (i) switch (i)
{ {
@@ -1127,11 +1115,11 @@ public class TimerUtils
if (item.isFood()) if (item.isFood())
{ {
healthTime = health.getMaxTime() - (healthTime > 0 ? healthTime = health.getMaxTime() - (healthTime > 0 ?
health.getFadeInTime() : health.getFadeInTime() :
0); 0);
hungerTime = hunger.getMaxTime() - (hungerTime > 0 ? hungerTime = hunger.getMaxTime() - (hungerTime > 0 ?
hunger.getFadeInTime() : hunger.getFadeInTime() :
0); 0);
} }
if (i == 0) if (i == 0)
{ {
@@ -1150,9 +1138,9 @@ public class TimerUtils
/* /*
* Checks for a change in what slot is used. * Checks for a change in what slot is used.
*/ */
if (selectedHotbarSlot != entity.getInventory().selectedSlot) if (selectedHotbarSlot != entity.inventory.selectedSlot)
{ {
selectedHotbarSlot = entity.getInventory().selectedSlot; selectedHotbarSlot = entity.inventory.selectedSlot;
mainHandTime = handTime; mainHandTime = handTime;
changed = true; changed = true;
} }
@@ -1160,8 +1148,8 @@ public class TimerUtils
if (changed) if (changed)
{ {
hotbarTime = hotbar.getMaxTime() - (hotbarTime > 0 ? hotbarTime = hotbar.getMaxTime() - (hotbarTime > 0 ?
hotbar.getFadeInTime() : hotbar.getFadeInTime() :
0); 0);
} }
else if (hotbarTime > 0) else if (hotbarTime > 0)
{ {
@@ -1175,25 +1163,19 @@ public class TimerUtils
* Determines whether or not to draw the crosshair, adjusting the alpha as * Determines whether or not to draw the crosshair, adjusting the alpha as
* needed. * needed.
* *
* @return If true, then cancel drawing the crosshair.
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
public static void recolorHotbar(MatrixStack stack) public static void recolorHotbar(MatrixStack stack)
{ {
ConfigManager.TimeValues hotbar = ConfigManager.TimeValues hotbar =
ConfigManager.getInstance().getHotbarTime(); ConfigManager.getInstance().getHotbarTime();
// RenderSystem.pushMatrix(); RenderSystem.pushMatrix();
stack.push(); stack.push();
stack.translate(0F, TimerUtils.getHotbarTranslation(), 0F); RenderSystem.translatef(0F, TimerUtils.getHotbarTranslation(), 0F);
setAlpha(Main.getAlpha(hotbarTime, setAlpha(Main.getAlpha(hotbarTime,
hotbar.getMaxTime(), hotbar.getMaxTime(),
hotbar.getFadeInTime(), hotbar.getFadeInTime(),
hotbar.getFadeOutTime())); hotbar.getFadeOutTime()));
/*
* Update the hotbar item matrix
*/
stack = RenderSystem.getModelViewStack();
stack.push();
stack.translate(0F, TimerUtils.getHotbarTranslation(), 0F);
RenderSystem.applyModelViewMatrix();
} }
} }

View File

View File

10
src/main/java/markil3/immersive_hud/mixin/HudHook.java Executable file → Normal file
View File

@@ -40,7 +40,7 @@ import markil3.immersive_hud.TimerUtils;
* that most of the logic can be found in {@link TimerUtils}. * that most of the logic can be found in {@link TimerUtils}.
* *
* @author Markil 3 * @author Markil 3
* @version 1.1.1-1.17-fabric * @version 0.1-1.16.4-fabric
*/ */
@Mixin(InGameHud.class) @Mixin(InGameHud.class)
public class HudHook public class HudHook
@@ -634,7 +634,7 @@ public class HudHook
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
@Inject(method = "renderHotbar", at = @At(value = "INVOKE", target = @Inject(method = "renderHotbar", at = @At(value = "INVOKE", target =
"Lcom/mojang/blaze3d/systems/RenderSystem;setShaderColor(FFFF)V", shift "Lcom/mojang/blaze3d/systems/RenderSystem;color4f(FFFF)V", shift
= At.Shift.AFTER)) = At.Shift.AFTER))
public void adjustHotbar(float tickDelta, public void adjustHotbar(float tickDelta,
MatrixStack matrices, MatrixStack matrices,
@@ -661,7 +661,7 @@ public class HudHook
* @param stack - The matrix drawing stack. * @param stack - The matrix drawing stack.
* @param callbackInfo * @param callbackInfo
* *
* @version 1.1.1-1.17-fabric * @version 0.2-1.16.4-fabric
* @since 0.1-1.16.4-fabric * @since 0.1-1.16.4-fabric
*/ */
@Inject(method = "renderHotbar", at = @At(value = "TAIL")) @Inject(method = "renderHotbar", at = @At(value = "TAIL"))
@@ -671,10 +671,8 @@ public class HudHook
{ {
try try
{ {
RenderSystem.popMatrix();
stack.pop(); stack.pop();
stack = RenderSystem.getModelViewStack();
stack.pop();
RenderSystem.applyModelViewMatrix();
/* /*
* Resets the color so that nothing else is bothered. * Resets the color so that nothing else is bothered.
*/ */

0
src/main/resources/assets/immersive_hud/icon.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 380 KiB

After

Width:  |  Height:  |  Size: 380 KiB

View File

View File

@@ -34,9 +34,8 @@
], ],
"depends": { "depends": {
"fabricloader": ">=0.11.3", "fabricloader": ">=0.7.4",
"minecraft": "1.17.x", "minecraft": "1.16.x"
"java": ">=16"
}, },
"suggests": { "suggests": {
"modmenu": "*", "modmenu": "*",

View File

@@ -2,7 +2,7 @@
"required": true, "required": true,
"minVersion": "0.8", "minVersion": "0.8",
"package": "markil3.immersive_hud.mixin", "package": "markil3.immersive_hud.mixin",
"compatibilityLevel": "JAVA_16", "compatibilityLevel": "JAVA_8",
"mixins": [ "mixins": [
], ],
"client": [ "client": [