finished 1.2.0
This commit is contained in:
10
README.md
10
README.md
@@ -8,9 +8,11 @@ The config in `config/loadsupport.toml` is pretty self explainatory:
|
|||||||
startSound = true
|
startSound = true
|
||||||
minMemory = 4.0
|
minMemory = 4.0
|
||||||
errorTitle = "Error: Not enough Java memory!"
|
errorTitle = "Error: Not enough Java memory!"
|
||||||
errorDescription = "Please allocate at least {minMemory} GB of Java memory to your Minecraft Instance! You have currently {currentMemory} GB allocated."
|
errorMinMemory = "Please allocate at least {minMemory} GB of Java memory to your Minecraft instance!"
|
||||||
|
errorCurrentMemory = "You have currently {currentMemory} GB allocated."
|
||||||
|
memoryInfoLink = "https://github.com/vaporvee/LoadSupport/wiki/How-to-allocate-more-memory-to-your-Minecraft-instance"
|
||||||
```
|
```
|
||||||
The errorDescription does automatic line breaks. `{minMemory}` and `{currentMemory}` get replaced by their actual values.
|
`{minMemory}` and `{currentMemory}` get replaced by their actual values.
|
||||||
|
|
||||||
## Planned Features 👀
|
## Planned Features 👀
|
||||||
- 🔊 Customizable startup sound
|
- 🔊 Customizable startup sound
|
||||||
@@ -23,11 +25,9 @@ The player doesn't need to wait just to know that they selected the wrong amount
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
#### Blocks the title screen🚧
|
#### Blocks the game window🚧
|
||||||
Make sure the player gets the correct performance experience.
|
Make sure the player gets the correct performance experience.
|
||||||
|
|
||||||
<img src="https://cdn.modrinth.com/data/bnO15g6H/images/881f15c2413795ba1ba0bebd2baf4c0f4862336c.png" width="600px">
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Play a sound when Minecraft finished loading 🔊
|
### Play a sound when Minecraft finished loading 🔊
|
||||||
|
@@ -21,7 +21,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "me.shedaniel.cloth:cloth-config-neoforge:18.0.145"
|
compileOnly "me.shedaniel.cloth:cloth-config-neoforge:${cloth_version}"
|
||||||
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
|
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
|
||||||
// fabric and neoforge both bundle mixinextras, so it is safe to use it in common
|
// fabric and neoforge both bundle mixinextras, so it is safe to use it in common
|
||||||
compileOnly group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.3.5'
|
compileOnly group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.3.5'
|
||||||
|
@@ -1,29 +1,30 @@
|
|||||||
package com.vaporvee.loadsupport;
|
package com.vaporvee.loadsupport;
|
||||||
|
|
||||||
|
import com.vaporvee.loadsupport.modules.Allocated;
|
||||||
import com.vaporvee.loadsupport.platform.Services;
|
import com.vaporvee.loadsupport.platform.Services;
|
||||||
|
import me.shedaniel.autoconfig.AutoConfig;
|
||||||
|
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class CommonClass {
|
public class CommonClass {
|
||||||
public static void init() {
|
public static boolean init() {
|
||||||
if (Services.PLATFORM.isEnvServer()) {
|
if (Services.PLATFORM.isEnvServer()) {
|
||||||
Constants.LOG.info(Constants.MOD_ID + " is a client mod only!");
|
Constants.LOG.info(Constants.MOD_ID + " is a client mod only!");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
Constants.LOG.info("Loading Load Support mod.");
|
InitConfig();
|
||||||
Allocated.init();
|
Allocated.init();
|
||||||
Allocated.printAllocated();
|
return true;
|
||||||
Services.CONFIG.InitConfig();
|
|
||||||
}
|
}
|
||||||
public static void checkConfig(Config config) {
|
public static Config config;
|
||||||
Constants.LOG.info("Config loaded!");
|
public static long window;
|
||||||
if (config != null) {
|
|
||||||
if(config.minMemory > Allocated.memoryInGB){
|
private static void InitConfig() {
|
||||||
System.setProperty("java.awt.headless", "false");
|
AutoConfig.register(Config.class, Toml4jConfigSerializer::new);
|
||||||
Constants.LOG.error("Not enough memory! Allocated memory in GB is {} but set in config is {}",
|
config = AutoConfig.getConfigHolder(Config.class).getConfig();
|
||||||
Allocated.memoryInGB, config.minMemory);
|
}
|
||||||
Allocated.createMemoryError();
|
|
||||||
}
|
public static void HideWindow() {
|
||||||
} else {
|
GLFW.glfwHideWindow(window);
|
||||||
Constants.LOG.warn("Load config is null!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,10 +4,10 @@ import me.shedaniel.autoconfig.ConfigData;
|
|||||||
|
|
||||||
@me.shedaniel.autoconfig.annotation.Config(name = Constants.MOD_ID)
|
@me.shedaniel.autoconfig.annotation.Config(name = Constants.MOD_ID)
|
||||||
public class Config implements ConfigData {
|
public class Config implements ConfigData {
|
||||||
boolean startSound = true;
|
public boolean startSound = true;
|
||||||
float minMemory = 4.0f;
|
public float minMemory = 4.0f;
|
||||||
String errorTitle = "Error: Not enough Java memory!";
|
public String errorTitle = "Error: Not enough Java memory!";
|
||||||
String errorMinMemory = "Please allocate at least {minMemory} GB of Java memory to your Minecraft instance!";
|
public String errorMinMemory = "Please allocate at least {minMemory} GB of Java memory to your Minecraft instance!";
|
||||||
String errorCurrentMemory = "You have currently {currentMemory} GB allocated.";
|
public String errorCurrentMemory = "You have currently {currentMemory} GB allocated.";
|
||||||
String memoryInfoLink = "https://github.com/vaporvee/LoadSupport/wiki/How-to-allocate-more-memory-to-your-Minecraft-instance";
|
public String memoryInfoLink = "https://github.com/vaporvee/LoadSupport/wiki/How-to-allocate-more-memory-to-your-Minecraft-instance";
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,14 @@
|
|||||||
|
package com.vaporvee.loadsupport;
|
||||||
|
|
||||||
|
import com.vaporvee.loadsupport.modules.StartSound;
|
||||||
|
import net.minecraft.client.gui.screens.AccessibilityOnboardingScreen;
|
||||||
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
import net.minecraft.client.gui.screens.TitleScreen;
|
||||||
|
|
||||||
|
public class ScreenEventHandler {
|
||||||
|
public static void eventTrigger(Screen screen) {
|
||||||
|
if (screen instanceof TitleScreen || screen instanceof AccessibilityOnboardingScreen) {
|
||||||
|
StartSound.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
package com.vaporvee.loadsupport.mixin;
|
package com.vaporvee.loadsupport.mixin;
|
||||||
|
|
||||||
import com.vaporvee.loadsupport.Allocated;
|
import com.vaporvee.loadsupport.modules.Allocated;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
@@ -1,17 +0,0 @@
|
|||||||
package com.vaporvee.loadsupport.mixin;
|
|
||||||
|
|
||||||
import com.vaporvee.loadsupport.Constants;
|
|
||||||
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 MixinMinecraft {
|
|
||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "<init>")
|
|
||||||
private void init(CallbackInfo info) {
|
|
||||||
Constants.LOG.info("Mixin MC Platform: {}", Minecraft.getInstance().getVersionType());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,35 @@
|
|||||||
|
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.CommonClass;
|
||||||
|
import com.vaporvee.loadsupport.modules.Allocated;
|
||||||
|
import com.vaporvee.loadsupport.platform.Services;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Mixin(Window.class)
|
||||||
|
public class WindowHideMixin {
|
||||||
|
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
private long window;
|
||||||
|
|
||||||
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
|
private void afterInit(WindowEventHandler eventHandler, ScreenManager screenManager, DisplayData displayData, String preferredFullscreenVideoMode, String title, CallbackInfo ci) {
|
||||||
|
CommonClass.window = window;
|
||||||
|
if(Objects.equals(Services.PLATFORM.getPlatformName(), "Fabric") && !Allocated.enoughMemory){ // Fabric loads early enough to fire it here
|
||||||
|
CommonClass.HideWindow(); // Hide main Minecraft Window which gets frozen by mixin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -1,6 +1,10 @@
|
|||||||
package com.vaporvee.loadsupport;
|
package com.vaporvee.loadsupport.modules;
|
||||||
|
|
||||||
|
import com.vaporvee.loadsupport.CommonClass;
|
||||||
|
import com.vaporvee.loadsupport.Config;
|
||||||
|
import com.vaporvee.loadsupport.Constants;
|
||||||
import com.vaporvee.loadsupport.platform.Services;
|
import com.vaporvee.loadsupport.platform.Services;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -11,14 +15,22 @@ public class Allocated {
|
|||||||
public static float memoryInGB;
|
public static float memoryInGB;
|
||||||
public static void init(){
|
public static void init(){
|
||||||
memoryInGB = Runtime.getRuntime().maxMemory() / Constants.GIGABYTE;
|
memoryInGB = Runtime.getRuntime().maxMemory() / Constants.GIGABYTE;
|
||||||
memoryInGB = Math.round(Allocated.memoryInGB * 10) / 10f;
|
memoryInGB = Math.round(memoryInGB * 10) / 10f;
|
||||||
}
|
|
||||||
public static void printAllocated() {
|
|
||||||
Constants.LOG.info(String.format("Allocated Memory: %.1f GB", memoryInGB));
|
Constants.LOG.info(String.format("Allocated Memory: %.1f GB", memoryInGB));
|
||||||
|
checkMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getWarningMessage() {
|
private static void checkMemory(){
|
||||||
Config config = Services.CONFIG.getConfig();
|
if(CommonClass.config.minMemory > memoryInGB){
|
||||||
|
System.setProperty("java.awt.headless", "false");
|
||||||
|
Constants.LOG.error("Not enough memory! Allocated memory in GB is {} but set in config is {}",
|
||||||
|
memoryInGB, CommonClass.config.minMemory);
|
||||||
|
createMemoryError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String[] getWarningMessage() {
|
||||||
|
Config config = CommonClass.config;
|
||||||
|
|
||||||
String title = stripHtml(config.errorTitle);
|
String title = stripHtml(config.errorTitle);
|
||||||
String minMemoryText = stripHtml(config.errorMinMemory);
|
String minMemoryText = stripHtml(config.errorMinMemory);
|
||||||
@@ -38,14 +50,15 @@ public class Allocated {
|
|||||||
return input == null ? "" : input.replaceAll("<[^>]*>", "");
|
return input == null ? "" : input.replaceAll("<[^>]*>", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean enoughMemory = true;
|
|
||||||
private static JFrame errorWindow;
|
private static JFrame errorWindow;
|
||||||
|
|
||||||
|
public static boolean enoughMemory = true;
|
||||||
|
|
||||||
public static boolean isWindowOpen(){
|
public static boolean isWindowOpen(){
|
||||||
return errorWindow.isDisplayable();
|
return errorWindow.isDisplayable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createMemoryError() {
|
private static void createMemoryError() {
|
||||||
try {
|
try {
|
||||||
if (enoughMemory) {
|
if (enoughMemory) {
|
||||||
enoughMemory = false;
|
enoughMemory = false;
|
||||||
@@ -91,6 +104,9 @@ public class Allocated {
|
|||||||
errorWindow.add(buttonPanel, BorderLayout.SOUTH);
|
errorWindow.add(buttonPanel, BorderLayout.SOUTH);
|
||||||
errorWindow.setVisible(true);
|
errorWindow.setVisible(true);
|
||||||
});
|
});
|
||||||
|
if(Objects.equals(Services.PLATFORM.getPlatformName(), "NeoForge")){// NeoForge loads too late so we need to fire it here
|
||||||
|
CommonClass.HideWindow(); // Hide main Minecraft Window which gets frozen by mixin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (RuntimeException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
} catch (RuntimeException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||||
Constants.LOG.error(String.valueOf(e));
|
Constants.LOG.error(String.valueOf(e));
|
@@ -0,0 +1,19 @@
|
|||||||
|
package com.vaporvee.loadsupport.modules;
|
||||||
|
|
||||||
|
import com.vaporvee.loadsupport.CommonClass;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
|
||||||
|
public class StartSound {
|
||||||
|
private static boolean startedOnce = false;
|
||||||
|
|
||||||
|
public static void play() {
|
||||||
|
if (!startedOnce && CommonClass.config.startSound) {
|
||||||
|
startedOnce = true;
|
||||||
|
Minecraft.getInstance().getSoundManager().play(
|
||||||
|
SimpleSoundInstance.forUI(SoundEvents.UI_TOAST_CHALLENGE_COMPLETE, 1.0F)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,7 +1,6 @@
|
|||||||
package com.vaporvee.loadsupport.platform;
|
package com.vaporvee.loadsupport.platform;
|
||||||
|
|
||||||
import com.vaporvee.loadsupport.Constants;
|
import com.vaporvee.loadsupport.Constants;
|
||||||
import com.vaporvee.loadsupport.platform.services.IConfig;
|
|
||||||
import com.vaporvee.loadsupport.platform.services.IPlatformHelper;
|
import com.vaporvee.loadsupport.platform.services.IPlatformHelper;
|
||||||
|
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
@@ -10,8 +9,6 @@ public class Services {
|
|||||||
|
|
||||||
public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class);
|
public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class);
|
||||||
|
|
||||||
public static final IConfig CONFIG = load(IConfig.class);
|
|
||||||
|
|
||||||
public static <T> T load(Class<T> clazz) {
|
public static <T> T load(Class<T> clazz) {
|
||||||
|
|
||||||
final T loadedService = ServiceLoader.load(clazz)
|
final T loadedService = ServiceLoader.load(clazz)
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
package com.vaporvee.loadsupport.platform.services;
|
|
||||||
|
|
||||||
import com.vaporvee.loadsupport.Config;
|
|
||||||
|
|
||||||
public interface IConfig {
|
|
||||||
/**
|
|
||||||
* Initializes config on available platforms
|
|
||||||
*/
|
|
||||||
void InitConfig();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the populated config class with local config data when loaded correctly
|
|
||||||
* @return pupulated Config object
|
|
||||||
*/
|
|
||||||
Config getConfig();
|
|
||||||
}
|
|
@@ -6,7 +6,8 @@
|
|||||||
"compatibilityLevel": "JAVA_18",
|
"compatibilityLevel": "JAVA_18",
|
||||||
"mixins": [],
|
"mixins": [],
|
||||||
"client": [
|
"client": [
|
||||||
"MixinMinecraft"
|
"MinecraftPauseMixin",
|
||||||
|
"WindowHideMixin"
|
||||||
],
|
],
|
||||||
"server": [],
|
"server": [],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
|
@@ -15,7 +15,7 @@ dependencies {
|
|||||||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||||
implementation 'com.moandjiezana.toml:toml4j:0.7.2'
|
implementation 'com.moandjiezana.toml:toml4j:0.7.2'
|
||||||
modApi("me.shedaniel.cloth:cloth-config-fabric:18.0.145") {
|
modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_version}") {
|
||||||
exclude(group: "net.fabricmc.fabric-api")
|
exclude(group: "net.fabricmc.fabric-api")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,11 @@
|
|||||||
|
package com.vaporvee.loadsupport;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
|
||||||
|
|
||||||
|
public class ClientScreenHandler {
|
||||||
|
public static void register() {
|
||||||
|
ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
|
||||||
|
ScreenEventHandler.eventTrigger(screen);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@@ -6,6 +6,9 @@ public class LoadSupport implements ModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
CommonClass.init();
|
boolean initiated = CommonClass.init();
|
||||||
|
if(initiated) {
|
||||||
|
ClientScreenHandler.register();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
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,26 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
package com.vaporvee.loadsupport.platform;
|
|
||||||
|
|
||||||
import com.vaporvee.loadsupport.CommonClass;
|
|
||||||
import com.vaporvee.loadsupport.Config;
|
|
||||||
import com.vaporvee.loadsupport.platform.services.IConfig;
|
|
||||||
import me.shedaniel.autoconfig.AutoConfig;
|
|
||||||
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
|
|
||||||
|
|
||||||
public class LSConfigFabric implements IConfig {
|
|
||||||
public static Config config;
|
|
||||||
@Override
|
|
||||||
public void InitConfig() {
|
|
||||||
AutoConfig.register(Config.class, Toml4jConfigSerializer::new);
|
|
||||||
config = AutoConfig.getConfigHolder(Config.class).getConfig();
|
|
||||||
CommonClass.checkConfig(config);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Config getConfig() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1 +0,0 @@
|
|||||||
com.vaporvee.loadsupport.platform.LSConfigFabric
|
|
@@ -5,10 +5,7 @@
|
|||||||
"refmap": "${mod_id}.refmap.json",
|
"refmap": "${mod_id}.refmap.json",
|
||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"mixins": [],
|
"mixins": [],
|
||||||
"client": [
|
"client": [],
|
||||||
"MinecraftPauseMixin",
|
|
||||||
"WindowHideMixin"
|
|
||||||
],
|
|
||||||
"server": [],
|
"server": [],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
@@ -7,30 +7,33 @@ group=com.vaporvee.loadsupport
|
|||||||
java_version=21
|
java_version=21
|
||||||
|
|
||||||
# Common
|
# Common
|
||||||
minecraft_version=1.21.5
|
minecraft_version=1.21.1
|
||||||
mod_name=Load Support
|
mod_name=Load Support
|
||||||
mod_author=vaporvee
|
mod_author=vaporvee
|
||||||
mod_id=loadsupport
|
mod_id=loadsupport
|
||||||
license=Apache License 2.0
|
license=Apache License 2.0
|
||||||
credits=
|
credits=
|
||||||
description=Shows when the user has too less Java memory allocated, and plays a sound when the game has loaded.
|
description=Shows when the user has too less Java memory allocated, and plays a sound when the game has loaded.
|
||||||
minecraft_version_range=[1.21.5, 1.22)
|
minecraft_version_range=[1.21.1, 1.21.6)
|
||||||
## This is the version of minecraft that the 'common' project uses, you can find a list of all versions here
|
## This is the version of minecraft that the 'common' project uses, you can find a list of all versions here
|
||||||
## https://projects.neoforged.net/neoforged/neoform
|
## https://projects.neoforged.net/neoforged/neoform
|
||||||
neo_form_version=1.21.5-20250325.162830
|
neo_form_version=1.21.1-20240808.144430
|
||||||
# The version of ParchmentMC that is used, see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions
|
# The version of ParchmentMC that is used, see https://parchmentmc.org/docs/getting-started#choose-a-version for new versions
|
||||||
parchment_minecraft=1.21.4
|
parchment_minecraft=1.21.1
|
||||||
parchment_version=2025.03.23
|
parchment_version=2024.11.17
|
||||||
|
|
||||||
# Fabric
|
# Fabric
|
||||||
fabric_version=0.119.5+1.21.5
|
fabric_version=0.116.3+1.21.1
|
||||||
fabric_loader_version=0.16.10
|
fabric_loader_version=0.16.10
|
||||||
|
|
||||||
|
|
||||||
# NeoForge
|
# NeoForge
|
||||||
neoforge_version=21.5.4-beta
|
neoforge_version=21.1.184
|
||||||
neoforge_loader_version_range=[4,)
|
neoforge_loader_version_range=[4,)
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
cloth_version=15.0.140
|
||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
|
@@ -10,7 +10,7 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.moandjiezana.toml:toml4j:0.7.2'
|
implementation 'com.moandjiezana.toml:toml4j:0.7.2'
|
||||||
implementation "me.shedaniel.cloth:cloth-config-neoforge:18.0.145"
|
implementation "me.shedaniel.cloth:cloth-config-neoforge:${cloth_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
neoForge {
|
neoForge {
|
||||||
@@ -32,9 +32,6 @@ neoForge {
|
|||||||
client {
|
client {
|
||||||
client()
|
client()
|
||||||
}
|
}
|
||||||
data {
|
|
||||||
clientData()
|
|
||||||
}
|
|
||||||
server {
|
server {
|
||||||
server()
|
server()
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,16 @@
|
|||||||
|
package com.vaporvee.loadsupport;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
import net.neoforged.neoforge.client.event.ScreenEvent;
|
||||||
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
|
|
||||||
|
public class ClientScreenHandler {
|
||||||
|
public static void register() {
|
||||||
|
NeoForge.EVENT_BUS.addListener(ClientScreenHandler::onScreenInit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void onScreenInit(ScreenEvent.Init.Post event) {
|
||||||
|
Screen screen = event.getScreen();
|
||||||
|
ScreenEventHandler.eventTrigger(screen);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,8 +1,5 @@
|
|||||||
package com.vaporvee.loadsupport;
|
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.bus.api.IEventBus;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
|
|
||||||
@@ -10,6 +7,9 @@ import net.neoforged.fml.common.Mod;
|
|||||||
public class LoadSupport {
|
public class LoadSupport {
|
||||||
|
|
||||||
public LoadSupport(IEventBus eventBus) {
|
public LoadSupport(IEventBus eventBus) {
|
||||||
CommonClass.init();
|
boolean initiated = CommonClass.init();
|
||||||
|
if (initiated) {
|
||||||
|
ClientScreenHandler.register();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,23 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
package com.vaporvee.loadsupport.platform;
|
|
||||||
|
|
||||||
import com.vaporvee.loadsupport.CommonClass;
|
|
||||||
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;
|
|
||||||
@Override
|
|
||||||
public void InitConfig() {
|
|
||||||
AutoConfig.register(Config.class, Toml4jConfigSerializer::new);
|
|
||||||
config = AutoConfig.getConfigHolder(Config.class).getConfig();
|
|
||||||
CommonClass.checkConfig(config);
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Config getConfig() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -10,13 +10,11 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlatformName() {
|
public String getPlatformName() {
|
||||||
|
|
||||||
return "NeoForge";
|
return "NeoForge";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isModLoaded(String modId) {
|
public boolean isModLoaded(String modId) {
|
||||||
|
|
||||||
return ModList.get().isLoaded(modId);
|
return ModList.get().isLoaded(modId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +25,6 @@ public class NeoForgePlatformHelper implements IPlatformHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDevelopmentEnvironment() {
|
public boolean isDevelopmentEnvironment() {
|
||||||
|
|
||||||
return !FMLLoader.isProduction();
|
return !FMLLoader.isProduction();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1 +0,0 @@
|
|||||||
com.vaporvee.loadsupport.platform.LSConfigNeoForge
|
|
@@ -4,10 +4,7 @@
|
|||||||
"package": "com.vaporvee.loadsupport.mixin",
|
"package": "com.vaporvee.loadsupport.mixin",
|
||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"mixins": [],
|
"mixins": [],
|
||||||
"client": [
|
"client": [],
|
||||||
"MinecraftPauseMixin",
|
|
||||||
"WindowHideMixin"
|
|
||||||
],
|
|
||||||
"server": [],
|
"server": [],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
Reference in New Issue
Block a user