Skip to content
This repository was archived by the owner on Feb 4, 2018. It is now read-only.

Commit 6e810a0

Browse files
committed
✨ Re added Custom Chat
🐛 Fixed UI from disappearing when another ui is open
1 parent 2d761f6 commit 6e810a0

File tree

5 files changed

+36
-22
lines changed

5 files changed

+36
-22
lines changed

src/main/java/uk/co/hexeption/darkforge/DarkForge.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import uk.co.hexeption.darkforge.api.logger.LogHelper;
2626
import uk.co.hexeption.darkforge.gui.gui.ClickGuiScreen;
2727
import uk.co.hexeption.darkforge.gui.gui.theme.themes.darkforge.DarkForgeTheme;
28-
import uk.co.hexeption.darkforge.hook.HGuiInGame;
2928
import uk.co.hexeption.darkforge.managers.*;
3029
import uk.co.hexeption.darkforge.notification.Notification;
3130
import uk.co.hexeption.darkforge.ui.hud.Hud;
@@ -60,9 +59,6 @@ public enum DarkForge {
6059

6160
public void start() {
6261

63-
Minecraft mc = Minecraft.getMinecraft();
64-
mc.ingameGUI = new HGuiInGame(mc);
65-
6662
LogHelper.info("Loading Mods...");
6763
modManager.Initialization();
6864

src/main/java/uk/co/hexeption/darkforge/hook/HGuiInGame.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,39 @@
2020
import net.minecraft.client.Minecraft;
2121
import net.minecraft.client.gui.GuiIngame;
2222
import net.minecraft.client.gui.ScaledResolution;
23+
import net.minecraft.client.renderer.GlStateManager;
24+
import uk.co.hexeption.darkforge.event.Event;
25+
import uk.co.hexeption.darkforge.event.events.EventRenderScreen;
2326
import uk.co.hexeption.darkforge.gui.screen.DarkForgeChat;
27+
import uk.co.hexeption.darkforge.managers.EventManager;
2428
import uk.co.hexeption.darkforge.utils.ReflectionHelper;
2529

2630
/**
2731
* Created by Keir on 22/04/2017.
2832
*/
2933
public class HGuiInGame extends GuiIngame {
3034

31-
public HGuiInGame(Minecraft mcIn) {
32-
super(mcIn);
35+
private final Minecraft mc;
36+
37+
public HGuiInGame(Minecraft mc) {
38+
39+
super(mc);
40+
this.mc = mc;
3341
ReflectionHelper.setPersistantChatGUI(this, new DarkForgeChat(mc));
3442

3543
}
3644

45+
@Override
46+
public void renderGameOverlay(float partialTicks) {
47+
48+
super.renderGameOverlay(partialTicks);
49+
50+
GlStateManager.pushMatrix();
51+
EventRenderScreen event = new EventRenderScreen(Event.Type.POST, mc.displayWidth, mc.displayHeight);
52+
EventManager.handleEvent(event);
53+
GlStateManager.popMatrix();
54+
}
55+
3756
@Override
3857
protected void renderPotionEffects(ScaledResolution resolution) {
3958

src/main/java/uk/co/hexeption/darkforge/mixin/mixins/MixinMinecraft.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
import net.minecraft.client.Minecraft;
2121
import net.minecraft.client.gui.GuiMainMenu;
2222
import net.minecraft.client.gui.GuiScreen;
23-
import net.minecraft.client.gui.ScaledResolution;
2423
import net.minecraft.client.multiplayer.WorldClient;
25-
import net.minecraft.client.renderer.GlStateManager;
2624
import net.minecraft.util.Session;
2725
import net.minecraft.util.Timer;
2826
import org.apache.commons.lang3.JavaVersion;
@@ -39,10 +37,10 @@
3937
import uk.co.hexeption.darkforge.DarkForge;
4038
import uk.co.hexeption.darkforge.MC;
4139
import uk.co.hexeption.darkforge.event.Event;
42-
import uk.co.hexeption.darkforge.event.events.EventRenderScreen;
4340
import uk.co.hexeption.darkforge.event.events.EventTick;
4441
import uk.co.hexeption.darkforge.event.events.EventWorld;
4542
import uk.co.hexeption.darkforge.gui.screen.DarkForgeMainMenu;
43+
import uk.co.hexeption.darkforge.hook.HGuiInGame;
4644
import uk.co.hexeption.darkforge.managers.EventManager;
4745
import uk.co.hexeption.darkforge.mixin.imp.IMixinMinecraft;
4846
import uk.co.hexeption.darkforge.utils.InputHandler;
@@ -60,9 +58,11 @@ public abstract class MixinMinecraft implements IMixinMinecraft, MC {
6058
@Shadow
6159
@Nullable
6260
public GuiScreen currentScreen;
61+
6362
@Shadow
6463
@Final
6564
private Timer timer;
65+
6666
@Mutable
6767
@Shadow
6868
@Final
@@ -77,6 +77,7 @@ public abstract class MixinMinecraft implements IMixinMinecraft, MC {
7777

7878
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;checkGLError(Ljava/lang/String;)V", ordinal = 2, shift = At.Shift.AFTER))
7979
private void IstartGame(CallbackInfo callback) {
80+
8081
if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) {
8182
DarkForge.INSTANCE.start();
8283
} else {
@@ -86,37 +87,31 @@ private void IstartGame(CallbackInfo callback) {
8687

8788
@Inject(method = "runGameLoop", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/profiler/Profiler;startSection(Ljava/lang/String;)V", args = "ldc=tick", shift = At.Shift.AFTER))
8889
private void IrunGameLoop(CallbackInfo callback) {
90+
8991
EventTick event = new EventTick(Event.Type.PRE);
9092
EventManager.handleEvent(event);
9193
}
9294

9395
@Inject(method = "runTickKeyboard", at = @At(value = "INVOKE", remap = false, target = "Lorg/lwjgl/input/Keyboard;getEventKey()I", ordinal = 0, shift = At.Shift.BEFORE))
9496
public void IrunTickKeyboard(CallbackInfo callback) {
97+
9598
if (Keyboard.getEventKeyState()) {
9699
InputHandler.handleKeyboard();
97100
}
98101
}
99102

100103
@Inject(method = "runTickMouse", at = @At(value = "INVOKE", remap = false, target = "Lorg/lwjgl/input/Mouse;getEventButton()I", ordinal = 0, shift = At.Shift.BEFORE))
101104
public void IrunTickMouse(CallbackInfo callback) {
105+
102106
if (Mouse.getEventButtonState()) {
103107
InputHandler.handleMouse();
104108
}
105109
}
106110

107-
@Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/EntityRenderer;updateCameraAndRender(FJ)V", shift = At.Shift.AFTER))
108-
private void IrenderScreenPost(CallbackInfo callback) {
109-
if (!((Minecraft) (Object) this).skipRenderWorld) {
110-
GlStateManager.pushMatrix();
111-
ScaledResolution res = new ScaledResolution((Minecraft) (Object) this);
112-
EventRenderScreen event = new EventRenderScreen(Event.Type.POST, res.getScaledWidth(), res.getScaledHeight());
113-
EventManager.handleEvent(event);
114-
GlStateManager.popMatrix();
115-
}
116-
}
117-
118111
@Inject(method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at = @At("HEAD"))
119112
public void loadWorld(@Nullable WorldClient worldClientIn, String loadingMessage, CallbackInfo callback) {
113+
114+
mc.ingameGUI = new HGuiInGame(mc);
120115
Event event;
121116
if (worldClientIn != null) {
122117
event = new EventWorld.Load(Event.Type.PRE, worldClientIn);
@@ -137,16 +132,19 @@ public void runTick(CallbackInfo callbackInfo) {
137132

138133
@Override
139134
public Session getSession() {
135+
140136
return session;
141137
}
142138

143139
@Override
144140
public void setSession(Session session) {
141+
145142
this.session = session;
146143
}
147144

148145
@Override
149146
public Timer getTimer() {
147+
150148
return timer;
151149
}
152150
}

src/main/java/uk/co/hexeption/darkforge/ui/hud/Hud.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ public void onNextTheme() {
7878

7979
@Override
8080
public void onEvent(Event event) {
81+
8182
if (event instanceof EventRenderScreen) {
82-
if (Minecraft.getMinecraft().gameSettings.showDebugInfo || Minecraft.getMinecraft().currentScreen != null)
83+
if (Minecraft.getMinecraft().gameSettings.showDebugInfo)
8384
return;
8485

8586
IGameHud currentTheme = getCurrentTheme();

src/main/java/uk/co/hexeption/darkforge/ui/tab/Tab.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void onNextTheme() {
6969
@Override
7070
public void onEvent(Event event) {
7171
if (event instanceof EventRenderScreen) {
72-
if (Minecraft.getMinecraft().gameSettings.showDebugInfo || Minecraft.getMinecraft().currentScreen != null)
72+
if (Minecraft.getMinecraft().gameSettings.showDebugInfo)
7373
return;
7474

7575

0 commit comments

Comments
 (0)