Compare commits
16 Commits
Author | SHA1 | Date |
---|---|---|
Johannes Frohnmeyer | 9bb5c4b87c | |
Johannes Frohnmeyer | c008ce3868 | |
Johannes Frohnmeyer | 2954301ea8 | |
Johannes Frohnmeyer | 3c4fab0afc | |
Johannes Frohnmeyer | 291b2704fe | |
Johannes Frohnmeyer | 8251b26791 | |
Johannes Frohnmeyer | 0b81b5237b | |
Johannes Frohnmeyer | 3bf5c852e5 | |
Johannes Frohnmeyer | 135003faf8 | |
Johannes Frohnmeyer | 72ebde914e | |
Johannes Frohnmeyer | 1971508c43 | |
Johannes Frohnmeyer | 8504b7bac2 | |
Johannes Frohnmeyer | 9d45d0f23d | |
Johannes Frohnmeyer | d9cdc43254 | |
Johannes Frohnmeyer | ac8889d11a | |
Johannes Frohnmeyer | 78d8c16412 |
|
@ -1,2 +0,0 @@
|
|||
include:
|
||||
- remote: 'https://jfmods.gitlab.io/scripts/jfmod.yml'
|
|
@ -0,0 +1 @@
|
|||
#link https://pages.frohnmeyer-wds.de/scripts/jfmod.yml
|
|
@ -0,0 +1,5 @@
|
|||
ModsMod generates and loads a selectable number of empty mods.
|
||||
|
||||
This is done using LibJF.
|
||||
|
||||
You can find the config at .minecraft/config/ModsMod.json5 or in ModMenu
|
15
build.gradle
15
build.gradle
|
@ -1,15 +0,0 @@
|
|||
apply from: "https://jfmods.gitlab.io/scripts/jfmod.gradle"
|
||||
|
||||
dependencies {
|
||||
include modImplementation("io.gitlab.jfronny.libjf:libjf-config-v0:${project.jfapi_version}")
|
||||
include("io.gitlab.jfronny.libjf:libjf-unsafe-v0:${project.jfapi_version}")
|
||||
include("io.gitlab.jfronny.libjf:libjf-base:${project.jfapi_version}")
|
||||
|
||||
modImplementation "com.terraformersmc:modmenu:3.0.1"
|
||||
|
||||
// Compat fix
|
||||
modRuntimeOnly(fabricApi.module("fabric-api-base", "${project.fabric_version}"))
|
||||
modRuntimeOnly(fabricApi.module("fabric-resource-loader-v0", "${project.fabric_version}"))
|
||||
modRuntimeOnly(fabricApi.module("fabric-screen-api-v1", "${project.fabric_version}"))
|
||||
modRuntimeOnly(fabricApi.module("fabric-command-api-v1", "${project.fabric_version}"))
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
plugins {
|
||||
id("jfmod") version "1.6-SNAPSHOT"
|
||||
}
|
||||
|
||||
allprojects { group = "io.gitlab.jfronny" }
|
||||
base.archivesName = "modsmod"
|
||||
|
||||
val commonsVersion = "1.7-SNAPSHOT"
|
||||
jfMod {
|
||||
minecraftVersion = "1.20.5"
|
||||
yarn("build.1")
|
||||
loaderVersion = "0.15.10"
|
||||
libJfVersion = "3.15.5"
|
||||
fabricApiVersion = "0.97.6+1.20.5"
|
||||
|
||||
modrinth {
|
||||
projectId = "modsmod"
|
||||
requiredDependencies.add("libjf")
|
||||
optionalDependencies.add("modmenu")
|
||||
}
|
||||
curseforge {
|
||||
projectId = "405095"
|
||||
requiredDependencies.add("libjf")
|
||||
optionalDependencies.add("modmenu")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v2")
|
||||
modImplementation("io.gitlab.jfronny.libjf:libjf-unsafe-v0")
|
||||
|
||||
compileOnly("io.gitlab.jfronny:commons-serialize-generator-annotations:$commonsVersion")
|
||||
annotationProcessor("io.gitlab.jfronny:commons-serialize-generator:$commonsVersion")
|
||||
|
||||
// Dev env
|
||||
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny")
|
||||
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil")
|
||||
modLocalRuntime("com.terraformersmc:modmenu:10.0.0-beta.1")
|
||||
// for modmenu
|
||||
modLocalRuntime("net.fabricmc.fabric-api:fabric-resource-loader-v0")
|
||||
modLocalRuntime("net.fabricmc.fabric-api:fabric-screen-api-v1")
|
||||
modLocalRuntime("net.fabricmc.fabric-api:fabric-key-binding-api-v1")
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
# https://fabricmc.net/develop/
|
||||
minecraft_version=1.18.2
|
||||
yarn_mappings=build.1
|
||||
loader_version=0.13.3
|
||||
# Mod Properties
|
||||
maven_group=io.gitlab.jfronny
|
||||
archives_base_name=modsmod
|
||||
|
||||
jfapi_version=2.5.0
|
||||
fabric_version=0.47.8+1.18.2
|
||||
|
||||
modrinth_id=4GhX11Ed
|
||||
curseforge_id=405095
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
maven("https://maven.fabricmc.net/") // FabricMC
|
||||
maven("https://maven.frohnmeyer-wds.de/artifacts") // scripts
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "modsmod"
|
|
@ -1,15 +1,13 @@
|
|||
package io.gitlab.jfronny.modsmod;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import io.gitlab.jfronny.commons.serialize.databind.api.TypeToken;
|
||||
import io.gitlab.jfronny.modsmod.util.IteratorCallbackList;
|
||||
import net.fabricmc.loader.impl.FabricLoaderImpl;
|
||||
import net.fabricmc.loader.impl.ModContainerImpl;
|
||||
import net.fabricmc.loader.impl.discovery.ModCandidate;
|
||||
import net.fabricmc.loader.impl.metadata.LoaderModMetadata;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.*;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -30,8 +28,7 @@ public class FabricLoaderInterface {
|
|||
CREATE_PLAIN_METHOD = ModCandidate.class.getDeclaredMethod("createPlain", new TypeToken<List<Path>>(){}.getRawType(), LoaderModMetadata.class, boolean.class, new TypeToken<Collection<ModCandidate>>(){}.getRawType());
|
||||
CREATE_PLAIN_METHOD.setAccessible(true);
|
||||
} catch (NoSuchMethodException | NoSuchFieldException e) {
|
||||
ModsMod.LOGGER.error("Failed to get reference to fabric-loader internals. The fabric-loader version may be incompatible with patchwork-runtime.", e);
|
||||
throw new IllegalStateException(e);
|
||||
throw new IllegalStateException("Failed to get reference to fabric loader internals. This fabric loader version is probably unsupported by modsmod", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,12 +39,10 @@ public class FabricLoaderInterface {
|
|||
MODS_FIELD.set(fabricLoader, modContainers);
|
||||
} catch (IllegalAccessException e) {
|
||||
ModsMod.LOGGER.error("Failed to reset mods field", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, ModsMod::loadMods));
|
||||
} catch (IllegalAccessException e) {
|
||||
ModsMod.LOGGER.error("Failed to make mods list synchronized.", e);
|
||||
throw new IllegalStateException(e);
|
||||
throw new IllegalStateException("Failed to make mods list synchronized", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,8 +50,7 @@ public class FabricLoaderInterface {
|
|||
try {
|
||||
ADD_MOD_METHOD.invoke(fabricLoader, modCandidate);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
ModsMod.LOGGER.error("Failed to inject mod into fabric-loader.", e);
|
||||
throw new IllegalStateException(e);
|
||||
throw new IllegalStateException("Failed to inject mod into fabric loader", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,8 +58,7 @@ public class FabricLoaderInterface {
|
|||
try {
|
||||
return (ModCandidate) CREATE_PLAIN_METHOD.invoke(null, List.of(path), metadata, requiresRemap, nestedMods);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
ModsMod.LOGGER.error("Failed to create plain mod container", e);
|
||||
throw new IllegalStateException(e);
|
||||
throw new IllegalStateException("Failed to create plain mod container", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,34 @@
|
|||
package io.gitlab.jfronny.modsmod;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.gitlab.jfronny.libjf.config.api.ConfigInstance;
|
||||
import io.gitlab.jfronny.libjf.config.impl.ConfigInstanceImpl;
|
||||
import io.gitlab.jfronny.commons.logger.SystemLoggerPlus;
|
||||
import io.gitlab.jfronny.libjf.config.api.v2.ConfigInstance;
|
||||
import io.gitlab.jfronny.libjf.unsafe.UltraEarlyInit;
|
||||
import io.gitlab.jfronny.modsmod.builder.JsonBuilder;
|
||||
import io.gitlab.jfronny.modsmod.builder.ModMeta;
|
||||
import io.gitlab.jfronny.modsmod.util.IOUtil;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.impl.FabricLoaderImpl;
|
||||
import net.fabricmc.loader.impl.metadata.LoaderModMetadata;
|
||||
import net.fabricmc.loader.impl.metadata.ModMetadataParser;
|
||||
import net.fabricmc.loader.impl.metadata.ParseMetadataException;
|
||||
import net.fabricmc.loader.impl.metadata.*;
|
||||
import net.fabricmc.loader.impl.util.FileSystemUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class ModsMod implements UltraEarlyInit {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(ModsMod.MOD_ID);
|
||||
static final HashSet<ModMeta> MODS = new HashSet<>();
|
||||
static final FabricLoaderImpl LOADER = FabricLoaderImpl.INSTANCE;
|
||||
public static final Gson GSON = new Gson();
|
||||
public static final String MOD_ID = "modsmod";
|
||||
public static final SystemLoggerPlus LOGGER = SystemLoggerPlus.forName(MOD_ID);
|
||||
private static final String CACHE_NAME = MOD_ID + "cache";
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
try {
|
||||
JFC_ModsModConfig.ensureInitialized();
|
||||
//Load config
|
||||
Path modsmodCfgFile = ((ConfigInstanceImpl)ConfigInstance.get(MOD_ID)).path;
|
||||
Path modsmodCfgFile = ConfigInstance.get(MOD_ID).getFilePath().orElseThrow();
|
||||
//make sure the modsmodcache dir is ok
|
||||
Path path = LOADER.getConfigDir().resolve(CACHE_NAME);
|
||||
if (!Files.isDirectory(path)) {
|
||||
|
@ -58,8 +51,7 @@ public class ModsMod implements UltraEarlyInit {
|
|||
}
|
||||
Files.copy(modsmodCfgFile, cfgCache, StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to validate modsmod config cache, caching will not be available");
|
||||
e.printStackTrace();
|
||||
LOGGER.error("Failed to validate modsmod config cache, caching will not be available", e);
|
||||
}
|
||||
MODS.clear();
|
||||
//Generate mods
|
||||
|
@ -84,14 +76,19 @@ public class ModsMod implements UltraEarlyInit {
|
|||
}
|
||||
FabricLoaderInterface.synchronize(LOADER);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("Could not create modsmod mods", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadMods() {
|
||||
for (ModMeta meta : MODS) {
|
||||
try {
|
||||
LoaderModMetadata info = ModMetadataParser.parseMetadata(Files.newInputStream(meta.fmj), meta.url.toString(), new ArrayList<>());
|
||||
LoaderModMetadata info = ModMetadataParser.parseMetadata(Files.newInputStream(meta.fmj),
|
||||
meta.url.toString(),
|
||||
new ArrayList<>(),
|
||||
new VersionOverrides(),
|
||||
new DependencyOverrides(FabricLoader.getInstance().getConfigDir()),
|
||||
false);
|
||||
FabricLoaderInterface.addMod(LOADER, FabricLoaderInterface.createPlain(meta.rootPath, info, false, new HashSet<>()));
|
||||
} catch (IOException | ParseMetadataException e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package io.gitlab.jfronny.modsmod;
|
||||
|
||||
import io.gitlab.jfronny.libjf.config.api.JfConfig;
|
||||
import io.gitlab.jfronny.libjf.config.api.Entry;
|
||||
import io.gitlab.jfronny.libjf.config.api.v2.Entry;
|
||||
import io.gitlab.jfronny.libjf.config.api.v2.JfConfig;
|
||||
|
||||
public class ModsModConfig implements JfConfig {
|
||||
@Entry
|
||||
public static Boolean parent = false;
|
||||
@Entry
|
||||
public static Boolean cache = true;
|
||||
@Entry
|
||||
public static Integer modsCount = 26;
|
||||
@JfConfig
|
||||
public class ModsModConfig {
|
||||
@Entry public static boolean parent = false;
|
||||
@Entry public static boolean cache = true;
|
||||
@Entry public static int modsCount = 26;
|
||||
|
||||
static {
|
||||
JFC_ModsModConfig.ensureInitialized();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package io.gitlab.jfronny.modsmod.builder;
|
||||
|
||||
import io.gitlab.jfronny.commons.serialize.generator.annotations.GPrefer;
|
||||
import io.gitlab.jfronny.commons.serialize.generator.annotations.GSerializable;
|
||||
import io.gitlab.jfronny.libjf.LibJf;
|
||||
import io.gitlab.jfronny.modsmod.ModsMod;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
|
@ -12,30 +15,21 @@ import java.util.Map;
|
|||
public class JsonBuilder {
|
||||
public static void build(int number, Path outputPath, boolean parent) throws IOException {
|
||||
try (BufferedWriter bw = Files.newBufferedWriter(outputPath)) {
|
||||
ModsMod.GSON.toJson(new ModManifest(number, parent), bw);
|
||||
GC_JsonBuilder.ModManifest.serialize(new ModManifest(number, parent), bw, LibJf.JSON_TRANSPORT);
|
||||
}
|
||||
//String s = ModsMod.GSON.toJson(new ModManifest(number, parent));
|
||||
//ModsMod.LOGGER.info(s);
|
||||
//Files.writeString(outputPath, s);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class ModManifest {
|
||||
public final int schemaVersion = 1;
|
||||
public final String id;
|
||||
public final String version = "1.0";
|
||||
public final String name;
|
||||
public final Map<String, ModMenuData> custom = new HashMap<>();
|
||||
@GSerializable
|
||||
public record ModManifest(int schemaVersion, String id, String version, String name, Map<String, ModMenuData> custom) {
|
||||
@GPrefer
|
||||
public ModManifest {
|
||||
}
|
||||
|
||||
public ModManifest(int number, boolean parent) {
|
||||
id = "modmod_" + number;
|
||||
name = "ModsMod " + number;
|
||||
if (parent)
|
||||
custom.put("modmenu", new ModMenuData());
|
||||
this(1, "modmod_" + number, "1.0", "ModsMod " + number, parent ? Map.of("modmenu", new ModMenuData("modsmod")) : Map.of());
|
||||
}
|
||||
|
||||
public static class ModMenuData {
|
||||
public final String parent = "modsmod";
|
||||
}
|
||||
@GSerializable
|
||||
public record ModMenuData(String parent) { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "modsmod",
|
||||
"version": "${version}",
|
||||
"name": "ModsMod",
|
||||
"version": "${version}",
|
||||
"description": "Dynamically creates and loads empty mods",
|
||||
"authors": [
|
||||
"JFronny"
|
||||
],
|
||||
"authors": ["JFronny"],
|
||||
"contact": {
|
||||
"website": "https://jfronny.gitlab.io",
|
||||
"repo": "https://www.gitlab.com/jfmods/ModsMod"
|
||||
"email": "projects.contact@frohnmeyer-wds.de",
|
||||
"homepage": "https://jfronny.gitlab.io",
|
||||
"issues": "https://git.frohnmeyer-wds.de/JfMods/ModsMod/issues",
|
||||
"sources": "https://git.frohnmeyer-wds.de/JfMods/ModsMod"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "assets/modsmod/icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"libjf:config": ["io.gitlab.jfronny.modsmod.ModsModConfig"],
|
||||
"libjf:config": ["io.gitlab.jfronny.modsmod.JFC_ModsModConfig"],
|
||||
"libjf:early": ["io.gitlab.jfronny.modsmod.ModsMod"]
|
||||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=0.13.3",
|
||||
"libjf-config-v0": ">=2.5.0",
|
||||
"libjf-config-core-v1": ">=3.0.3",
|
||||
"libjf-unsafe-v0": ">=3.0.3",
|
||||
"minecraft": "*"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue