Compare commits

..

No commits in common. "master" and "2.5.6" have entirely different histories.

6 changed files with 39 additions and 43 deletions

View File

@ -1,17 +1,15 @@
plugins { plugins {
id("jfmod") version "1.6-SNAPSHOT" id("jfmod") version "1.5-SNAPSHOT"
} }
allprojects { group = "io.gitlab.jfronny" } allprojects { group = "io.gitlab.jfronny" }
base.archivesName = "modsmod" base.archivesName = "modsmod"
val commonsVersion = "2.0.0-SNAPSHOT"
jfMod { jfMod {
minecraftVersion = "1.21.1" minecraftVersion = "1.20.2"
yarn("build.3") yarn("build.1")
loaderVersion = "0.16.1" loaderVersion = "0.14.22"
libJfVersion = "3.17.0" libJfVersion = "3.13.1"
fabricApiVersion = "0.102.1+1.21.1"
modrinth { modrinth {
projectId = "modsmod" projectId = "modsmod"
@ -26,18 +24,11 @@ jfMod {
} }
dependencies { dependencies {
modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v2") modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v2:${jfMod.libJfVersion.get()}")
modImplementation("io.gitlab.jfronny.libjf:libjf-unsafe-v0") modImplementation("io.gitlab.jfronny.libjf:libjf-unsafe-v0:${jfMod.libJfVersion.get()}")
compileOnly("io.gitlab.jfronny:commons-serialize-generator-annotations:$commonsVersion")
annotationProcessor("io.gitlab.jfronny:commons-serialize-generator:$commonsVersion")
// Dev env // Dev env
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny") modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-ui-tiny:${jfMod.libJfVersion.get()}")
modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil") modLocalRuntime("io.gitlab.jfronny.libjf:libjf-devutil:${jfMod.libJfVersion.get()}")
modLocalRuntime("com.terraformersmc:modmenu:11.0.1") modLocalRuntime("com.terraformersmc:modmenu:8.0.0-beta.2")
// 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,7 +1,7 @@
pluginManagement { pluginManagement {
repositories { repositories {
maven("https://maven.frohnmeyer-wds.de/mirrors") maven("https://maven.fabricmc.net/") // FabricMC
maven("https://maven.neoforged.net/releases") maven("https://maven.frohnmeyer-wds.de/artifacts") // scripts
gradlePluginPortal() gradlePluginPortal()
} }
} }

View File

@ -1,10 +1,10 @@
package io.gitlab.jfronny.modsmod; package io.gitlab.jfronny.modsmod;
import io.gitlab.jfronny.commons.serialize.databind.api.TypeToken; import io.gitlab.jfronny.gson.reflect.TypeToken;
import io.gitlab.jfronny.modsmod.util.IteratorCallbackList; import io.gitlab.jfronny.modsmod.util.IteratorCallbackList;
import net.fabricmc.loader.impl.FabricLoaderImpl; import net.fabricmc.loader.impl.FabricLoaderImpl;
import net.fabricmc.loader.impl.ModContainerImpl; import net.fabricmc.loader.impl.ModContainerImpl;
import net.fabricmc.loader.impl.discovery.ModCandidateImpl; import net.fabricmc.loader.impl.discovery.ModCandidate;
import net.fabricmc.loader.impl.metadata.LoaderModMetadata; import net.fabricmc.loader.impl.metadata.LoaderModMetadata;
import java.lang.reflect.*; import java.lang.reflect.*;
@ -19,13 +19,13 @@ public class FabricLoaderInterface {
static { static {
try { try {
ADD_MOD_METHOD = FabricLoaderImpl.class.getDeclaredMethod("addMod", ModCandidateImpl.class); ADD_MOD_METHOD = FabricLoaderImpl.class.getDeclaredMethod("addMod", ModCandidate.class);
ADD_MOD_METHOD.setAccessible(true); ADD_MOD_METHOD.setAccessible(true);
MODS_FIELD = FabricLoaderImpl.class.getDeclaredField("mods"); MODS_FIELD = FabricLoaderImpl.class.getDeclaredField("mods");
MODS_FIELD.setAccessible(true); MODS_FIELD.setAccessible(true);
CREATE_PLAIN_METHOD = ModCandidateImpl.class.getDeclaredMethod("createPlain", new TypeToken<List<Path>>(){}.getRawType(), LoaderModMetadata.class, boolean.class, new TypeToken<Collection<ModCandidateImpl>>(){}.getRawType()); 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); CREATE_PLAIN_METHOD.setAccessible(true);
} catch (NoSuchMethodException | NoSuchFieldException e) { } catch (NoSuchMethodException | NoSuchFieldException e) {
throw new IllegalStateException("Failed to get reference to fabric loader internals. This fabric loader version is probably unsupported by modsmod", e); throw new IllegalStateException("Failed to get reference to fabric loader internals. This fabric loader version is probably unsupported by modsmod", e);
@ -46,7 +46,7 @@ public class FabricLoaderInterface {
} }
} }
public static void addMod(FabricLoaderImpl fabricLoader, ModCandidateImpl modCandidate) { public static void addMod(FabricLoaderImpl fabricLoader, ModCandidate modCandidate) {
try { try {
ADD_MOD_METHOD.invoke(fabricLoader, modCandidate); ADD_MOD_METHOD.invoke(fabricLoader, modCandidate);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
@ -54,9 +54,9 @@ public class FabricLoaderInterface {
} }
} }
public static ModCandidateImpl createPlain(Path path, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidateImpl> nestedMods) { public static ModCandidate createPlain(Path path, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidate> nestedMods) {
try { try {
return (ModCandidateImpl) CREATE_PLAIN_METHOD.invoke(null, List.of(path), metadata, requiresRemap, nestedMods); return (ModCandidate) CREATE_PLAIN_METHOD.invoke(null, List.of(path), metadata, requiresRemap, nestedMods);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalStateException("Failed to create plain mod container", e); throw new IllegalStateException("Failed to create plain mod container", e);
} }

View File

@ -1,6 +1,7 @@
package io.gitlab.jfronny.modsmod; package io.gitlab.jfronny.modsmod;
import io.gitlab.jfronny.commons.logger.SystemLoggerPlus; import io.gitlab.jfronny.commons.logging.Logger;
import io.gitlab.jfronny.gson.Gson;
import io.gitlab.jfronny.libjf.config.api.v2.ConfigInstance; import io.gitlab.jfronny.libjf.config.api.v2.ConfigInstance;
import io.gitlab.jfronny.libjf.unsafe.UltraEarlyInit; import io.gitlab.jfronny.libjf.unsafe.UltraEarlyInit;
import io.gitlab.jfronny.modsmod.builder.JsonBuilder; import io.gitlab.jfronny.modsmod.builder.JsonBuilder;
@ -19,8 +20,9 @@ import java.util.HashSet;
public class ModsMod implements UltraEarlyInit { public class ModsMod implements UltraEarlyInit {
static final HashSet<ModMeta> MODS = new HashSet<>(); static final HashSet<ModMeta> MODS = new HashSet<>();
static final FabricLoaderImpl LOADER = FabricLoaderImpl.INSTANCE; static final FabricLoaderImpl LOADER = FabricLoaderImpl.INSTANCE;
public static final Gson GSON = new Gson();
public static final String MOD_ID = "modsmod"; public static final String MOD_ID = "modsmod";
public static final SystemLoggerPlus LOGGER = SystemLoggerPlus.forName(MOD_ID); public static final Logger LOGGER = Logger.forName(MOD_ID);
private static final String CACHE_NAME = MOD_ID + "cache"; private static final String CACHE_NAME = MOD_ID + "cache";
@Override @Override

View File

@ -1,8 +1,5 @@
package io.gitlab.jfronny.modsmod.builder; 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 io.gitlab.jfronny.modsmod.ModsMod;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -15,21 +12,27 @@ import java.util.Map;
public class JsonBuilder { public class JsonBuilder {
public static void build(int number, Path outputPath, boolean parent) throws IOException { public static void build(int number, Path outputPath, boolean parent) throws IOException {
try (BufferedWriter bw = Files.newBufferedWriter(outputPath)) { try (BufferedWriter bw = Files.newBufferedWriter(outputPath)) {
GC_JsonBuilder.ModManifest.serialize(new ModManifest(number, parent), bw, LibJf.JSON_TRANSPORT); ModsMod.GSON.toJson(new ModManifest(number, parent), bw);
} }
} }
@GSerializable @SuppressWarnings("unused")
public record ModManifest(int schemaVersion, String id, String version, String name, Map<String, ModMenuData> custom) { private static class ModManifest {
@GPrefer public final int schemaVersion = 1;
public ModManifest { public final String id;
} public final String version = "1.0";
public final String name;
public final Map<String, ModMenuData> custom = new HashMap<>();
public ModManifest(int number, boolean parent) { public ModManifest(int number, boolean parent) {
this(1, "modmod_" + number, "1.0", "ModsMod " + number, parent ? Map.of("modmenu", new ModMenuData("modsmod")) : Map.of()); id = "modmod_" + number;
name = "ModsMod " + number;
if (parent)
custom.put("modmenu", new ModMenuData());
} }
@GSerializable public static class ModMenuData {
public record ModMenuData(String parent) { } public final String parent = "modsmod";
}
} }
} }

View File

@ -19,7 +19,7 @@
"libjf:early": ["io.gitlab.jfronny.modsmod.ModsMod"] "libjf:early": ["io.gitlab.jfronny.modsmod.ModsMod"]
}, },
"depends": { "depends": {
"fabricloader": ">=0.16.1", "fabricloader": ">=0.13.3",
"libjf-config-core-v1": ">=3.0.3", "libjf-config-core-v1": ">=3.0.3",
"libjf-unsafe-v0": ">=3.0.3", "libjf-unsafe-v0": ">=3.0.3",
"minecraft": "*" "minecraft": "*"