Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 47ec9a9

Browse files
committed
(1.16, 1.21.1) fix HotbarHUD
1 parent 8904450 commit 47ec9a9

File tree

4 files changed

+10
-178
lines changed

4 files changed

+10
-178
lines changed

1.16_combat-6/src/main/java/io/github/axolotlclient/bridge/mixin/PlatformDispatchMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public ClientConnection getConnection() {
124124
final var minecraft = MinecraftClient.getInstance();
125125
final var serverEntry = minecraft.getCurrentServerEntry();
126126

127-
final var img = NativeImage.read(Objects.requireNonNull(serverEntry == null ? minecraft.getServer().getServerMetadata().getFavicon() : serverEntry.getIcon()));
127+
final var img = NativeImage.read(Objects.requireNonNull(serverEntry == null ? minecraft.getServer().getServerMetadata().getFavicon().substring("data:image/png;base64,".length()) : serverEntry.getIcon()));
128128
final var icon = new NativeImageBackedTexture(img);
129129
final var iconId = new Identifier("axolotlclient",
130130
serverEntry == null ? "worlds/" + Hashing.sha1().hashUnencodedChars(((MinecraftServerAccessor) minecraft.getServer()).getStorageSource().getDirectoryName()) + "/icon" :

1.16_combat-6/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public void renderComponent(AxoRenderContext context, float delta) {
6262
? (PlayerEntity) MinecraftClient.getInstance().cameraEntity
6363
: null;
6464
if (playerEntity != null) {
65-
//scale(matrices);
6665
DrawPosition pos = getPos();
6766

6867
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
@@ -72,7 +71,6 @@ public void renderComponent(AxoRenderContext context, float delta) {
7271
Arm arm = playerEntity.getMainArm().getOpposite();
7372

7473
matrices.br$pushMatrix();
75-
matrices.br$translateMatrix(0, -90, 0);
7674
drawTexture(matrices, pos.x, pos.y, 0, 0, 182, 22, 256, 256);
7775
drawTexture(matrices, pos.x - 1 + playerEntity.inventory.selectedSlot * 20, pos.y - 1, 0, 22, 24,
7876
22, 256, 256);

1.21/src/main/java/io/github/axolotlclient/mixin/InGameHudMixin.java

Lines changed: 8 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import com.llamalad7.mixinextras.expression.Expression;
2626
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
27+
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
2728
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
2829
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
2930
import com.llamalad7.mixinextras.sugar.Local;
@@ -46,17 +47,13 @@
4647
import net.minecraft.entity.Entity;
4748
import net.minecraft.entity.player.PlayerEntity;
4849
import net.minecraft.scoreboard.ScoreboardObjective;
49-
import net.minecraft.text.StringVisitable;
5050
import net.minecraft.text.Text;
5151
import org.jetbrains.annotations.Nullable;
5252
import org.spongepowered.asm.mixin.Mixin;
5353
import org.spongepowered.asm.mixin.Shadow;
5454
import org.spongepowered.asm.mixin.injection.At;
5555
import org.spongepowered.asm.mixin.injection.Inject;
56-
import org.spongepowered.asm.mixin.injection.ModifyArgs;
57-
import org.spongepowered.asm.mixin.injection.Redirect;
5856
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
59-
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
6057

6158
@Mixin(InGameHud.class)
6259
public abstract class InGameHudMixin {
@@ -134,91 +131,16 @@ private void onHudRender(GuiGraphics graphics, DeltaTracker tracker, CallbackInf
134131
}
135132
}
136133

137-
@Inject(method = "renderHotbar", at = @At("HEAD"), cancellable = true)
138-
public void axolotlclient$customHotbar(GuiGraphics graphics, DeltaTracker tracker, CallbackInfo ci) {
139-
if (!HudManager.getInstance().hudsEnabled()) return;
134+
@WrapMethod(method = "renderHotbar")
135+
public void axolotlclient$customHotbar(GuiGraphics graphics, DeltaTracker tracker, Operation<Void> original) {
140136
HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID);
137+
graphics.getMatrices().push();
141138
if (hud.isEnabled()) {
142-
ci.cancel();
143-
}
144-
}
145-
146-
@ModifyArgs(method = "renderHeldItemTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawTextWithBackground(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;IIII)I"))
147-
public void axolotlclient$setItemNamePos(Args args) {
148-
if (!HudManager.getInstance().hudsEnabled()) return;
149-
HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID);
150-
if (hud.isEnabled()) {
151-
args.set(2, hud.getX() + (int) ((hud.getWidth() * hud.getScale())
152-
- MinecraftClient.getInstance().textRenderer.getWidth((StringVisitable) args.get(1))) / 2);
153-
args.set(3, hud.getY() - 36
154-
+ (!MinecraftClient.getInstance().interactionManager.hasStatusBars() ? 14 : 0));
155-
}
156-
}
157-
158-
@ModifyArgs(method = "renderMountJumpBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"))
159-
public void axolotlclient$moveHorseHealth(Args args) {
160-
if (!HudManager.getInstance().hudsEnabled()) return;
161-
HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID);
162-
if (hud.isEnabled()) {
163-
args.set(1, hud.getX());
164-
args.set(2, hud.getY() - 7);
165-
}
166-
}
167-
168-
@ModifyArgs(method = "renderExperienceBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawGuiTexture(Lnet/minecraft/util/Identifier;IIIIIIII)V"))
169-
public void axolotlclient$moveXPBar(Args args) {
170-
if (!HudManager.getInstance().hudsEnabled()) return;
171-
HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID);
172-
if (hud.isEnabled()) {
173-
args.set(1, hud.getX());
174-
args.set(2, hud.getY() - 7);
175-
}
176-
}
177-
178-
@WrapOperation(method = "renderExperienceBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;getScaledWindowHeight()I"))
179-
public int axolotlclient$moveXPBarHeight(GuiGraphics instance, Operation<Integer> original) {
180-
if (!HudManager.getInstance().hudsEnabled()) return original.call(instance);
181-
HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID);
182-
if (hud.isEnabled()) {
183-
return hud.getY() + 22;
184-
}
185-
return original.call(instance);
186-
}
187-
188-
@Redirect(method = "renderExperienceLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;getScaledWindowHeight()I"))
189-
public int axolotlclient$moveXPLevelHeight(GuiGraphics instance) {
190-
HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID);
191-
if (HudManager.getInstance().hudsEnabled() && hud.isEnabled()) {
192-
return hud.getY() + 22;
193-
}
194-
return instance.getScaledWindowHeight();
195-
}
196-
197-
@Redirect(method = "renderExperienceLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;getScaledWindowWidth()I"))
198-
public int axolotlclient$moveXPLevelWidth(GuiGraphics instance) {
199-
HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID);
200-
if (HudManager.getInstance().hudsEnabled() && hud.isEnabled()) {
201-
return hud.getX() * 2 + hud.getWidth();
202-
}
203-
return instance.getScaledWindowWidth();
204-
}
205-
206-
@Redirect(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;getScaledWindowHeight()I"))
207-
public int axolotlclient$moveStatusBarsHeight(GuiGraphics instance) {
208-
HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID);
209-
if (HudManager.getInstance().hudsEnabled() && hud.isEnabled()) {
210-
return hud.getY() + 22;
211-
}
212-
return instance.getScaledWindowHeight();
213-
}
214-
215-
@Redirect(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;getScaledWindowWidth()I"))
216-
public int axolotlclient$moveStatusBarsWidth(GuiGraphics instance) {
217-
HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID);
218-
if (HudManager.getInstance().hudsEnabled() && hud.isEnabled()) {
219-
return hud.getX() * 2 + hud.getWidth();
139+
graphics.getMatrices().translate(-graphics.getScaledWindowWidth()/2f + 182/2f, -graphics.getScaledWindowHeight()+22, 0);
140+
graphics.getMatrices().translate(hud.getX(), hud.getY(), 0);
220141
}
221-
return instance.getScaledWindowWidth();
142+
original.call(graphics, tracker);
143+
graphics.getMatrices().pop();
222144
}
223145

