ported no ram window to fabric finishing it
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
package com.vaporvee.loadsupport.mixin;
|
||||||
|
|
||||||
|
import com.vaporvee.loadsupport.Allocated;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,26 @@
|
|||||||
|
package com.vaporvee.loadsupport.mixin;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.DisplayData;
|
||||||
|
import com.mojang.blaze3d.platform.ScreenManager;
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import com.mojang.blaze3d.platform.WindowEventHandler;
|
||||||
|
import com.vaporvee.loadsupport.Allocated;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
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.CallbackInfo;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@Mixin(Window.class)
|
||||||
|
public class WindowHideMixin {
|
||||||
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
|
private void onWindowInit(WindowEventHandler eventHandler, ScreenManager screenManager, DisplayData displayData, String preferredFullscreenVideoMode, String title, CallbackInfo ci) {
|
||||||
|
if (!Allocated.enoughMemory) {
|
||||||
|
long w = ((Window)(Object)this).getWindow();
|
||||||
|
GLFW.glfwHideWindow(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -6,7 +6,8 @@
|
|||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"mixins": [],
|
"mixins": [],
|
||||||
"client": [
|
"client": [
|
||||||
"MixinTitleScreen"
|
"MinecraftPauseMixin",
|
||||||
|
"WindowHideMixin"
|
||||||
],
|
],
|
||||||
"server": [],
|
"server": [],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
|
Reference in New Issue
Block a user