This commit is contained in:
shedaniel
2022-02-03 01:34:49 +08:00
parent 1ebf2eecab
commit 2c8f514694
3 changed files with 25 additions and 26 deletions

View File

@@ -26,7 +26,12 @@ repositories {
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modCompileOnly "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") {
// temp workaround to test arch
exclude module: "fabric-rendering-fluids-v1"
exclude module: "fabric-transfer-api-v1"
}
modCompileOnly("com.terraformersmc:modmenu:${rootProject.mod_menu_version}") { transitive false }
common(project(path: ":common", configuration: "namedElements")) { transitive false }

View File

@@ -20,9 +20,6 @@
package dev.architectury.plugin.fabric;
import net.fabricmc.loader.api.*;
import net.fabricmc.loader.api.SemanticVersion;
import net.fabricmc.loader.api.Version;
import net.fabricmc.loader.api.VersionParsingException;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
@@ -56,6 +53,21 @@ public class ArchitecturyMixinPlugin implements IMixinConfigPlugin {
return true;
}
private boolean isMinecraft1182() {
ModContainer minecraft = FabricLoader.getInstance().getModContainer("minecraft")
.orElseThrow(() -> new IllegalStateException("Where is minecraft?"));
Version version = minecraft.getMetadata().getVersion();
if (version instanceof SemanticVersion) {
try {
return version.compareTo(SemanticVersion.parse("1.18.2-")) >= 0;
} catch (VersionParsingException e) {
throw new IllegalStateException("Failed to parse version", e);
}
}
System.err.println("Minecraft is not a SemanticVersion, cannot determine if it is >= 1.18.2");
return true;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if ("dev.architectury.mixin.fabric.client.MixinEffectInstance".equals(mixinClassName)) {
@@ -65,27 +77,9 @@ public class ArchitecturyMixinPlugin implements IMixinConfigPlugin {
} else if ("dev.architectury.mixin.fabric.client.MixinGameRenderer013".equals(mixinClassName)) {
return isLoader013();
} else if ("dev.architectury.mixin.fabric.client.MixinMinecraft118".equals(mixinClassName)) {
Version minecraft = FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion();
// is below 1.18.2
Version version = null;
try {
version = SemanticVersion.parse("1.18.2-");
} catch (VersionParsingException e) {
e.printStackTrace();
return false;
}
return minecraft.compareTo(version) < 0;
return !isMinecraft1182();
} else if ("dev.architectury.mixin.fabric.client.MixinMinecraft1182".equals(mixinClassName)) {
Version minecraft = FabricLoader.getInstance().getModContainer("minecraft").get().getMetadata().getVersion();
// is 1.18.2 or above
Version version = null;
try {
version = SemanticVersion.parse("1.18.2-");
} catch (VersionParsingException e) {
e.printStackTrace();
return false;
}
return minecraft.compareTo(version) >= 0;
return isMinecraft1182();
}
return true;
}

View File

@@ -3,8 +3,8 @@ org.gradle.daemon=false
forgeEnabled=false
minecraft_version=22w03a
supported_version=1.18.2 (22w03a)
minecraft_version=22w05a
supported_version=1.18.2 (22w05a)
cf_type=release