|
24 | 24 |
|
25 | 25 | import com.llamalad7.mixinextras.expression.Expression; |
26 | 26 | import com.llamalad7.mixinextras.injector.ModifyExpressionValue; |
| 27 | +import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; |
27 | 28 | import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
28 | 29 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
29 | 30 | import com.llamalad7.mixinextras.sugar.Local; |
|
46 | 47 | import net.minecraft.entity.Entity; |
47 | 48 | import net.minecraft.entity.player.PlayerEntity; |
48 | 49 | import net.minecraft.scoreboard.ScoreboardObjective; |
49 | | -import net.minecraft.text.StringVisitable; |
50 | 50 | import net.minecraft.text.Text; |
51 | 51 | import org.jetbrains.annotations.Nullable; |
52 | 52 | import org.spongepowered.asm.mixin.Mixin; |
53 | 53 | import org.spongepowered.asm.mixin.Shadow; |
54 | 54 | import org.spongepowered.asm.mixin.injection.At; |
55 | 55 | import org.spongepowered.asm.mixin.injection.Inject; |
56 | | -import org.spongepowered.asm.mixin.injection.ModifyArgs; |
57 | | -import org.spongepowered.asm.mixin.injection.Redirect; |
58 | 56 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
59 | | -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; |
60 | 57 |
|
61 | 58 | @Mixin(InGameHud.class) |
62 | 59 | public abstract class InGameHudMixin { |
@@ -134,91 +131,16 @@ private void onHudRender(GuiGraphics graphics, DeltaTracker tracker, CallbackInf |
134 | 131 | } |
135 | 132 | } |
136 | 133 |
|
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) { |
140 | 136 | HotbarHUD hud = (HotbarHUD) HudManager.getInstance().get(HotbarHUD.ID); |
| 137 | + graphics.getMatrices().push(); |
141 | 138 | 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); |
220 | 141 | } |
221 | | - return instance.getScaledWindowWidth(); |
| 142 | + original.call(graphics, tracker); |
| 143 | + graphics.getMatrices().pop(); |
222 | 144 | } |
223 | 145 |
|
224 | 146 | @Inject( |
|
0 commit comments