Compare commits

..

7 Commits

Author SHA1 Message Date
Markil3
02dddb3257 Update gradle.properties 2021-08-30 22:30:24 -06:00
Markil3
59d2a3934c 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:23:13 -06:00
Markil3
c4fe9992b0 Changes how the mod handles status bars slightly.
This should somewhat increase compatibility with the AppleSkin mod.
2021-07-22 13:37:28 -06:00
Markil3
8646ac8ec8 Update build.yml 2021-06-18 09:32:53 -06:00
Markil3
241b8c8357 Update build.yml for 1.17 workflows 2021-06-18 09:29:19 -06:00
Markil3
4d1cf0d9e2 Fixes the inventory items not moving properly. 2021-06-18 08:46:06 -06:00
Markil3
3b73bf6cb8 Updates for Minecraft 1.17
Still needs a bit of tweaking
2021-06-18 08:27:59 -06:00
26 changed files with 160 additions and 150 deletions

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

@@ -12,9 +12,9 @@ jobs:
matrix: matrix:
# Use these Java versions # Use these Java versions
java: [ java: [
1.8, # Minimum supported by Minecraft 1.16, # Minimum supported by Minecraft
11, # Current Java LTS 16, # Current Java LTS
15 # Latest version 16 # 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 Normal file → Executable file
View File

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

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

15
build.gradle Normal file → Executable file
View File

@@ -1,10 +1,10 @@
plugins { plugins {
id 'fabric-loom' version '0.5-SNAPSHOT' id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_16
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,13 +43,8 @@ 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"
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too // Minecraft 1.17 (21w19a) upwards uses Java 16.
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. it.options.release = 16
// 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 Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 37 MiB

After

Width:  |  Height:  |  Size: 37 MiB

10
gradle.properties Normal file → Executable 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.16.4 minecraft_version=1.17
yarn_mappings=1.16.4+build.9 yarn_mappings=1.17+build.1
loader_version=0.11.1 loader_version=0.11.3
cloth_version=4.11.14 cloth_version=5.0.34
modmenu_version=1.16.8 modmenu_version=2.0.2
# 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-6.8-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

0
screenshot1.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

0
screenshot2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 767 KiB

After

Width:  |  Height:  |  Size: 767 KiB

0
screenshot3.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

0
screenshot4.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 983 KiB

After

Width:  |  Height:  |  Size: 983 KiB

0
screenshot5.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 405 KiB

After

Width:  |  Height:  |  Size: 405 KiB

0
settings.gradle Normal file → Executable file
View File

8
src/main/java/markil3/immersive_hud/ConfigManager.java Normal file → Executable 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 Normal file → Executable file
View File

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

@@ -17,7 +17,6 @@ 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;
@@ -44,8 +43,7 @@ public class ModMenu implements ModMenuApi
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud." + name + "tooltip.immersive_hud." + name +
"MaxTime")) "MaxTime"))
.setSaveConsumer(val -> value .setSaveConsumer(val -> value.setMaxTime((int) (val * TICKS_PER_SECOND)))
.setMaxTime((int) (val * TICKS_PER_SECOND)))
.build(); .build();
DoubleListEntry fadeIn = DoubleListEntry fadeIn =
@@ -59,8 +57,7 @@ public class ModMenu implements ModMenuApi
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud." + name + "tooltip.immersive_hud." + name +
"FadeIn")) "FadeIn"))
.setSaveConsumer(val -> value .setSaveConsumer(val -> value.setFadeInTime((int) (val * TICKS_PER_SECOND)))
.setFadeInTime((int) (val * TICKS_PER_SECOND)))
.build(); .build();
DoubleListEntry fadeOut = DoubleListEntry fadeOut =
@@ -74,8 +71,7 @@ public class ModMenu implements ModMenuApi
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud." + name + "tooltip.immersive_hud." + name +
"FadeOut")) "FadeOut"))
.setSaveConsumer(val -> value .setSaveConsumer(val -> value.setFadeOutTime((int) (val * TICKS_PER_SECOND)))
.setFadeOutTime((int) (val * TICKS_PER_SECOND)))
.build(); .build();
cat.addEntry(maxTime); cat.addEntry(maxTime);
@@ -97,11 +93,9 @@ public class ModMenu implements ModMenuApi
.setSavingRunnable(() -> { .setSavingRunnable(() -> {
try try
{ {
if (Class if (Class.forName("me.shedaniel.autoconfig.AutoConfig") != null)
.forName("me.shedaniel.autoconfig.AutoConfig") != null)
{ {
AutoConfig AutoConfig.getConfigHolder(ConfigManagerCloth.class)
.getConfigHolder(ConfigManagerCloth.class)
.save(); .save();
} }
} }
@@ -142,8 +136,7 @@ public class ModMenu implements ModMenuApi
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud" + "tooltip.immersive_hud" +
".crosshairTime")) ".crosshairTime"))
.setSaveConsumer(val -> instance .setSaveConsumer(val -> instance.setCrosshairTime((int) (val * TICKS_PER_SECOND)))
.setCrosshairTime((int) (val * TICKS_PER_SECOND)))
.build()); .build());
general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText( general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText(
@@ -161,8 +154,7 @@ public class ModMenu implements ModMenuApi
.setDefaultValue(30) .setDefaultValue(30)
.setTooltip(new TranslatableText( .setTooltip(new TranslatableText(
"tooltip.immersive_hud.handTime")) "tooltip.immersive_hud.handTime"))
.setSaveConsumer(val -> instance .setSaveConsumer(val -> instance.setHandTime((int) (val * TICKS_PER_SECOND)))
.setHandTime((int) (val * TICKS_PER_SECOND)))
.build()); .build());
general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText( general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText(

38
src/main/java/markil3/immersive_hud/TimerUtils.java Normal file → Executable 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 0.1-1.16.4-fabric * @version 1.1.1-1.17-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.color4f(1.0F, 1.0F, 1.0F, alpha); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha);
} }
/** /**
@@ -290,6 +290,7 @@ public class TimerUtils
* *
* @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)
@@ -373,7 +374,9 @@ public class TimerUtils
* *
* @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,
@@ -439,6 +442,7 @@ 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)
@@ -495,6 +499,7 @@ 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)
@@ -626,6 +631,7 @@ 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)
@@ -637,8 +643,7 @@ public class TimerUtils
if (effectinstance.getDuration() <= BLINK_TIME) if (effectinstance.getDuration() <= BLINK_TIME)
{ {
effectAlpha = effectAlpha =
MathHelper.sin(7000F / (effectinstance MathHelper.sin(7000F / (effectinstance.getDuration() + 16F * (float) Math.PI)) * 50F / (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())
@@ -663,6 +668,7 @@ 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()
@@ -690,6 +696,7 @@ 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)
@@ -765,6 +772,7 @@ 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)
@@ -843,7 +851,9 @@ 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)
@@ -862,7 +872,7 @@ public class TimerUtils
return true; return true;
} }
if (entity.method_3151() > 0) if (entity.getMountJumpStrength() > 0)
{ {
jumpTime = jump.getMaxTime() - (jumpTime > 0 ? jumpTime = jump.getMaxTime() - (jumpTime > 0 ?
jump.getFadeInTime() : jump.getFadeInTime() :
@@ -890,6 +900,7 @@ 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)
@@ -944,6 +955,7 @@ 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
*/ */
@@ -1138,9 +1150,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.inventory.selectedSlot) if (selectedHotbarSlot != entity.getInventory().selectedSlot)
{ {
selectedHotbarSlot = entity.inventory.selectedSlot; selectedHotbarSlot = entity.getInventory().selectedSlot;
mainHandTime = handTime; mainHandTime = handTime;
changed = true; changed = true;
} }
@@ -1163,19 +1175,25 @@ 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();
RenderSystem.translatef(0F, TimerUtils.getHotbarTranslation(), 0F); stack.translate(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 Normal file → Executable 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 0.1-1.16.4-fabric * @version 1.1.1-1.17-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;color4f(FFFF)V", shift "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderColor(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 0.2-1.16.4-fabric * @version 1.1.1-1.17-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,8 +671,10 @@ 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 Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 380 KiB

After

Width:  |  Height:  |  Size: 380 KiB

View File

View File

@@ -34,8 +34,9 @@
], ],
"depends": { "depends": {
"fabricloader": ">=0.7.4", "fabricloader": ">=0.11.3",
"minecraft": "1.16.x" "minecraft": "1.17.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_8", "compatibilityLevel": "JAVA_16",
"mixins": [ "mixins": [
], ],
"client": [ "client": [