|
7 | 7 | import org.spongepowered.asm.mixin.injection.At; |
8 | 8 | import org.spongepowered.asm.mixin.injection.Inject; |
9 | 9 | import org.spongepowered.asm.mixin.injection.ModifyVariable; |
10 | | -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
11 | 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
12 | | -import java.util.Objects; |
13 | | -import net.minecraft.client.DeltaTracker; |
14 | | -import net.minecraft.client.Minecraft; |
15 | 11 | import net.minecraft.client.gui.Gui; |
16 | 12 | import net.minecraft.client.gui.Gui.ContextualInfo; |
17 | | -import net.minecraft.client.gui.GuiGraphicsExtractor; |
18 | 13 | import net.minecraft.world.entity.LivingEntity; |
19 | 14 |
|
20 | 15 | @Mixin(value = Gui.class) |
21 | 16 | public abstract class InGameHudMixin { |
22 | | - @Final @Shadow private Minecraft minecraft; |
23 | 17 | @Shadow protected abstract LivingEntity getPlayerVehicleWithHealth(); |
24 | 18 |
|
25 | | - private OneBarElements oneBarElements; |
26 | | - private boolean showOneBar = false; |
27 | | - |
28 | | - @Inject(at = @At("HEAD"), method = "render") |
29 | | - public void render(GuiGraphicsExtractor context, DeltaTracker tickCounter, CallbackInfo ci) { |
30 | | - oneBarElements = new OneBarElements(context); |
31 | | - showOneBar = MixinConfigQuery.isOneBarEnabled(); // This var exists because it also shows whether oneBarElements is initialized |
32 | | - |
33 | | - boolean barsVisible = !minecraft.options.hideGui && Objects.requireNonNull(minecraft.gameMode).canHurtPlayer(); |
34 | | - if(showOneBar && barsVisible) oneBarElements.renderOneBar(); |
35 | | - if(showOneBar && MixinConfigQuery.showMountJump() && !minecraft.options.hideGui) oneBarElements.mountJumpBar(); |
36 | | - |
37 | | - PlayerProperties.setLocatorBarAvailable(minecraft.player.connection.getWaypointManager().hasWaypoints()); |
38 | | - } |
39 | | - |
40 | | - @Inject(method = "renderPlayerHealth", at = @At(value = "HEAD"), cancellable = true) |
41 | | - private void hideHud(GuiGraphicsExtractor context, CallbackInfo ci){ |
42 | | - if(showOneBar && !MixinConfigQuery.isCompatModeEnabled()) |
43 | | - ci.cancel(); |
44 | | - } |
45 | | - |
46 | | - @Inject(method = "renderVehicleHealth", at = @At(value = "HEAD"), cancellable = true) |
47 | | - private void hideMountHealth(GuiGraphicsExtractor context, CallbackInfo ci) { |
48 | | - if(showOneBar && !MixinConfigQuery.isCompatModeEnabled()) |
49 | | - ci.cancel(); |
50 | | - oneBarElements.mountBar(getPlayerVehicleWithHealth()); |
51 | | - } |
| 19 | + private boolean showOneBar = MixinConfigQuery.isOneBarEnabled();; |
52 | 20 |
|
53 | 21 | @Inject(method = "nextContextualInfoState", at = @At("HEAD"), cancellable = true) |
54 | 22 | private void forceLocatorBar(CallbackInfoReturnable<ContextualInfo> cir) { |
|
0 commit comments