From 4b9f22355a4aae881ab8e899b5dab412e407827b Mon Sep 17 00:00:00 2001 From: yurisuika Date: Sun, 23 Jan 2022 17:39:14 -0800 Subject: [PATCH] Support for Appleskin and Inventorio --- build.gradle | 4 +++ gradle.properties | 6 ++-- .../mixin/client/HUDOverlayHandlerMixin.java | 21 +++++++++++++ ...ixinInGameHud.java => InGameHudMixin.java} | 30 +++++++++---------- .../client/ui/HotbarHUDRendererMixin.java | 22 ++++++++++++++ src/main/resources/fabric.mod.json | 2 +- src/main/resources/raised.accesswidener | 2 +- src/main/resources/raised.mixins.json | 4 ++- 8 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/yurisuika/raised/mixin/client/HUDOverlayHandlerMixin.java rename src/main/java/com/yurisuika/raised/mixin/client/gui/hud/{MixinInGameHud.java => InGameHudMixin.java} (83%) create mode 100644 src/main/java/com/yurisuika/raised/mixin/client/ui/HotbarHUDRendererMixin.java diff --git a/build.gradle b/build.gradle index 05dd7818..1727138f 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,8 @@ repositories { // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // See https://docs.gradle.org/current/userguide/declaring_repositories.html // for more information about repositories. + maven { url "https://maven.ryanliptak.com/" } + maven { url 'https://jitpack.io' } } dependencies { @@ -30,6 +32,8 @@ dependencies { // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. + modCompileOnly ("squeek.appleskin:appleskin-fabric:mc1.18-2.2.0") {transitive = false} + modCompileOnly ('com.github.Lizard-Of-Oz.Inventorio:inventorio-1.18-fabric:1.18-SNAPSHOT') {transitive = false} } processResources { diff --git a/gradle.properties b/gradle.properties index bbc667ca..e5adab05 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use minecraft_version=1.18.1 - yarn_mappings=1.18.1+build.18 + yarn_mappings=1.18.1+build.22 loader_version=0.12.12 # Mod Properties - mod_version = 1.0.0 + mod_version = 1.0.1 maven_group = com.yurisuika.raised archives_base_name = raised # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.45.2+1.18 + fabric_version=0.46.2+1.18 diff --git a/src/main/java/com/yurisuika/raised/mixin/client/HUDOverlayHandlerMixin.java b/src/main/java/com/yurisuika/raised/mixin/client/HUDOverlayHandlerMixin.java new file mode 100644 index 00000000..90cf955e --- /dev/null +++ b/src/main/java/com/yurisuika/raised/mixin/client/HUDOverlayHandlerMixin.java @@ -0,0 +1,21 @@ +package com.yurisuika.raised.mixin.client; + +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import squeek.appleskin.client.HUDOverlayHandler; + +@Mixin(HUDOverlayHandler.class) +public class HUDOverlayHandlerMixin { + + @Shadow public int foodIconsOffset; + @Shadow public int FOOD_BAR_HEIGHT; + + @Redirect(method = "onPreRender", at = @At(value = "FIELD", target = "squeek/appleskin/client/HUDOverlayHandler.foodIconsOffset:I", opcode = Opcodes.PUTFIELD)) + private void modifyFoodIconsOffset(HUDOverlayHandler instance, int value) { + foodIconsOffset = FOOD_BAR_HEIGHT + 1; + } + +} \ No newline at end of file diff --git a/src/main/java/com/yurisuika/raised/mixin/client/gui/hud/MixinInGameHud.java b/src/main/java/com/yurisuika/raised/mixin/client/gui/hud/InGameHudMixin.java similarity index 83% rename from src/main/java/com/yurisuika/raised/mixin/client/gui/hud/MixinInGameHud.java rename to src/main/java/com/yurisuika/raised/mixin/client/gui/hud/InGameHudMixin.java index 35dd8efd..1867451b 100644 --- a/src/main/java/com/yurisuika/raised/mixin/client/gui/hud/MixinInGameHud.java +++ b/src/main/java/com/yurisuika/raised/mixin/client/gui/hud/InGameHudMixin.java @@ -4,72 +4,72 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.*; -@Mixin(InGameHud.class) -public class MixinInGameHud { +@Mixin(value = InGameHud.class, priority = 9001) +public class InGameHudMixin { @ModifyConstant(method = "renderExperienceBar", constant = @Constant(intValue = 31)) private int xpTextDistance(int value) { - return 32; + return value + 1; } @ModifyConstant(method = "renderHotbar", constant = @Constant(intValue = 22, ordinal = 4)) private int selectorHeight(int value) { - return 24; + return value + 2; } @ModifyConstant(method = "renderHotbar", constant = @Constant(intValue = 22, ordinal = 0)) private int hotbarDistance(int value) { - return 23; + return value + 1; } @ModifyConstant(method = "renderHotbar", constant = @Constant(intValue = 22, ordinal = 2)) private int selectorDistance(int value) { - return 23; + return value + 1; } @ModifyConstant(method = "renderMountJumpBar", constant = @Constant(intValue = 3)) private int jumpBarDistance(int value) { - return 2; + return value - 1; } @ModifyConstant(method = "renderExperienceBar", constant = @Constant(intValue = 3)) private int experienceBarDistance(int value) { - return 2; + return value - 1; } @ModifyConstant(method = "renderHeldItemTooltip", constant = @Constant(intValue = 59)) private int heldItemTooltipDistance(int value) { - return 60; + return value + 1; } @ModifyConstant(method = "renderStatusBars", constant = @Constant(intValue = 39)) private int statusBarsDistance(int value) { - return 40; + return value + 1; } @ModifyConstant(method = "renderMountHealth", constant = @Constant(intValue = 39)) private int mountHealthDistance(int value) { - return 40; + return value + 1; } @ModifyConstant(method = "renderHotbar", constant = @Constant(intValue = 23, ordinal = 1)) private int emptyOffhandDistance(int value) { - return 24; + return value + 1; } @ModifyConstant(method = "renderHotbar", constant = @Constant(intValue = 23, ordinal = 0)) private int heldOffhandDistance(int value) { - return 24; + return value + 1; } @ModifyConstant(method = "renderHotbar", constant = @Constant(intValue = 3, ordinal = 1)) private int offhandItemDistance(int value) { - return 4; + return value + 1; } @ModifyConstant(method = "renderHotbar", constant = @Constant(intValue = 3, ordinal = 0)) private int itemDistance(int value) { - return 4; + return value + 1; } } diff --git a/src/main/java/com/yurisuika/raised/mixin/client/ui/HotbarHUDRendererMixin.java b/src/main/java/com/yurisuika/raised/mixin/client/ui/HotbarHUDRendererMixin.java new file mode 100644 index 00000000..643b0413 --- /dev/null +++ b/src/main/java/com/yurisuika/raised/mixin/client/ui/HotbarHUDRendererMixin.java @@ -0,0 +1,22 @@ +package com.yurisuika.raised.mixin.client.ui; + +import me.lizardofoz.inventorio.client.ui.HotbarHUDRenderer; +import net.minecraft.client.util.Window; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(HotbarHUDRenderer.class) +public class HotbarHUDRendererMixin { + + @Redirect(method = "renderSegmentedHotbar", at = @At(value = "INVOKE", target = "net/minecraft/client/util/Window.getScaledHeight()I")) + private int modifyScaledHeight(Window instance) { + return instance.getScaledHeight() - 1; + } + + @Redirect(method = "renderHotbarAddons", at = @At(value = "INVOKE", target = "net/minecraft/client/util/Window.getScaledHeight()I")) + private int modifyAddonsScaledHeight(Window instance) { + return instance.getScaledHeight() - 1; + } + +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 127d3ad3..9da41d1f 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -4,7 +4,7 @@ "version": "${version}", "name": "Raised", - "description": "Fixes the hotbar!", + "description": "Raises the hotbar so the selector is not cut off!", "authors": [ "yurisuika" ], diff --git a/src/main/resources/raised.accesswidener b/src/main/resources/raised.accesswidener index dca2e331..72dbc3ba 100644 --- a/src/main/resources/raised.accesswidener +++ b/src/main/resources/raised.accesswidener @@ -1,3 +1,3 @@ accessWidener v1 named -accessible method net/minecraft/client/gui/hud/InGameHud renderHotbar (FLnet/minecraft/client/util/math/MatrixStack;)V +accessible method net/minecraft/client/gui/hud/InGameHud renderHotbar (FLnet/minecraft/client/util/math/MatrixStack;)V \ No newline at end of file diff --git a/src/main/resources/raised.mixins.json b/src/main/resources/raised.mixins.json index 2fd71edc..40272d10 100644 --- a/src/main/resources/raised.mixins.json +++ b/src/main/resources/raised.mixins.json @@ -6,7 +6,9 @@ "mixins": [ ], "client": [ - "client.gui.hud.MixinInGameHud" + "client.HUDOverlayHandlerMixin", + "client.gui.hud.InGameHudMixin", + "client.ui.HotbarHUDRendererMixin" ], "injectors": { "defaultRequire": 1