diff --git a/src/main/java/me/zeroeightsix/kami/KamiMod.java b/src/main/java/me/zeroeightsix/kami/KamiMod.java
index a9b190cc..99684047 100644
--- a/src/main/java/me/zeroeightsix/kami/KamiMod.java
+++ b/src/main/java/me/zeroeightsix/kami/KamiMod.java
@@ -27,7 +27,10 @@ import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
import me.zeroeightsix.kami.setting.SettingsRegister;
import me.zeroeightsix.kami.setting.config.Configuration;
-import me.zeroeightsix.kami.util.*;
+import me.zeroeightsix.kami.util.Friends;
+import me.zeroeightsix.kami.util.LagCompensator;
+import me.zeroeightsix.kami.util.RichPresence;
+import me.zeroeightsix.kami.util.Wrapper;
import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
@@ -198,6 +201,7 @@ public class KamiMod {
ModuleManager.getModuleByName("InfoOverlay").setEnabled(true);
ModuleManager.getModuleByName("InventoryViewer").setEnabled(true);
ModuleManager.getModuleByName("ActiveModules").setEnabled(true);
+ ModuleManager.getModuleByName("FixGui").setEnabled(true);
if (((Capes) ModuleManager.getModuleByName("Capes")).startupGlobal.getValue()) {
ModuleManager.getModuleByName("Capes").setEnabled(true);
diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/gui/InventoryViewer.java b/src/main/java/me/zeroeightsix/kami/module/modules/gui/InventoryViewer.java
index 0cf20528..8e43b67b 100644
--- a/src/main/java/me/zeroeightsix/kami/module/modules/gui/InventoryViewer.java
+++ b/src/main/java/me/zeroeightsix/kami/module/modules/gui/InventoryViewer.java
@@ -1,9 +1,6 @@
package me.zeroeightsix.kami.module.modules.gui;
-import me.zeroeightsix.kami.KamiMod;
-import me.zeroeightsix.kami.gui.kami.KamiGUI;
import me.zeroeightsix.kami.gui.rgui.component.container.use.Frame;
-import me.zeroeightsix.kami.gui.rgui.util.ContainerHelper;
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
@@ -16,10 +13,8 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
-import java.util.List;
-
import static me.zeroeightsix.kami.command.Command.sendDisableMessage;
-import static me.zeroeightsix.kami.util.ColourConverter.rgbToInt;
+import static me.zeroeightsix.kami.util.GuiFrameUtil.getFrameByName;
/**
* Updated by S-B99 on 21/02/20
@@ -43,20 +38,6 @@ public class InventoryViewer extends Module {
private boolean isTop = false;
private boolean isBottom = false;
- KamiGUI kamiGUI = KamiMod.getInstance().getGuiManager();
-
- // This is bad, but without a rearchitecture, it's probably staying... - 20kdc
- private Frame getInventoryViewer() {
- kamiGUI = KamiMod.getInstance().getGuiManager();
- if (kamiGUI == null)
- return null;
- List frames = ContainerHelper.getAllChildren(Frame.class, kamiGUI);
- for (Frame frame : frames)
- if (frame.getTitle().equalsIgnoreCase("inventory viewer"))
- return frame;
- return null;
- }
-
private int invMoveHorizontal() {
if (!docking.getValue() || mcTexture.getValue()) return 0;
if (isLeft) return 45;
@@ -72,7 +53,7 @@ public class InventoryViewer extends Module {
}
private void updatePos() {
- Frame frame = getInventoryViewer();
+ Frame frame = getFrameByName("inventory viewer");
if (frame == null)
return;
isTop = frame.getDocking().isTop();
@@ -125,11 +106,11 @@ public class InventoryViewer extends Module {
@Override
public void onRender() {
- Frame frame = getInventoryViewer();
+ Frame frame = getFrameByName("inventory viewer");
if (frame == null)
return;
if (frame.isPinned()) {
- final NonNullList items = InventoryViewer.mc.player.inventory.mainInventory;
+ final NonNullList items = mc.player.inventory.mainInventory;
boxRender(frame.getX(), frame.getY());
itemRender(items, frame.getX(), frame.getY());
}
diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/hidden/FixGui.java b/src/main/java/me/zeroeightsix/kami/module/modules/hidden/FixGui.java
new file mode 100644
index 00000000..afb3cda3
--- /dev/null
+++ b/src/main/java/me/zeroeightsix/kami/module/modules/hidden/FixGui.java
@@ -0,0 +1,12 @@
+package me.zeroeightsix.kami.module.modules.hidden;
+
+import me.zeroeightsix.kami.module.Module;
+
+import static me.zeroeightsix.kami.util.GuiFrameUtil.fixFrames;
+
+@Module.Info(name = "Hidden:FixGui", category = Module.Category.HIDDEN, showOnArray = Module.ShowOnArray.OFF, description = "Moves GUI elements back on screen")
+public class FixGui extends Module {
+ public void onUpdate() {
+ fixFrames(mc);
+ }
+}
diff --git a/src/main/java/me/zeroeightsix/kami/util/GuiFrameUtil.java b/src/main/java/me/zeroeightsix/kami/util/GuiFrameUtil.java
new file mode 100644
index 00000000..bcab198f
--- /dev/null
+++ b/src/main/java/me/zeroeightsix/kami/util/GuiFrameUtil.java
@@ -0,0 +1,56 @@
+package me.zeroeightsix.kami.util;
+
+import me.zeroeightsix.kami.KamiMod;
+import me.zeroeightsix.kami.command.Command;
+import me.zeroeightsix.kami.gui.kami.KamiGUI;
+import me.zeroeightsix.kami.gui.rgui.component.container.use.Frame;
+import me.zeroeightsix.kami.gui.rgui.util.ContainerHelper;
+import net.minecraft.client.Minecraft;
+import org.lwjgl.opengl.Display;
+
+import java.util.List;
+
+/**
+ * @author S-B99
+ * Created by S-B99 on 24/03/20
+ */
+public class GuiFrameUtil {
+ // This is bad, but without a rearchitecture, it's probably staying... - 20kdc and S-B99
+ public static Frame getFrameByName(String name) {
+ KamiGUI kamiGUI = KamiMod.getInstance().getGuiManager();
+ if (kamiGUI == null)
+ return null;
+ List frames = ContainerHelper.getAllChildren(Frame.class, kamiGUI);
+ for (Frame frame : frames)
+ if (frame.getTitle().equalsIgnoreCase(name))
+ return frame;
+ return null;
+ }
+
+ /* Additional method to prevent calling kamiGui if you already have an instance */
+ public static Frame getFrameByName(KamiGUI kamiGUI, String name) {
+ if (kamiGUI == null)
+ return null;
+ List frames = ContainerHelper.getAllChildren(Frame.class, kamiGUI);
+ for (Frame frame : frames)
+ if (frame.getTitle().equalsIgnoreCase(name))
+ return frame;
+ return null;
+ }
+
+ public static void fixFrames(Minecraft mc) {
+ KamiGUI kamiGUI = KamiMod.getInstance().getGuiManager();
+ if (kamiGUI == null) return;
+ List frames = ContainerHelper.getAllChildren(Frame.class, kamiGUI);
+ for (Frame frame : frames) {
+ int divider = mc.gameSettings.guiScale;
+ if (divider == 0) divider = 4;
+ if (frame.getX() > (Display.getWidth() / divider)) {
+ frame.setX((Display.getWidth() / divider) - frame.getWidth());
+ }
+ if (frame.getY() > (Display.getHeight() / divider)) {
+ frame.setY((Display.getHeight() / divider) - frame.getHeight());
+ }
+ }
+ }
+}