Modernize toolchain

Now requires Fabric Loader 0.16.10 even on Minecraft 1.20.1
This commit is contained in:
embeddedt 2025-01-19 19:26:55 -05:00
parent f97766019a
commit e7f86f8687
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
8 changed files with 8 additions and 83 deletions

View File

@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.9-SNAPSHOT" apply false
id "maven-publish"
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.palantir.git-version' version '1.0.0'

View File

@ -1,7 +1,6 @@
package org.embeddedt.modernfix.common.mixin.bugfix.chunk_deadlock;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.gameevent.GameEvent;

View File

@ -29,7 +29,7 @@ configurations {
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
testImplementation "net.fabricmc:fabric-loader-junit:${rootProject.fabric_loader_version}"
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${rootProject.mixinextras_version}")))
annotationProcessor("io.github.llamalad7:mixinextras-fabric:${rootProject.mixinextras_version}")
modCompileOnly(fabricApi.module("fabric-api-base", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
modCompileOnly(fabricApi.module("fabric-screen-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }

View File

@ -5,7 +5,6 @@ import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import net.fabricmc.loader.impl.gui.FabricGuiEntry;
import net.fabricmc.loader.impl.gui.FabricStatusTree;
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
import org.embeddedt.modernfix.fabric.mappings.MappingsClearer;
import org.embeddedt.modernfix.spark.SparkLaunchProfiler;
import org.embeddedt.modernfix.util.CommonModUtil;
@ -19,9 +18,6 @@ public class ModernFixPreLaunchFabric implements PreLaunchEntrypoint {
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.spark_profile_launch.OnFabric")) {
CommonModUtil.runWithoutCrash(() -> SparkLaunchProfiler.start("launch"), "Failed to start profiler");
}
if(ModernFixMixinPlugin.instance.isOptionEnabled("perf.clear_fabric_mapping_tables.MappingsClearer")) {
MappingsClearer.clear();
}
// Prevent launching with Continuity when dynamic resources is on
if(false && ModernFixMixinPlugin.instance.isOptionEnabled("perf.dynamic_resources.ContinuityCheck")

View File

@ -1,71 +0,0 @@
package org.embeddedt.modernfix.fabric.mappings;
import net.fabricmc.loader.api.*;
import net.fabricmc.loader.impl.launch.FabricLauncherBase;
import net.fabricmc.loader.impl.launch.MappingConfiguration;
import net.fabricmc.mapping.tree.TinyMappingFactory;
import org.embeddedt.modernfix.util.CommonModUtil;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Optional;
/**
* Designed for Fabric Loader 0.14.x, probably has issues on other versions. The entire thing is wrapped in a try-catch
* so it should never cause crashes, just fail to work.
*/
public class MappingsClearer {
private static final Version LOADER_015;
static {
try {
LOADER_015 = Version.parse("0.15.0");
} catch (VersionParsingException e) {
throw new RuntimeException(e);
}
}
@SuppressWarnings("unchecked")
public static void clear() {
if(FabricLoader.getInstance().isDevelopmentEnvironment())
return; // never do this in dev
Optional<Version> loaderVersion = FabricLoader.getInstance().getModContainer("fabricloader").map(m -> m.getMetadata().getVersion());
if(!loaderVersion.isPresent() || LOADER_015.compareTo(loaderVersion.get()) < 0) {
// Fabric Loader is probably too new, abort
return;
}
CommonModUtil.runWithoutCrash(() -> {
// For now, force the mapping resolver to be initialized. Fabric Loader 0.14.23 stops initializing it early,
// which means that we actually need to keep the TinyMappingFactory tree around for initialization to work
// later. We force init it now because then we can store less in memory.
// Comparing heap dumps on 0.14.23 suggests a savings of 20MB by doing it our way, since many mods will
// end up needing the mapping resolver.
// This will need to be revisited when https://github.com/FabricMC/fabric-loader/pull/812 is merged.
FabricLoader.getInstance().getMappingResolver();
// clear notch->intermediary mappings
MappingConfiguration config = FabricLauncherBase.getLauncher().getMappingConfiguration();
Field mappingsField = MappingConfiguration.class.getDeclaredField("mappings");
mappingsField.setAccessible(true);
mappingsField.set(config, TinyMappingFactory.EMPTY_TREE);
// clear useless intermediary->intermediary mappings
MappingResolver resolver = FabricLoader.getInstance().getMappingResolver();
Class<?> targetResolverClz = Class.forName("net.fabricmc.loader.impl.MappingResolverImpl");
if(targetResolverClz.isAssignableFrom(resolver.getClass())) {
// hopefully still Loader 0.14.x, proceed
Class<?> namespaceDataClz = Class.forName("net.fabricmc.loader.impl.MappingResolverImpl$NamespaceData");
Constructor<?> constructor = namespaceDataClz.getDeclaredConstructor();
constructor.setAccessible(true);
Object theData = constructor.newInstance();
Field mapField = resolver.getClass().getDeclaredField("namespaceDataMap");
mapField.setAccessible(true);
Map<String, Object> theMap = (Map<String, Object>)mapField.get(resolver);
theMap.replace("intermediary", theData);
}
}, "Failed to clear mappings");
}
}

View File

@ -42,7 +42,8 @@
"modernfix-common.mixins.json"
],
"depends": {
"minecraft": ">=1.16.2"
"minecraft": ">=1.16.2",
"fabricloader": ">=0.16.10"
},
"breaks": {
"dashloader": "<5.0.0-beta.1"

View File

@ -2,7 +2,7 @@
org.gradle.jvmargs=-Xmx2G
junit_version=5.10.0-M1
mixinextras_version=0.3.2
mixinextras_version=0.4.1
mod_id=modernfix
minecraft_version=1.20.1
@ -18,7 +18,7 @@ kubejs_version=1902.6.0-build.142
rhino_version=1902.2.2-build.268
supported_minecraft_versions=1.20.1
fabric_loader_version=0.14.25
fabric_loader_version=0.16.10
fabric_api_version=0.86.0+1.20.1
continuity_version=3.0.0-beta.2+1.19.3
@ -28,7 +28,7 @@ diagonal_fences_version=4558828
spark_version=4587310
use_fabric_api_at_runtime=false
use_fabric_api_at_runtime=true
# Look up maven coordinates when changing shadow_version
shadow_version=7.1.2

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME