finished the ram checker and dialog. finished its implementation in neoforge
This commit is contained in:
@@ -2,6 +2,7 @@ package com.vaporvee.loadsupport;
|
||||
|
||||
|
||||
import com.vaporvee.loadsupport.platform.Services;
|
||||
import net.neoforged.bus.api.Event;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
|
||||
|
@@ -0,0 +1,21 @@
|
||||
package com.vaporvee.loadsupport.mixin;
|
||||
|
||||
import com.vaporvee.loadsupport.Allocated;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftPauseMixin {
|
||||
@Inject(method = "run", at = @At("HEAD"), cancellable = true)
|
||||
private void onRunHead(CallbackInfo ci) {
|
||||
if (!Allocated.enoughMemory) {
|
||||
while (Allocated.isWindowOpen()) {
|
||||
try { Thread.sleep(100); } catch (InterruptedException ignored) {}
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package com.vaporvee.loadsupport.mixin;
|
||||
|
||||
import com.vaporvee.loadsupport.Constants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public class MixinTitleScreen {
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "init()V")
|
||||
private void init(CallbackInfo info) {
|
||||
Constants.LOG.info("Mixin MC title Type: {}", Minecraft.getInstance().getVersionType());
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.vaporvee.loadsupport.mixin;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.vaporvee.loadsupport.Allocated;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Window.class)
|
||||
public class WindowHideMixin {
|
||||
@Inject(
|
||||
method = "takeOverWindow",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void onTakeOverWindow(CallbackInfoReturnable<Long> cir) {
|
||||
if (!Allocated.enoughMemory) {
|
||||
long w = cir.getReturnValue();
|
||||
GLFW.glfwHideWindow(w);
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ import com.vaporvee.loadsupport.Config;
|
||||
import com.vaporvee.loadsupport.platform.services.IConfig;
|
||||
import me.shedaniel.autoconfig.AutoConfig;
|
||||
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
|
||||
import net.neoforged.neoforge.client.event.ScreenEvent;
|
||||
|
||||
public class LSConfigNeoForge implements IConfig {
|
||||
public static Config config;
|
||||
@@ -13,6 +14,7 @@ public class LSConfigNeoForge implements IConfig {
|
||||
AutoConfig.register(Config.class, Toml4jConfigSerializer::new);
|
||||
config = AutoConfig.getConfigHolder(Config.class).getConfig();
|
||||
CommonClass.checkConfig(config);
|
||||
|
||||
}
|
||||
@Override
|
||||
public Config getConfig() {
|
||||
|
@@ -5,7 +5,8 @@
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [],
|
||||
"client": [
|
||||
"MixinTitleScreen"
|
||||
"MinecraftPauseMixin",
|
||||
"WindowHideMixin"
|
||||
],
|
||||
"server": [],
|
||||
"injectors": {
|
||||
|
Reference in New Issue
Block a user