AppleSkin

AppleSkin

236M Downloads

[Enhancement] Add config for offsets to clientside HUD items

3x1t-5tyl3 opened this issue · 4 comments

commented

In my usecase where I disabled experience and the experience bar, it'd be great to add an offset config to the hud elements so I can align them with my own mod's way of altering the hud.

For context, I alter the vanilla hud via mixins to achieve a shift of the health and food bar. Tough as Nails just binds itself to the height of the food bar. Given potential incompatibility with raised, adding an offset would be both easy and not cause issues with other mods.

Binding to the foodHud ergo : renderFoodLevel() would also probably work?

KZpx35fJptsaQztC

commented

Edit: decided to not care anymore. Thanks anyhow for the help. I'll just disable the bars instead.

commented

What version of Minecraft are you targeting? Which of Fabric/NeoForge/Forge are you targeting? Each version/loader might work differently here, so that info is relevant (e.g. in the Fabric version for 1.21, AppleSkin hooks renderFood so it'd likely just work)


If all else fails, you can use the HUDOverlayEvent from the AppleSkin API for this purpose (just listen for it and modify the y value accordingly):

Details on how to use the AppleSkin API are in the readme for whatever branch is relevant for you.

commented

What version of Minecraft are you targeting? Which of Fabric/NeoForge/Forge are you targeting? Each version/loader might work differently here, so that info is relevant (e.g. in the Fabric version for 1.21, AppleSkin hooks renderFood so it'd likely just work)

If all else fails, you can use the HUDOverlayEvent from the AppleSkin API for this purpose (just listen for it and modify the y value accordingly):

* https://github.com/squeek502/AppleSkin/blob/1.21-fabric/java/squeek/appleskin/api/event/HUDOverlayEvent.java

* https://github.com/squeek502/AppleSkin/blob/1.21-neoforge/java/squeek/appleskin/api/event/HUDOverlayEvent.java

* (or see whatever branch is relevant for your mod)

Details on how to use the AppleSkin API are in the readme for whatever branch is relevant for you.

Personally I'm targetting exclusively NeoForge for MC-1.21 21.0.4x-beta+ (Mainly due to breaking ToolAction rename)

commented

AppleSkin uses the NeoForge RegisterGuiLayersEvent for this stuff, so in theory altering the rightHeight variable before AppleSkin reads it should make things work:

// register dummy layers that just store the gui.leftHeight/gui.rightHeight
// before they get modified during the rendering of the health/food HUD
event.registerBelow(
VanillaGuiLayers.PLAYER_HEALTH,
ResourceLocation.fromNamespaceAndPath(ModInfo.MODID, "health_offset"),
(guiGraphics, deltaTracker) -> healthIconsOffset = Minecraft.getInstance().gui.leftHeight
);
event.registerBelow(
VanillaGuiLayers.FOOD_LEVEL,
ResourceLocation.fromNamespaceAndPath(ModInfo.MODID, "food_offset"),
(guiGraphics, deltaTracker) -> foodIconsOffset = Minecraft.getInstance().gui.rightHeight
);
// register overlays/underlays.
event.registerAbove(VanillaGuiLayers.PLAYER_HEALTH, HealthOverlay.ID, new HealthOverlay());
event.registerAbove(VanillaGuiLayers.FOOD_LEVEL, HungerOverlay.ID, new HungerOverlay());
event.registerAbove(VanillaGuiLayers.FOOD_LEVEL, SaturationOverlay.ID, new SaturationOverlay());
event.registerBelow(VanillaGuiLayers.FOOD_LEVEL, ExhaustionOverlay.ID, new ExhaustionOverlay());