-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix standard HUD not moving up on Forge
- Loading branch information
Showing
6 changed files
with
107 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.demonwav.extendedhotbar; | ||
|
||
import static com.mumfrey.liteloader.gl.GL.glPopMatrix; | ||
import static com.mumfrey.liteloader.gl.GL.glPushMatrix; | ||
import static com.mumfrey.liteloader.gl.GL.glTranslated; | ||
|
||
import com.mumfrey.liteloader.core.LiteLoader; | ||
|
||
public final class Util { | ||
|
||
private static LiteModExtendedHotbar mod = null; | ||
|
||
public static final int DISTANCE = -22; | ||
|
||
private Util() {} | ||
|
||
/* | ||
* This likely doesn't need to be thread-safe. | ||
*/ | ||
public static LiteModExtendedHotbar getMod() { | ||
LiteModExtendedHotbar m = Util.mod; | ||
if (m != null) { | ||
return m; | ||
} | ||
|
||
synchronized (Util.class) { | ||
m = Util.mod; | ||
if (m != null) { | ||
return m; | ||
} | ||
|
||
m = LiteLoader.getInstance().getMod(LiteModExtendedHotbar.class); | ||
Util.mod = m; | ||
} | ||
|
||
return m; | ||
} | ||
|
||
public static void moveUp() { | ||
if (getMod().isEnabled()) { | ||
glPushMatrix(); | ||
glTranslated(0, DISTANCE, 0); | ||
} | ||
} | ||
|
||
public static void reset() { | ||
if (getMod().isEnabled()) { | ||
glPopMatrix(); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/demonwav/extendedhotbar/mixin/MixinGuiInGameForge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.demonwav.extendedhotbar.mixin; | ||
|
||
import static com.demonwav.extendedhotbar.Util.moveUp; | ||
import static com.demonwav.extendedhotbar.Util.reset; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiIngame; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Pseudo | ||
@Mixin(targets = "net.minecraftforge.client.GuiIngameForge") | ||
public abstract class MixinGuiInGameForge extends GuiIngame { | ||
|
||
public MixinGuiInGameForge(final Minecraft mcIn) { | ||
super(mcIn); | ||
} | ||
|
||
@Inject( | ||
method = "Lnet/minecraftforge/client/GuiIngameForge;renderGameOverlay(F)V", | ||
at = { | ||
@At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;renderBossHealth()V", shift = At.Shift.BY, by = 2), | ||
@At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;renderSleepFade(II)V", shift = At.Shift.AFTER) | ||
} | ||
) | ||
private void moveGuiUp(float partialTicks, final CallbackInfo info) { | ||
moveUp(); | ||
} | ||
|
||
@Inject( | ||
method = "Lnet/minecraftforge/client/GuiIngameForge;renderGameOverlay(F)V", at = { | ||
@At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;renderSleepFade(II)V"), | ||
@At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;renderFPSGraph()V") | ||
} | ||
) | ||
private void moveGuiDown(float partialTicks, final CallbackInfo info) { | ||
reset(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters