aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-04 13:36:51 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-04 13:36:51 +0200
commit8df18aacd08a0b6caf612a31d578dd6e6d5fa31a (patch)
tree988f84d67dda81d549c5f81806859445b61df72f /src/main/java/cc/polyfrost/oneconfig
parenta4d135ebb02c6fea87c8f9275a8a07338999d84b (diff)
parentd77df8fd5fa42b35c3e655f8e95874338b611901 (diff)
downloadOneConfig-8df18aacd08a0b6caf612a31d578dd6e6d5fa31a.tar.gz
OneConfig-8df18aacd08a0b6caf612a31d578dd6e6d5fa31a.tar.bz2
OneConfig-8df18aacd08a0b6caf612a31d578dd6e6d5fa31a.zip
Merge branch 'master' of github.com:Polyfrost/OneConfig
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/OneConfig.java35
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java11
2 files changed, 28 insertions, 18 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
index 7b42fe9..2cead04 100644
--- a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java
@@ -8,13 +8,9 @@ import cc.polyfrost.oneconfig.config.data.ModType;
import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.hud.HudCore;
import cc.polyfrost.oneconfig.lwjgl.BlurHandler;
-import cc.polyfrost.oneconfig.lwjgl.RenderManager;
-import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
-import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.test.TestConfig;
import cc.polyfrost.oneconfig.utils.commands.CommandManager;
import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils;
-import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
@@ -35,34 +31,37 @@ public class OneConfig {
public static TestConfig testConfig;
public static final List<Mod> loadedMods = new ArrayList<>();
public static final List<ModMetadata> loadedOtherMods = new ArrayList<>();
+ private static boolean preLaunched = false;
+ private static boolean initialized = false;
- @net.minecraftforge.fml.common.Mod.EventHandler
- public void onPreFMLInit(net.minecraftforge.fml.common.event.FMLPreInitializationEvent event) {
- if (!Launch.blackboard.containsKey("oneconfig.initialized")) {
+ /**
+ * Called before mods are loaded.
+ * <p><b>SHOULD NOT BE CALLED!</b></p>
+ */
+ public static void preLaunch() {
+ if (preLaunched) return;
+ if (!net.minecraft.launchwrapper.Launch.blackboard.containsKey("oneconfig.initialized")) {
throw new RuntimeException("OneConfig has not been initialized! Please add the OneConfig tweaker or call OneConfigInit via an ITweaker or a FMLLoadingPlugin!");
}
oneConfigDir.mkdirs();
new File(oneConfigDir, "profiles").mkdirs();
config = new OneConfigConfig();
+ preLaunched = true;
}
- @net.minecraftforge.fml.common.Mod.EventHandler
- public void onFMLInitialization(net.minecraftforge.fml.common.event.FMLInitializationEvent event) {
+ /**
+ * Called after mods are loaded.
+ * <p><b>SHOULD NOT BE CALLED!</b></p>
+ */
+ public static void init() {
+ if (initialized) return;
BlurHandler.INSTANCE.load();
testConfig = new TestConfig();
CommandManager.INSTANCE.registerCommand(new OneConfigCommand());
EventManager.INSTANCE.register(new HudCore());
EventManager.INSTANCE.register(HypixelUtils.INSTANCE);
- RenderManager.setupAndDraw((vg) -> {
- RenderManager.drawRoundedRect(vg, -100, -100, 50, 50, -1, 12f);
- RenderManager.drawText(vg, "OneConfig loading...", -100, -100, -1, 12f, Fonts.MEDIUM);
- RenderManager.drawImage(vg, Images.HUE_GRADIENT, -100, -100, 50, 50);
- });
- }
-
- @net.minecraftforge.fml.common.Mod.EventHandler
- public void onPostFMLInit(net.minecraftforge.fml.common.event.FMLPostInitializationEvent event) {
reloadModsList();
+ initialized = true;
}
public static void reloadModsList() {
diff --git a/src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java b/src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java
index 1226244..5d11729 100644
--- a/src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java
+++ b/src/main/java/cc/polyfrost/oneconfig/mixin/MinecraftMixin.java
@@ -1,5 +1,6 @@
package cc.polyfrost.oneconfig.mixin;
+import cc.polyfrost.oneconfig.OneConfig;
import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.events.event.*;
import cc.polyfrost.oneconfig.libs.mixinextras.injector.ModifyExpressionValue;
@@ -17,6 +18,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MinecraftMixin {
@Shadow private Timer timer;
+ @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;beginMinecraftLoading(Lnet/minecraft/client/Minecraft;Ljava/util/List;Lnet/minecraft/client/resources/IReloadableResourceManager;)V", remap = false), remap = true)
+ private void onPreLaunch(CallbackInfo ci) {
+ OneConfig.preLaunch();
+ }
+
+ @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;onInitializationComplete()V", shift = At.Shift.AFTER, remap = false), remap = true)
+ private void onInit(CallbackInfo ci) {
+ OneConfig.init();
+ }
+
@Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickStart(F)V", shift = At.Shift.AFTER, remap = false), remap = true)
private void onRenderTickStart(CallbackInfo ci) {
EventManager.INSTANCE.post(new RenderEvent(Stage.START, timer.renderPartialTicks));