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

Commit

Permalink
✨ Re added Custom Chat
Browse files Browse the repository at this point in the history
🐛 Fixed UI from disappearing when another ui is open
  • Loading branch information
Hexeption committed Apr 23, 2017
1 parent 2d761f6 commit 6e810a0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/main/java/uk/co/hexeption/darkforge/DarkForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import uk.co.hexeption.darkforge.api.logger.LogHelper;
import uk.co.hexeption.darkforge.gui.gui.ClickGuiScreen;
import uk.co.hexeption.darkforge.gui.gui.theme.themes.darkforge.DarkForgeTheme;
import uk.co.hexeption.darkforge.hook.HGuiInGame;
import uk.co.hexeption.darkforge.managers.*;
import uk.co.hexeption.darkforge.notification.Notification;
import uk.co.hexeption.darkforge.ui.hud.Hud;
Expand Down Expand Up @@ -60,9 +59,6 @@ public enum DarkForge {

public void start() {

Minecraft mc = Minecraft.getMinecraft();
mc.ingameGUI = new HGuiInGame(mc);

LogHelper.info("Loading Mods...");
modManager.Initialization();

Expand Down
23 changes: 21 additions & 2 deletions src/main/java/uk/co/hexeption/darkforge/hook/HGuiInGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,39 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiIngame;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import uk.co.hexeption.darkforge.event.Event;
import uk.co.hexeption.darkforge.event.events.EventRenderScreen;
import uk.co.hexeption.darkforge.gui.screen.DarkForgeChat;
import uk.co.hexeption.darkforge.managers.EventManager;
import uk.co.hexeption.darkforge.utils.ReflectionHelper;

/**
* Created by Keir on 22/04/2017.
*/
public class HGuiInGame extends GuiIngame {

public HGuiInGame(Minecraft mcIn) {
super(mcIn);
private final Minecraft mc;

public HGuiInGame(Minecraft mc) {

super(mc);
this.mc = mc;
ReflectionHelper.setPersistantChatGUI(this, new DarkForgeChat(mc));

}

@Override
public void renderGameOverlay(float partialTicks) {

super.renderGameOverlay(partialTicks);

GlStateManager.pushMatrix();
EventRenderScreen event = new EventRenderScreen(Event.Type.POST, mc.displayWidth, mc.displayHeight);
EventManager.handleEvent(event);
GlStateManager.popMatrix();
}

@Override
protected void renderPotionEffects(ScaledResolution resolution) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.Session;
import net.minecraft.util.Timer;
import org.apache.commons.lang3.JavaVersion;
Expand All @@ -39,10 +37,10 @@
import uk.co.hexeption.darkforge.DarkForge;
import uk.co.hexeption.darkforge.MC;
import uk.co.hexeption.darkforge.event.Event;
import uk.co.hexeption.darkforge.event.events.EventRenderScreen;
import uk.co.hexeption.darkforge.event.events.EventTick;
import uk.co.hexeption.darkforge.event.events.EventWorld;
import uk.co.hexeption.darkforge.gui.screen.DarkForgeMainMenu;
import uk.co.hexeption.darkforge.hook.HGuiInGame;
import uk.co.hexeption.darkforge.managers.EventManager;
import uk.co.hexeption.darkforge.mixin.imp.IMixinMinecraft;
import uk.co.hexeption.darkforge.utils.InputHandler;
Expand All @@ -60,9 +58,11 @@ public abstract class MixinMinecraft implements IMixinMinecraft, MC {
@Shadow
@Nullable
public GuiScreen currentScreen;

@Shadow
@Final
private Timer timer;

@Mutable
@Shadow
@Final
Expand All @@ -77,6 +77,7 @@ public abstract class MixinMinecraft implements IMixinMinecraft, MC {

@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;checkGLError(Ljava/lang/String;)V", ordinal = 2, shift = At.Shift.AFTER))
private void IstartGame(CallbackInfo callback) {

if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) {
DarkForge.INSTANCE.start();
} else {
Expand All @@ -86,37 +87,31 @@ private void IstartGame(CallbackInfo callback) {

@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))
private void IrunGameLoop(CallbackInfo callback) {

EventTick event = new EventTick(Event.Type.PRE);
EventManager.handleEvent(event);
}

@Inject(method = "runTickKeyboard", at = @At(value = "INVOKE", remap = false, target = "Lorg/lwjgl/input/Keyboard;getEventKey()I", ordinal = 0, shift = At.Shift.BEFORE))
public void IrunTickKeyboard(CallbackInfo callback) {

if (Keyboard.getEventKeyState()) {
InputHandler.handleKeyboard();
}
}

@Inject(method = "runTickMouse", at = @At(value = "INVOKE", remap = false, target = "Lorg/lwjgl/input/Mouse;getEventButton()I", ordinal = 0, shift = At.Shift.BEFORE))
public void IrunTickMouse(CallbackInfo callback) {

if (Mouse.getEventButtonState()) {
InputHandler.handleMouse();
}
}

@Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/EntityRenderer;updateCameraAndRender(FJ)V", shift = At.Shift.AFTER))
private void IrenderScreenPost(CallbackInfo callback) {
if (!((Minecraft) (Object) this).skipRenderWorld) {
GlStateManager.pushMatrix();
ScaledResolution res = new ScaledResolution((Minecraft) (Object) this);
EventRenderScreen event = new EventRenderScreen(Event.Type.POST, res.getScaledWidth(), res.getScaledHeight());
EventManager.handleEvent(event);
GlStateManager.popMatrix();
}
}

@Inject(method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at = @At("HEAD"))
public void loadWorld(@Nullable WorldClient worldClientIn, String loadingMessage, CallbackInfo callback) {

mc.ingameGUI = new HGuiInGame(mc);
Event event;
if (worldClientIn != null) {
event = new EventWorld.Load(Event.Type.PRE, worldClientIn);
Expand All @@ -137,16 +132,19 @@ public void runTick(CallbackInfo callbackInfo) {

@Override
public Session getSession() {

return session;
}

@Override
public void setSession(Session session) {

this.session = session;
}

@Override
public Timer getTimer() {

return timer;
}
}
3 changes: 2 additions & 1 deletion src/main/java/uk/co/hexeption/darkforge/ui/hud/Hud.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ public void onNextTheme() {

@Override
public void onEvent(Event event) {

if (event instanceof EventRenderScreen) {
if (Minecraft.getMinecraft().gameSettings.showDebugInfo || Minecraft.getMinecraft().currentScreen != null)
if (Minecraft.getMinecraft().gameSettings.showDebugInfo)
return;

IGameHud currentTheme = getCurrentTheme();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/uk/co/hexeption/darkforge/ui/tab/Tab.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void onNextTheme() {
@Override
public void onEvent(Event event) {
if (event instanceof EventRenderScreen) {
if (Minecraft.getMinecraft().gameSettings.showDebugInfo || Minecraft.getMinecraft().currentScreen != null)
if (Minecraft.getMinecraft().gameSettings.showDebugInfo)
return;


Expand Down

0 comments on commit 6e810a0

Please sign in to comment.