Add ModMenu "integration"

This commit is contained in:
Andrew-71 2023-10-21 14:05:13 +03:00
parent 306d9d4a76
commit 93e149be13
8 changed files with 49 additions and 11 deletions

View file

@ -13,6 +13,10 @@ base {
} }
repositories { repositories {
maven {
name = 'ModMenu'
url = 'https://maven.terraformersmc.com/releases/'
}
} }
loom { loom {
@ -54,6 +58,7 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" // Fabric API. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" // Fabric API.
modApi "com.terraformersmc:modmenu:${modmenu_version}" // ModMenu
} }
processResources { processResources {
@ -97,15 +102,16 @@ modrinth {
token = System.getenv(modrinth_token) // DO NOT REVEAL THE TOKEN!!! token = System.getenv(modrinth_token) // DO NOT REVEAL THE TOKEN!!!
projectId = mod_id projectId = mod_id
versionNumber = mod_version versionNumber = mod_version
versionType = "beta" // `release`, `beta`, `alpha` versionType = "beta" // release/beta/alpha
uploadFile = remapJar uploadFile = remapJar
gameVersions = ["1.20.1"] gameVersions = ["1.20.1"]
loaders = ["fabric"] loaders = ["fabric"]
dependencies { dependencies {
// scope.type required.project "fabric-api"
// scope.type "name"
// The scope can be `required`, `optional`, `incompatible`, or `embedded` // The scope can be `required`, `optional`, `incompatible`, or `embedded`
// The type can either be `project` or `version` // The type can either be `project` or `version`
required.project "fabric-api" // Creates a new required dependency on Fabric API
// optional.version "sodium", "mc1.19.3-0.4.8" // Creates a new optional dependency on this specific version of Sodium // optional.version "sodium", "mc1.19.3-0.4.8" // Creates a new optional dependency on this specific version of Sodium
} }
} }

View file

@ -13,8 +13,9 @@ mod_version=0.2
maven_group=su.a71 maven_group=su.a71
mod_id=new_soviet mod_id=new_soviet
# Dependencies (Fabric API) # Dependencies
fabric_version=0.90.0+1.20.1 fabric_version=0.90.0+1.20.1
modmenu_version=7.2.2
# Modrinth publishing # Modrinth publishing
modrinth_token=tokenhere modrinth_token=tokenhere

View file

@ -0,0 +1,19 @@
package su.a71.new_soviet.config;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
public class ModMenuCompat implements ModMenuApi{
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return screen -> new Screen(Text.of("")) {
@Override
protected void init() {
Config.openConfigFile();
this.client.setScreen(screen);
}
};
}
}

View file

@ -3,10 +3,11 @@ package su.a71.new_soviet;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.minecraft.util.math.random.Random; import net.minecraft.util.math.random.Random;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import su.a71.new_soviet.config.Config;
import su.a71.new_soviet.registration.NSE_Blocks; import su.a71.new_soviet.registration.NSE_Blocks;
import su.a71.new_soviet.registration.NSE_Custom; import su.a71.new_soviet.registration.NSE_Custom;
import su.a71.new_soviet.registration.NSE_Items; import su.a71.new_soviet.registration.NSE_Items;

View file

@ -1,4 +1,7 @@
package su.a71.new_soviet; package su.a71.new_soviet.config;
import net.minecraft.util.Util;
import su.a71.new_soviet.NewSoviet;
import java.io.*; import java.io.*;
@ -22,8 +25,8 @@ public class Config {
private static void generateDefault() { private static void generateDefault() {
INSTANCE = new Config(); INSTANCE = new Config();
NewSoviet.LOG.info("Generated config file at config/new_soviet.json"); NewSoviet.LOG.info("Generated config file at config/" + NewSoviet.MOD_ID + ".json");
File file = new File("config/new_soviet.json"); File file = new File("config/" + NewSoviet.MOD_ID + ".json");
if(!file.getParentFile().exists() && !file.getParentFile().mkdirs()) { if(!file.getParentFile().exists() && !file.getParentFile().mkdirs()) {
NewSoviet.LOG.error("Error making dir, using default config"); NewSoviet.LOG.error("Error making dir, using default config");
INSTANCE = new Config(); INSTANCE = new Config();
@ -40,7 +43,7 @@ public class Config {
public static void load() { public static void load() {
// Generate config if it doesn't exist // Generate config if it doesn't exist
File file = new File("config/new_soviet.json"); File file = new File("config/" + NewSoviet.MOD_ID + ".json");
if(!file.exists()) { if(!file.exists()) {
generateDefault(); generateDefault();
} }
@ -59,4 +62,9 @@ public class Config {
INSTANCE = new Config(); INSTANCE = new Config();
} }
} }
public static void openConfigFile() {
String configPath = "config/" + NewSoviet.MOD_ID + ".json";
Util.getOperatingSystem().open(new File(configPath));
}
} }

View file

@ -14,7 +14,7 @@ import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
import su.a71.new_soviet.Config; import su.a71.new_soviet.config.Config;
import su.a71.new_soviet.NewSoviet; import su.a71.new_soviet.NewSoviet;
import su.a71.new_soviet.registration.NSE_Sounds; import su.a71.new_soviet.registration.NSE_Sounds;
import su.a71.new_soviet.registration.NSE_Stats; import su.a71.new_soviet.registration.NSE_Stats;

View file

@ -477,5 +477,5 @@
"advancement.new_soviet.sickle_kill.name": "Боевой колхозник", "advancement.new_soviet.sickle_kill.name": "Боевой колхозник",
"advancement.new_soviet.sickle_kill.desc": "Убейте кого-то серпом", "advancement.new_soviet.sickle_kill.desc": "Убейте кого-то серпом",
"modmenu.descriptionTranslation.modmenu": "Мод для minecraft который вернёт вас в старые добрые времена\nNSE добавляет строительные блоки, мебель, предметы и много всего другого в стиле СССР" "modmenu.descriptionTranslation.new_soviet": "Мод для minecraft который вернёт вас в старые добрые времена\nNSE добавляет строительные блоки, мебель, предметы и много всего другого в стиле СССР"
} }

View file

@ -23,6 +23,9 @@
], ],
"fabric-datagen": [ "fabric-datagen": [
"su.a71.new_soviet.DataGeneration" "su.a71.new_soviet.DataGeneration"
],
"modmenu": [
"su.a71.new_soviet.config.ModMenuCompat"
] ]
}, },
"depends": { "depends": {