mirror of
https://github.com/LegacyModdingMC/UniMixins.git
synced 2026-10-27 06:53:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12a4b93f65 | ||
|
|
7557facb0e | ||
|
|
a0a0d9f254 | ||
|
|
8a6a3bb5c7 | ||
|
|
3bf7e03dda | ||
|
|
9c49d2f964 | ||
|
|
fd12f73e48 | ||
|
|
86cd5ed15f | ||
|
|
e0ba3966ec | ||
|
|
933113d328 | ||
|
|
b9ad717326 | ||
|
|
26175b260f | ||
|
|
170ca0b763 | ||
|
|
76e679b50e | ||
|
|
f7b7bef023 | ||
|
|
2b3b2482ed |
No files matched your search
@@ -25,14 +25,11 @@ jobs:
|
||||
run: ./gradlew setupCIWorkspace
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- name: Assemble modular zip
|
||||
run: ./build-zip.sh
|
||||
- name: Copy artifacts to a single directory
|
||||
run: |
|
||||
mkdir build/tmp/ci -p
|
||||
cp module-all/build/libs/* build/tmp/ci
|
||||
cp module-*/build/libs/* build/tmp/ci
|
||||
rm build/tmp/ci/*-sources.jar
|
||||
cp build/*-modular-*.zip build/tmp/ci
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Package
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
# This workflow will build the project and publish a release using the changelog
|
||||
# in the last draft release. The draft is deleted after the task is finished.
|
||||
|
||||
# Usage:
|
||||
# 1. Create a draft release. Set the description and the tag (everything else
|
||||
# will be ignored)
|
||||
# 2. Push a tag with the same name
|
||||
|
||||
name: Release tagged build
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set release version
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 8
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Set up Gradle build
|
||||
run: ./gradlew setupCIWorkspace
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- name: Copy artifacts to a single directory
|
||||
run: |
|
||||
mkdir build/tmp/ci -p
|
||||
cp module-*/build/libs/* build/tmp/ci
|
||||
rm build/tmp/ci/*-sources.jar
|
||||
- name: Read changelog from last draft release
|
||||
run: |
|
||||
gh api "/repos/${GITHUB_REPOSITORY}/releases?per_page=1" \
|
||||
| jq ".[0]" > /tmp/last-release.json
|
||||
[ $(cat /tmp/last-release.json | jq '.draft' -r) == true ] || (echo "Error: Last release is not a draft" && false)
|
||||
DRAFT_TAG=$(cat /tmp/last-release.json | jq '.tag_name' -r)
|
||||
[ $DRAFT_TAG == $RELEASE_VERSION ] || (echo "Error: Last draft's tag does not match pushed tag" && false)
|
||||
cat /tmp/last-release.json | jq '.body' -r > /tmp/changelog.md
|
||||
cat /tmp/last-release.json | jq '.id' > /tmp/draft_id.txt
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: build/tmp/ci/*.jar
|
||||
body_path: /tmp/changelog.md
|
||||
- name: Delete last draft release
|
||||
run: |
|
||||
gh api -X DELETE "/repos/${GITHUB_REPOSITORY}/releases/$(cat /tmp/draft_id.txt)"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
@@ -28,7 +28,12 @@ Download the `-all` jar, and put it in your mods directory. Remove any other con
|
||||
|
||||
### Advanced usage
|
||||
|
||||
The `-modular` zip contains a separate jar for each module. Some modules depend on other modules, see the below list.
|
||||
You can also assemble your own combination of modules using the module jars. Some modules depend on other modules, see the **List of modules** section.
|
||||
|
||||
Assuming no other Mixin loaders are present, you will generally want the following modules:
|
||||
* **Mixin** (any single fork)
|
||||
* **Compat** and **Mixingasm** (optional but highly recommended)
|
||||
* Modules providing any extras you need
|
||||
|
||||
The game will crash if modules are missing dependencies. This can be disabled in the config.
|
||||
|
||||
|
||||
@@ -10,3 +10,5 @@ forge_version=10.13.4.1614-1.7.10
|
||||
|
||||
enable_mixin=false
|
||||
multiproject_structure=false
|
||||
|
||||
project_url=https://github.com/LegacyModdingMC/UniMixins
|
||||
+12
-3
@@ -32,13 +32,22 @@ task createMergedMcmodInfo() {
|
||||
def mergedJson = []
|
||||
getModuleJars().each {
|
||||
def json = new groovy.json.JsonSlurper().parseText(zipTree(it).matching { include 'mcmod.info' }.getSingleFile().text)
|
||||
json[0]["parent"] = "unimixins"
|
||||
mergedJson += json
|
||||
}
|
||||
|
||||
def desc = mergedJson.collect{ it.name.split(": ")[1]}.join("; ")
|
||||
mergedJson[0].name = "UniMixins"
|
||||
mergedJson[0].description = "UniMixins composite jar consisting of the following modules:\n" + desc
|
||||
mergedJson[0].version = version
|
||||
mergedJson = [
|
||||
[
|
||||
modid: "unimixins",
|
||||
name: "UniMixins",
|
||||
description: "UniMixins composite jar consisting of the following modules:\n" + desc,
|
||||
version: version,
|
||||
mcversion: "1.7.10",
|
||||
url: project_url,
|
||||
authorList: ["makamys"],
|
||||
]
|
||||
] + mergedJson
|
||||
|
||||
file("build/tmp/mcmod.info").text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(mergedJson))
|
||||
return file("build/tmp/mcmod.info")
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package io.github.legacymoddingmc.unimixins.all;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -18,7 +22,21 @@ public class AllCore implements IFMLLoadingPlugin {
|
||||
private static List<Class<?>> embeddedCorePluginClasses = new ArrayList<>();
|
||||
private static List<IFMLLoadingPlugin> embeddedCorePluginInstances = new ArrayList<>();
|
||||
|
||||
private static List<String> CONCERNING_JAR_PREFIXES = Arrays.asList(
|
||||
"gtnhmixins-",
|
||||
"gasstation-",
|
||||
"mixinbooterlegacy-",
|
||||
"spongemixins-",
|
||||
"mixingasm-"
|
||||
);
|
||||
|
||||
private static final Pattern LETTER = Pattern.compile("[a-z]");
|
||||
|
||||
static {
|
||||
if(isIntegrityCheckEnabled()) {
|
||||
doSanityCheck();
|
||||
}
|
||||
|
||||
try {
|
||||
for(String s : IOUtils.toString(AllCore.class.getResource("/META-INF/unimixins-all.EmbeddedFMLCorePlugins.txt")).split(" ")) {
|
||||
Class<?> cls = Class.forName(s);
|
||||
@@ -30,6 +48,59 @@ public class AllCore implements IFMLLoadingPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private static void doSanityCheck() {
|
||||
List<String> concerningJars = new ArrayList<>();
|
||||
|
||||
for(URL url : Launch.classLoader.getSources()) {
|
||||
String path = url.getPath();
|
||||
if(path.endsWith(".jar")) {
|
||||
String[] components = path.split("/");
|
||||
String name = components[components.length - 1].toLowerCase();
|
||||
Matcher matcher = LETTER.matcher(name);
|
||||
if(matcher.find()) {
|
||||
int firstLetterIndex = matcher.start();
|
||||
name = name.substring(firstLetterIndex);
|
||||
if (anyPrefixesMatch(name, CONCERNING_JAR_PREFIXES)) {
|
||||
concerningJars.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!concerningJars.isEmpty()) {
|
||||
// Any throwables we throw here will get caught, so all we can do is warn.
|
||||
String theWarning = "Detected incompatible jars: " + concerningJars;
|
||||
|
||||
LOGGER.warn("=======================================================================================");
|
||||
LOGGER.warn("WARNING / WARNING / WARNING / WARNING / WARNING / WARNING / WARNING / WARNING / WARNING");
|
||||
LOGGER.warn("=======================================================================================");
|
||||
LOGGER.error(theWarning);
|
||||
LOGGER.error("The game will almost certainly crash!");
|
||||
LOGGER.fatal("======================================================================================");
|
||||
throw new Error(theWarning); // Attention grabbing stack trace
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean anyPrefixesMatch(String s, Collection<String> prefixes) {
|
||||
for(String p : prefixes) {
|
||||
if(s.startsWith(p)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isIntegrityCheckEnabled() {
|
||||
// I'm scared to load Forge classes this early so we're doing this
|
||||
File file = new File(Launch.minecraftHome, "config/unimixins.cfg");
|
||||
if(file.exists()) {
|
||||
try {
|
||||
return !FileUtils.readFileToString(file).contains("B:disableIntegrityChecks=true");
|
||||
} catch(Exception e){}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public AllCore() {
|
||||
LOGGER.info("Instantiating AllCore");
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"description": "UniMixins module that remaps mods to use the correct names for Mixin packages.",
|
||||
"version": "${version}",
|
||||
"mcversion": "${minecraft_version}",
|
||||
"url": "",
|
||||
"url": "${project_url}",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"makamys"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
[
|
||||
{
|
||||
"modid": "unimixins-compat",
|
||||
"name": "UniMixins: Compatibility",
|
||||
"description": "UniMixins module that remaps mods to use the correct names for Mixin packages.",
|
||||
"modid": "unimixins-devcompat",
|
||||
"name": "UniMixins: Dev Compatibility",
|
||||
"description": "UniMixins module that applies compatibility tweaks for dev environments.",
|
||||
"version": "${version}",
|
||||
"mcversion": "${minecraft_version}",
|
||||
"url": "",
|
||||
"url": "${project_url}",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"makamys"
|
||||
|
||||
@@ -8,5 +8,6 @@ Modifications:
|
||||
|
||||
- Removed Mixin and MixinExtras bootstrap from GasStationCore.
|
||||
- Disabled dev mixin plugin because UniMixins's Compat module does the same thing.
|
||||
- Added call to "unimixins.mixinModidDecorator.refresh" after loading early mixins in GasStationCore and late mixins in LoadControllerMixin
|
||||
|
||||
License: LGPL3+SNEED (see LICENSE, COPYING and COPYING.LESSER)
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.falsepattern.gasstation.core;
|
||||
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
import com.falsepattern.gasstation.Tags;
|
||||
import com.falsepattern.gasstation.IEarlyMixinLoader;
|
||||
import io.github.legacymoddingmc.unimixins.gasstation.GasStationModule;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
@@ -66,6 +68,8 @@ public class GasStationCore implements IFMLLoadingPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
((Runnable) Launch.blackboard.getOrDefault("unimixins.mixinModidDecorator.refresh", Runnables.doNothing())).run();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
@@ -1,5 +1,6 @@
|
||||
package com.falsepattern.gasstation.mixins.mixin;
|
||||
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import cpw.mods.fml.common.*;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
|
||||
@@ -54,6 +55,8 @@ public abstract class LoadControllerMixin {
|
||||
}
|
||||
}
|
||||
|
||||
((Runnable)Launch.blackboard.getOrDefault("unimixins.mixinModidDecorator.refresh", Runnables.doNothing())).run();
|
||||
|
||||
for (ModContainer container : loader.getActiveModList()) {
|
||||
modClassLoader.addFile(container.getSource());
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
{
|
||||
"modid": "gasstation",
|
||||
"name": "UniMixins: GasStation",
|
||||
"description": "UniMixins module that provides GasStation extras.",
|
||||
"description": "UniMixins module that provides GasStation extras.\nDepends on: SpongeMixins, MixinBooterLegacy, MixinExtras",
|
||||
"version": "${extraVersion}+uni-${uniVersion}",
|
||||
"mcversion": "${mcversion}",
|
||||
"url": "",
|
||||
"url": "${project_url}",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"FalsePattern"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.3",
|
||||
"package": "com.falsepattern.gasstation.mixins.mixin",
|
||||
"refmap": "mixins.gasstation.refmap.json",
|
||||
"target": "@env(PREINIT)",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": ["LoadControllerMixin"]
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"mappings": {},
|
||||
"data": {}
|
||||
}
|
||||
@@ -9,5 +9,6 @@ Modifications:
|
||||
- added Mixin 0.7 support
|
||||
- made MixinExtras initialization get suppressed if Mixin version is below 0.8.5
|
||||
- made reflection support Mixin 0.7.11
|
||||
- added call to "unimixins.mixinModidDecorator.refresh" after loading early mixins in GTNHMixinsCore and late mixins in LateMixinOrchestrationMixin
|
||||
|
||||
License: LGPL3 (see LICENSE)
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizon.gtnhmixins.core;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
|
||||
import com.gtnewhorizon.gtnhmixins.Reflection;
|
||||
import com.llamalad7.mixinextras.MixinExtrasBootstrap;
|
||||
@@ -120,7 +121,8 @@ public class GTNHMixinsCore implements IFMLLoadingPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
((Runnable)Launch.blackboard.getOrDefault("unimixins.mixinModidDecorator.refresh", Runnables.doNothing())).run();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizon.gtnhmixins.mixins;
|
||||
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import com.gtnewhorizon.gtnhmixins.GTNHMixins;
|
||||
import com.gtnewhorizon.gtnhmixins.ILateMixinLoader;
|
||||
import com.gtnewhorizon.gtnhmixins.LateMixin;
|
||||
@@ -70,6 +71,8 @@ public class LateMixinOrchestrationMixin {
|
||||
|
||||
}
|
||||
|
||||
((Runnable)Launch.blackboard.getOrDefault("unimixins.mixinModidDecorator.refresh", Runnables.doNothing())).run();
|
||||
|
||||
// Add all mods to the classpath now so they're available for mixin
|
||||
for (ModContainer container : loader.getActiveModList()) {
|
||||
modClassLoader.addFile(container.getSource());
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public class GTNHMixinsModule {
|
||||
|
||||
if(!missingComponents.isEmpty()) {
|
||||
LOGGER.error("The following missing components were detected: " + missingComponents);
|
||||
LOGGER.error("Please obtain mods which provide them. See the readme inside the mod jar or the mod's GitHub page for more details.");
|
||||
LOGGER.error("Please obtain mods which provide them.");
|
||||
throw new RuntimeException("Missing components detected");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
{
|
||||
"modid": "${extraModid}",
|
||||
"name": "UniMixins: GTNHMixins",
|
||||
"description": "UniMixins module that provides GTNHMixins extras and MixinExtras with the GTNH package name.",
|
||||
"description": "UniMixins module that provides GTNHMixins extras and MixinExtras with the GTNH package name.\nDepends on: SpongeMixins",
|
||||
"version": "${extraVersion}+uni-${uniVersion}",
|
||||
"mcversion": "${mcversion}",
|
||||
"url": "",
|
||||
"url": "${project_url}",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"mitchej123"
|
||||
|
||||
@@ -14,6 +14,10 @@ archivesBaseName = archivesBaseName.replace("-1.7.10", "-mixin-1.7.10")
|
||||
|
||||
configurations.archives.artifacts.clear()
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.spongepowered:mixin:0.8.5")
|
||||
}
|
||||
|
||||
apply plugin: "com.github.johnrengelman.shadow"
|
||||
|
||||
["spongepowered", "fabric", "gasmix", "gtnh", "unimix"].each {
|
||||
@@ -31,14 +35,24 @@ apply plugin: "com.github.johnrengelman.shadow"
|
||||
// Fabric / SpongePowered / UniMix / GTNH
|
||||
|
||||
if (mixinFlavor == "fabric" || mixinFlavor == "unimix") {
|
||||
mixinVersion = mixinFlavor == "fabric" ? "0.11.4+mixin.0.8.5" : "0.11.6+mixin.0.8.5"
|
||||
if (mixinFlavor == "unimix" && project.hasProperty("local")) {
|
||||
def uniLocal = mixinFlavor == "unimix" && project.hasProperty("local")
|
||||
def uniJitpack = mixinFlavor == "unimix" && !uniLocal
|
||||
|
||||
mixinVersion = mixinFlavor == "fabric" ? "0.11.4+mixin.0.8.5" : "0.11.9+mixin.0.8.5"
|
||||
if (uniLocal) {
|
||||
mixinVersion += "-local"
|
||||
}
|
||||
def mixinGroup = mixinFlavor == "fabric" ? "net.fabricmc" : "com.github.legacymoddingmc"
|
||||
// For some reason, jitpack doesn't work if I have a + in the version string,
|
||||
// so UniMix doesn't actually have the +mixin.0.8.5 suffix in the maven version.
|
||||
def mixinDep = mixinFlavor == "fabric" ? "net.fabricmc:sponge-mixin:$mixinVersion" : "com.github.LegacyModdingMC:UniMix:${mixinVersion.split("\\+")[0]}"
|
||||
|
||||
// jitpack differences:
|
||||
// - domain is com instead of io (for some strange reason)
|
||||
// - we have to use _ instead of + in version string because the latter is not supported (for some strange reason)
|
||||
// - artifact id is UniMix, not sponge-mixin (this one makes sense at least)
|
||||
|
||||
def mixinGroup = mixinFlavor == "fabric" ? "net.fabricmc" : "${uniJitpack ? 'com' : 'io'}.github.legacymoddingmc"
|
||||
def mixinArtifactId = uniJitpack ? "UniMix" : "sponge-mixin"
|
||||
def mixinDepVersion = uniJitpack ? mixinVersion.replace('+', '_') : mixinVersion
|
||||
def mixinDep = "$mixinGroup:$mixinArtifactId:$mixinDepVersion"
|
||||
|
||||
mixinFlavorClassifier = "$mixinFlavor-$mixinVersion"
|
||||
|
||||
dependencies {
|
||||
@@ -211,6 +225,7 @@ apply plugin: "com.github.johnrengelman.shadow"
|
||||
'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
||||
'FMLCorePluginContainsFMLMod': 'true',
|
||||
'ForceLoadAsMod': 'true',
|
||||
'FMLCorePlugin': 'io.github.legacymoddingmc.unimixins.mixin.MixinCore',
|
||||
'Premain-Class': 'org.spongepowered.tools.agent.MixinAgent',
|
||||
'Agent-Class': 'org.spongepowered.tools.agent.MixinAgent',
|
||||
'Can-Redefine-Classes': true,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package io.github.legacymoddingmc.unimixins.mixin;
|
||||
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Handles platform-specific setup of the Mixin environment.
|
||||
*/
|
||||
|
||||
@IFMLLoadingPlugin.MCVersion("1.7.10")
|
||||
public class MixinCore implements IFMLLoadingPlugin {
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is the earliest point we can run code after Mixin is initialized via MixinTweaker.
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
MixinModidDecorator.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package io.github.legacymoddingmc.unimixins.mixin;
|
||||
|
||||
// Reference: https://github.com/FabricMC/fabric-loader/blob/2a378f1c563b6ec96ae6620a278ecd23fa09da0f/src/main/java/net/fabricmc/loader/impl/launch/FabricMixinBootstrap.java
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
import org.spongepowered.asm.mixin.transformer.Config;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Decorates mixin configs with the first modid read from the <tt>mcmod.info</tt> of the enclosing jar, so they can be
|
||||
* used in Mixin error messages.
|
||||
*/
|
||||
public final class MixinModidDecorator {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
|
||||
public static final String KEY_MOD_ID = "fabric-modId";
|
||||
|
||||
private static Map<String, String> jarNameToModid;
|
||||
|
||||
private MixinModidDecorator() {}
|
||||
|
||||
public static void apply() {
|
||||
if(jarNameToModid == null) {
|
||||
jarNameToModid = createJarNameToModidMap();
|
||||
|
||||
// A method handle that can be used anywhere to trigger a refresh
|
||||
Launch.blackboard.put("unimixins.mixinModidDecorator.refresh", (Runnable)MixinModidDecorator::apply);
|
||||
}
|
||||
|
||||
for (Config config : Mixins.getConfigs()) {
|
||||
if(!config.getConfig().hasDecoration(KEY_MOD_ID)) {
|
||||
URL resource = Launch.classLoader.getResource(config.getName());
|
||||
if (resource != null) {
|
||||
String jarName = getJarNameFromResourceUrl(resource);
|
||||
if (jarName != null) {
|
||||
String modid = jarNameToModid.get(jarName);
|
||||
if (modid != null) {
|
||||
config.getConfig().decorate(KEY_MOD_ID, modid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, String> createJarNameToModidMap() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
try {
|
||||
for (URL url : Collections.list(Launch.classLoader.getResources("mcmod.info"))) {
|
||||
String fileName = getJarNameFromResourceUrl(url);
|
||||
if (fileName != null) {
|
||||
List<ModMetadata> metas = parseMcmodInfo(url);
|
||||
if (!metas.isEmpty()) {
|
||||
String modid = metas.get(0).modid;
|
||||
if (modid != null) {
|
||||
map.put(fileName, modid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("Failed to construct jar name -> modid map, mod names will not be shown in errors.");
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static List<ModMetadata> parseMcmodInfo(URL url) {
|
||||
try {
|
||||
JsonElement root = new Gson().fromJson(new InputStreamReader(url.openStream()), JsonElement.class);
|
||||
if (root.isJsonArray()) {
|
||||
return Arrays.asList(new Gson().fromJson(new InputStreamReader(url.openStream()), ModMetadata[].class));
|
||||
} else {
|
||||
return Arrays.asList(new Gson().fromJson(new InputStreamReader(url.openStream()), ModMetadata.class));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("Failed to parse mcmod.info at " + url + ": " + e);
|
||||
}
|
||||
return Arrays.asList();
|
||||
}
|
||||
|
||||
private static String getJarNameFromResourceUrl(URL url) {
|
||||
if (url.getPath().contains("!/")) {
|
||||
String filePath = url.getPath().split("!/")[0];
|
||||
String[] parts = filePath.split("/");
|
||||
if (parts.length != 0) {
|
||||
return parts[parts.length - 1];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class ModMetadata {
|
||||
String modid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
"description": "UniMixins module that provides the @MIXIN_SOURCE_CAPITALIZED@ fork of Mixin (version: @MIXIN_CLASSIFIER@).",
|
||||
"version": "@VERSION@",
|
||||
"mcversion": "1.7.10",
|
||||
"url": "",
|
||||
"url": "${project_url}",
|
||||
"updateUrl": "",
|
||||
"authorList": ["makamys"],
|
||||
"credits": "",
|
||||
|
||||
@@ -8,5 +8,6 @@ Modifications:
|
||||
- Replaced mod container with a @Mod annotation
|
||||
- Changed shaded ASM package name to legacy one
|
||||
- Changed mixin config to use PREINIT phase
|
||||
- Added call to "unimixins.mixinModidDecorator.refresh" after loading early mixins in MixinBooterLegacyPlugin and late mixins in LoadControllerMixin
|
||||
|
||||
License: LGPL 2.1 (see LICENSE)
|
||||
+4
@@ -1,5 +1,6 @@
|
||||
package io.github.tox1cozz.mixinbooterlegacy;
|
||||
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
@@ -7,6 +8,7 @@ import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.Name;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.SortingIndex;
|
||||
import io.github.tox1cozz.mixinextras.MixinExtrasBootstrap;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixins;
|
||||
@@ -69,6 +71,8 @@ public final class MixinBooterLegacyPlugin implements IFMLLoadingPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
((Runnable) Launch.blackboard.getOrDefault("unimixins.mixinModidDecorator.refresh", Runnables.doNothing())).run();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
@@ -1,5 +1,6 @@
|
||||
package io.github.tox1cozz.mixinbooterlegacy.loader.mixin;
|
||||
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import cpw.mods.fml.common.*;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
import io.github.tox1cozz.mixinbooterlegacy.LateMixin;
|
||||
@@ -57,6 +58,8 @@ public class LoadControllerMixin {
|
||||
}
|
||||
}
|
||||
|
||||
((Runnable)Launch.blackboard.getOrDefault("unimixins.mixinModidDecorator.refresh", Runnables.doNothing())).run();
|
||||
|
||||
for (ModContainer container : loader.getActiveModList()) {
|
||||
modClassLoader.addFile(container.getSource());
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
"description": "UniMixins module that provides MixinBooterLegacy extras and MixinExtras with MixinBooterLegacy's package name.",
|
||||
"version": "${extraVersion}+uni-${uniVersion}",
|
||||
"mcversion": "${mcversion}",
|
||||
"url": "https://github.com/tox1cozZ/mixin-booter-legacy",
|
||||
"url": "${project_url}",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"Rongmario", "tox1cozZ"
|
||||
],
|
||||
"credits": "Thanks Rongmario for a MixinBooter on Minecraft 1.12.2.",
|
||||
"logoFile": "/icon.png",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "UniMixins module that provides MixinExtras (version: ${extraVersion}).",
|
||||
"version": "${extraVersion}+uni-${uniVersion}",
|
||||
"mcversion": "${minecraft_version}",
|
||||
"url": "",
|
||||
"url": "${project_url}",
|
||||
"updateUrl": "",
|
||||
"authorList": ["LlamaLad7"],
|
||||
"credits": "",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"description": "UniMixins module that implements Mixingasm (version: ${extraVersion}).",
|
||||
"version": "${extraVersion}+uni-${uniVersion}",
|
||||
"mcversion": "${minecraft_version}",
|
||||
"url": "",
|
||||
"url": "${project_url}",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"makamys"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"description": "UniMixins module that provides an emulation of SpongeMixins (version: ${extraVersion} from GTNHMixins).",
|
||||
"version": "${extraVersion}+uni-${uniVersion}",
|
||||
"mcversion": "${minecraft_version}",
|
||||
"url": "",
|
||||
"url": "${project_url}",
|
||||
"updateUrl": "",
|
||||
"authorList": [
|
||||
"Time_Conqueror", "mitchej123"
|
||||
|
||||
Reference in new issue
Block a user