Compare commits

...

16 Commits

Author SHA1 Message Date
Johannes Frohnmeyer 9bb5c4b87c
chore: update to 1.20.5
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2024-04-25 22:36:13 +02:00
Johannes Frohnmeyer c008ce3868
chore: update to 1.20.4
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-12-07 20:54:13 +01:00
Johannes Frohnmeyer 2954301ea8
chore: update to 1.20.2
ci/woodpecker/push/jfmod Pipeline was successful Details
2023-09-22 21:20:53 +02:00
Johannes Frohnmeyer 3c4fab0afc
Bump to 1.20
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2023-06-09 17:33:21 +02:00
Johannes Frohnmeyer 291b2704fe
Bump to 1.19.4
ci/woodpecker/push/jfmod Pipeline failed Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2023-03-14 21:49:33 +01:00
Johannes Frohnmeyer 8251b26791
Use new config compiler
ci/woodpecker/push/jfmod Pipeline was successful Details
2022-12-29 16:05:35 +01:00
Johannes Frohnmeyer 0b81b5237b
Update to 1.19.3
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details
2022-12-07 22:34:30 +01:00
Johannes Frohnmeyer 3bf5c852e5
Update FMJ
ci/woodpecker/push/jfmod Pipeline was successful Details
2022-12-02 17:24:15 +01:00
Johannes Frohnmeyer 135003faf8
Update to new infrastructure 2022-12-02 17:23:28 +01:00
Johannes Frohnmeyer 72ebde914e
Update to LibJF 3 2022-08-28 16:47:28 +02:00
Johannes Frohnmeyer 1971508c43
Update to 1.19.1 2022-07-28 14:41:26 +02:00
Johannes Frohnmeyer 8504b7bac2
Update for newer fabric loader and 1.19 2022-06-07 22:30:42 +02:00
Johannes Frohnmeyer 9d45d0f23d
Update LibJF 2022-04-03 20:46:15 +02:00
Johannes Frohnmeyer d9cdc43254
Add description from modrinth 2022-03-13 16:46:26 +01:00
Johannes Frohnmeyer ac8889d11a
Include needed FAPI module 2022-03-02 18:22:14 +01:00
Johannes Frohnmeyer 78d8c16412
Remove ModMenu workaround 2022-03-02 18:16:34 +01:00
12 changed files with 112 additions and 98 deletions

View File

@ -1,2 +0,0 @@
include:
- remote: 'https://jfmods.gitlab.io/scripts/jfmod.yml'

1
.woodpecker.yml Normal file
View File

@ -0,0 +1 @@
#link https://pages.frohnmeyer-wds.de/scripts/jfmod.yml

5
README.md Normal file
View File

@ -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

View File

@ -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}"))
}

43
build.gradle.kts Normal file
View File

@ -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")
}

View File

@ -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

9
settings.gradle.kts Normal file
View File

@ -0,0 +1,9 @@
pluginManagement {
repositories {
maven("https://maven.fabricmc.net/") // FabricMC
maven("https://maven.frohnmeyer-wds.de/artifacts") // scripts
gradlePluginPortal()
}
}
rootProject.name = "modsmod"

View File

@ -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);
}
}
}

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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) { }
}
}

View File

@ -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": "*"
}
}