224146
@Inject(

1.21/src/main/java/io/github/axolotlclient/modules/hud/gui/hud/vanilla/HotbarHUD.java

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -25,114 +25,26 @@
2525
import java.util.ArrayList;
2626
import java.util.List;
2727

28-
import com.mojang.blaze3d.systems.RenderSystem;
2928
import io.github.axolotlclient.AxolotlClientConfig.api.options.Option;
3029
import io.github.axolotlclient.bridge.render.AxoRenderContext;
3130
import io.github.axolotlclient.modules.hud.gui.entry.TextHudEntry;
3231
import io.github.axolotlclient.modules.hud.util.DrawPosition;
3332
import net.minecraft.client.MinecraftClient;
3433
import net.minecraft.client.gui.GuiGraphics;
35-
import net.minecraft.client.option.AttackIndicator;
36-
import net.minecraft.entity.player.PlayerEntity;
37-
import net.minecraft.item.ItemStack;
38-
import net.minecraft.util.Arm;
3934
import net.minecraft.util.Identifier;
4035

4136
import static io.github.axolotlclient.modules.hud.util.DrawUtil.drawCenteredString;
4237

4338
public class HotbarHUD extends TextHudEntry {
44-
public static final Identifier ICONS_TEXTURE = Identifier.ofDefault("textures/gui/icons.png");
4539
public static final Identifier ID = Identifier.of("axolotlclient", "hotbarhud");
46-
private static final Identifier WIDGETS_TEXTURE = Identifier.ofDefault("textures/gui/widgets.png");
47-
48-
private final MinecraftClient client = (MinecraftClient) super.client;
4940

5041
public HotbarHUD() {
5142
super(182, 22, false);
5243
}
5344

5445
@Override
5546
public void renderComponent(AxoRenderContext context, float delta) {
56-
final var graphics = (GuiGraphics) context;
57-
58-
graphics.getMatrices().push();
59-
PlayerEntity playerEntity = MinecraftClient.getInstance().cameraEntity instanceof PlayerEntity
60-
? (PlayerEntity) MinecraftClient.getInstance().cameraEntity
61-
: null;
62-
if (playerEntity != null) {
63-
ItemStack itemStack = playerEntity.getOffHandStack();
64-
Arm arm = playerEntity.getMainArm().getOpposite();
65-
DrawPosition pos = getPos();
66-
int i = pos.x() + getWidth() / 2;
67-
graphics.getMatrices().push();
68-
graphics.getMatrices().translate(0.0F, 0.0F, -90.0F);
69-
graphics.drawTexture(WIDGETS_TEXTURE, i - 91, pos.y(), 0, 0, 182, 22);
70-
graphics.drawTexture(WIDGETS_TEXTURE, i - 91 - 1 + playerEntity.getInventory().selectedSlot * 20, pos.y() - 1, 0, 22, 24, 22);
71-
if (!itemStack.isEmpty()) {
72-
if (arm == Arm.LEFT) {
73-
graphics.drawTexture(WIDGETS_TEXTURE, i - 91 - 29, pos.y() - 1, 24, 22, 29, 24);
74-
} else {
75-
graphics.drawTexture(WIDGETS_TEXTURE, i + 91, pos.y() - 1, 53, 22, 29, 24);
76-
}
77-
}
78-
79-
graphics.getMatrices().pop();
80-
int l = 1;
81-
82-
for (int m = 0; m < 9; ++m) {
83-
int n = i - 90 + m * 20 + 2;
84-
int o = pos.y() + 6 - 3;
85-
this.renderHotbarItem(graphics, n, o, delta, playerEntity, playerEntity.getInventory().main.get(m), l++);
86-
}
87-
88-
if (!itemStack.isEmpty()) {
89-
int m = pos.y() + 6 - 3;
90-
if (arm == Arm.LEFT) {
91-
this.renderHotbarItem(graphics, i - 91 - 26, m, delta, playerEntity, itemStack, l++);
92-
} else {
93-
this.renderHotbarItem(graphics, i + 91 + 10, m, delta, playerEntity, itemStack, l++);
94-
}
95-
}
96-
97-
RenderSystem.enableBlend();
98-
if (this.client.options.getAttackIndicator().get() == AttackIndicator.HOTBAR) {
99-
float f = this.client.player.getAttackCooldownProgress(0.0F);
100-
if (f < 1.0F) {
101-
int n = pos.y() + 2;
102-
int o = i + 91 + 6;
103-
if (arm == Arm.RIGHT) {
104-
o = i - 91 - 22;
105-
}
106-
107-
int p = (int) (f * 19.0F);
108-
graphics.drawTexture(ICONS_TEXTURE, o, n, 0, 94, 18, 18);
109-
graphics.drawTexture(ICONS_TEXTURE, o, n + 18 - p, 18, 112 - p, 18, p);
110-
}
111-
}
112-
113-
RenderSystem.disableBlend();
114-
}
115-
graphics.getMatrices().pop();
116-
}
117-
118-
private void renderHotbarItem(GuiGraphics graphics, int x, int y, float tickDelta, PlayerEntity player, ItemStack stack, int seed) {
119-
if (!stack.isEmpty()) {
120-
float f = (float) stack.getCooldown() - tickDelta;
121-
if (f > 0.0F) {
122-
float g = 1.0F + f / 5.0F;
123-
graphics.getMatrices().push();
124-
graphics.getMatrices().translate((float) (x + 8), (float) (y + 12), 0.0F);
125-
graphics.getMatrices().scale(1.0F / g, (g + 1.0F) / 2.0F, 1.0F);
126-
graphics.getMatrices().translate((float) (-(x + 8)), (float) (-(y + 12)), 0.0F);
127-
}
128-
129-
graphics.drawItem(player, stack, x, y, seed);
130-
if (f > 0.0F) {
131-
graphics.getMatrices().pop();
132-
}
133-
134-
graphics.drawItemInSlot(this.client.textRenderer, stack, x, y);
135-
}
47+
// this is just a matrix translate in InGameHudMixin
13648
}
13749

13850
@Override

0 commit comments

Comments
 (0)