Update for newer fabric loader and 1.19

This commit is contained in:
Johannes Frohnmeyer 2022-06-07 22:30:42 +02:00
parent 9d45d0f23d
commit 8504b7bac2
Signed by: Johannes
GPG Key ID: E76429612C2929F4
6 changed files with 26 additions and 47 deletions

View File

@ -1,13 +1,10 @@
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("io.gitlab.jfronny.libjf:libjf-config-v0:${project.jfapi_version}")
modImplementation "com.terraformersmc:modmenu:3.1.0"
modImplementation "com.terraformersmc:modmenu:4.0.0-beta.4"
// Compat fix
include modImplementation(fabricApi.module("fabric-command-api-v1", "${project.fabric_version}"))
include modImplementation('io.gitlab.jfronny:gson:2.9.0.2022.4.2.19.45.43') // Dependency of LibJF 2.7.0
modImplementation(fabricApi.module("fabric-command-api-v2", "${project.fabric_version}"))
}

View File

@ -1,15 +1,17 @@
# https://fabricmc.net/develop/
minecraft_version=1.18.2
yarn_mappings=build.2
loader_version=0.13.3
minecraft_version=1.19
yarn_mappings=build.1
loader_version=0.14.6
# Mod Properties
maven_group=io.gitlab.jfronny
archives_base_name=modsmod
jfapi_version=2.7.1
fabric_version=0.48.0+1.18.2
jfapi_version=2.9.1
fabric_version=0.55.1+1.19
modrinth_id=4GhX11Ed
modrinth_required_dependencies=WKwQAwke
modrinth_optional_dependencies=mOgUt4GM
curseforge_id=405095
curseforge_required_dependencies=libjf
curseforge_optional_dependencies=modmenu

View File

@ -30,8 +30,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) {
MMSafeLog.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);
}
}
@ -41,13 +40,11 @@ public class FabricLoaderInterface {
try {
MODS_FIELD.set(fabricLoader, modContainers);
} catch (IllegalAccessException e) {
MMSafeLog.error("Failed to reset mods field", e);
e.printStackTrace();
ModsMod.LOGGER.error("Failed to reset mods field", e);
}
}, ModsMod::loadMods));
} catch (IllegalAccessException e) {
MMSafeLog.error("Failed to make mods list synchronized.", e);
throw new IllegalStateException(e);
throw new IllegalStateException("Failed to make mods list synchronized", e);
}
}
@ -55,8 +52,7 @@ public class FabricLoaderInterface {
try {
ADD_MOD_METHOD.invoke(fabricLoader, modCandidate);
} catch (IllegalAccessException | InvocationTargetException e) {
MMSafeLog.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 +60,7 @@ public class FabricLoaderInterface {
try {
return (ModCandidate) CREATE_PLAIN_METHOD.invoke(null, List.of(path), metadata, requiresRemap, nestedMods);
} catch (IllegalAccessException | InvocationTargetException e) {
MMSafeLog.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,16 +0,0 @@
package io.gitlab.jfronny.modsmod;
import net.fabricmc.loader.impl.util.log.Log;
import net.fabricmc.loader.impl.util.log.LogCategory;
public class MMSafeLog {
private static final LogCategory LOG_CATEGORY = new LogCategory("modsmod");
public static void error(String text) {
Log.error(LOG_CATEGORY, text);
}
public static void error(String text, Throwable e) {
Log.error(LOG_CATEGORY, text, e);
}
}

View File

@ -1,5 +1,6 @@
package io.gitlab.jfronny.modsmod;
import io.gitlab.jfronny.commons.log.*;
import io.gitlab.jfronny.gson.Gson;
import io.gitlab.jfronny.libjf.config.api.ConfigInstance;
import io.gitlab.jfronny.libjf.config.impl.ConfigInstanceRoot;
@ -7,10 +8,9 @@ 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.*;
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 java.io.IOException;
@ -26,6 +26,7 @@ public class ModsMod implements UltraEarlyInit {
static final FabricLoaderImpl LOADER = FabricLoaderImpl.INSTANCE;
public static final Gson GSON = new Gson();
public static final String MOD_ID = "modsmod";
public static final Logger LOGGER = Logger.forName(MOD_ID);
private static final String CACHE_NAME = MOD_ID + "cache";
@Override
@ -55,8 +56,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
@ -81,14 +81,18 @@ 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()));
FabricLoaderInterface.addMod(LOADER, FabricLoaderInterface.createPlain(meta.rootPath, info, false, new HashSet<>()));
} catch (IOException | ParseMetadataException e) {
throw new IllegalStateException(e);

View File

@ -14,9 +14,6 @@ public class JsonBuilder {
try (BufferedWriter bw = Files.newBufferedWriter(outputPath)) {
ModsMod.GSON.toJson(new ModManifest(number, parent), bw);
}
//String s = ModsMod.GSON.toJson(new ModManifest(number, parent));
//ModsMod.LOGGER.info(s);
//Files.writeString(outputPath, s);
}
@SuppressWarnings("unused")