diff options
author | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-15 18:28:38 -0230 |
---|---|---|
committer | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-15 18:28:38 -0230 |
commit | d447859cc3b850551191cabf832d3ab305758a9e (patch) | |
tree | 47c785977c9d144765d6e4459f1ffdc4601fda67 /src | |
parent | db6b8d152adf270035a274046afc6220a85eadb2 (diff) | |
download | SkyblockHud-Death-Defied-d447859cc3b850551191cabf832d3ab305758a9e.tar.gz SkyblockHud-Death-Defied-d447859cc3b850551191cabf832d3ab305758a9e.tar.bz2 SkyblockHud-Death-Defied-d447859cc3b850551191cabf832d3ab305758a9e.zip |
Fixed issue with hudcaching and sbh not being able to remove hud elements
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java | 4 | ||||
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java | 43 |
2 files changed, 25 insertions, 22 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java index bf38d49..e7143a9 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java @@ -1,7 +1,5 @@ package com.thatgravyboat.skyblockhud.handlers; -import static com.thatgravyboat.skyblockhud.GuiTextures.mapOverlay; - import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.config.KeyBindings; @@ -26,6 +24,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.opengl.GL11; +import static com.thatgravyboat.skyblockhud.GuiTextures.mapOverlay; + public class MapHandler { public enum MapIconTypes { diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java index 5d64950..746d917 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java @@ -1,7 +1,5 @@ package com.thatgravyboat.skyblockhud.mixins; -import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.*; - import com.thatgravyboat.skyblockhud.SkyblockHud; import com.thatgravyboat.skyblockhud.Utils; import com.thatgravyboat.skyblockhud.overlay.MiningHud; @@ -11,10 +9,13 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.*; + @Mixin(GuiIngameForge.class) public class MixinGuiIngameForge { @@ -25,8 +26,8 @@ public class MixinGuiIngameForge { public void onRenderArmor(int width, int height, CallbackInfo ci) { if (SkyblockHud.config.renderer.hideArmor && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); - if (pre(ARMOR)) return; - post(ARMOR); + if (prePost(ARMOR, eventParent)) return; + postPost(ARMOR, eventParent); } } @@ -34,8 +35,8 @@ public class MixinGuiIngameForge { public void onRenderHealth(int width, int height, CallbackInfo ci) { if (SkyblockHud.config.renderer.hideHearts && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); - if (pre(HEALTH)) return; - post(HEALTH); + if (prePost(HEALTH, eventParent)) return; + postPost(HEALTH, eventParent); } } @@ -43,8 +44,8 @@ public class MixinGuiIngameForge { public void onRenderAir(int width, int height, CallbackInfo ci) { if (SkyblockHud.config.renderer.hideAir && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); - if (pre(AIR)) return; - post(AIR); + if (prePost(AIR, eventParent)) return; + postPost(AIR, eventParent); } } @@ -52,8 +53,8 @@ public class MixinGuiIngameForge { public void onRenderHealthMount(int width, int height, CallbackInfo ci) { if (SkyblockHud.config.renderer.hideAnimalHearts && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); - if (pre(HEALTHMOUNT)) return; - post(HEALTHMOUNT); + if (prePost(HEALTHMOUNT, eventParent)) return; + postPost(HEALTHMOUNT, eventParent); } } @@ -61,13 +62,13 @@ public class MixinGuiIngameForge { public void onRenderExperience(int width, int height, CallbackInfo ci) { if (SkyblockHud.config.renderer.hideXpBar && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); - if (pre(EXPERIENCE)) return; - post(EXPERIENCE); + if (prePost(EXPERIENCE, eventParent)) return; + postPost(EXPERIENCE, eventParent); } else if (!SkyblockHud.config.renderer.hideXpBar && (SkyblockHud.config.mining.showDrillBar || SkyblockHud.config.mining.showHeatBar) && SkyblockHud.hasSkyblockScoreboard()) { if (MiningHud.getHeat() > 0 || Utils.isDrill(Minecraft.getMinecraft().thePlayer.getHeldItem())) { ci.cancel(); - if (pre(EXPERIENCE)) return; - post(EXPERIENCE); + if (prePost(EXPERIENCE, eventParent)) return; + postPost(EXPERIENCE, eventParent); } } } @@ -76,8 +77,8 @@ public class MixinGuiIngameForge { public void onRenderJumpBar(int width, int height, CallbackInfo ci) { if (SkyblockHud.config.renderer.hideXpBar && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); - if (pre(JUMPBAR)) return; - post(JUMPBAR); + if (prePost(JUMPBAR, eventParent)) return; + postPost(JUMPBAR, eventParent); } } @@ -85,16 +86,18 @@ public class MixinGuiIngameForge { public void onRenderFood(int width, int height, CallbackInfo ci) { if (SkyblockHud.config.renderer.hideFood && SkyblockHud.hasSkyblockScoreboard()) { ci.cancel(); - if (pre(FOOD)) return; - post(FOOD); + if (prePost(FOOD, eventParent)) return; + postPost(FOOD, eventParent); } } - private boolean pre(RenderGameOverlayEvent.ElementType type) { + @Unique + private static boolean prePost(RenderGameOverlayEvent.ElementType type, RenderGameOverlayEvent eventParent) { return MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Pre(eventParent, type)); } - private void post(RenderGameOverlayEvent.ElementType type) { + @Unique + private static void postPost(RenderGameOverlayEvent.ElementType type, RenderGameOverlayEvent eventParent) { MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(eventParent, type)); } } |