Skip to content

Commit

Permalink
Merge branch 'floader-0.15.6-update' into develop (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexIIL committed Feb 14, 2024
2 parents 67dbb3b + 782c3fc commit 309a30d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ quilt_loader = 0.24.0-beta.2
asm = 9.6
sponge_mixin = 0.12.5+mixin.0.8.5
tiny_mappings_parser = 0.3.0+build.17
tiny_remapper = 0.8.6
tiny_remapper = 0.10.0
access_widener = 2.1.0
quilt_json5 = 1.0.4+final
quilt_parsers = 0.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ protected static String getRelease(String version) {
int year = Integer.parseInt(matcher.group(1));
int week = Integer.parseInt(matcher.group(2));

if (year >= 23 && week >= 51) {
if (year == 23 && week >= 51 || year >= 24) {
return "1.20.5";
} else if (year == 23 && week >= 40 && week <= 46) {
return "1.20.3";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public boolean locateGame(QuiltLauncher launcher, String[] args) {
// expose obfuscated jar locations for mods to more easily remap code from obfuscated to intermediary
ObjectShare share = QuiltLoaderImpl.INSTANCE.getObjectShare();
share.put("fabric-loader:inputGameJar", gameJars.get(0)); // deprecated
share.put("fabric-loader:inputGameJars", gameJars);
share.put("fabric-loader:inputGameJars", Collections.unmodifiableList(new ArrayList<>(gameJars))); // need to make copy as gameJars is later mutated to hold the remapped jars
if (realmsJar != null) share.put("fabric-loader:inputRealmsJar", realmsJar);

String version = arguments.remove(Arguments.GAME_VERSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.stream.Collectors;

import org.objectweb.asm.commons.Remapper;
Expand All @@ -36,6 +41,7 @@
import org.quiltmc.loader.impl.QuiltLoaderImpl;
import org.quiltmc.loader.impl.launch.common.QuiltLauncher;
import org.quiltmc.loader.impl.launch.common.QuiltLauncherBase;
import org.quiltmc.loader.impl.util.ManifestUtil;
import org.quiltmc.loader.impl.util.QuiltLoaderInternal;
import org.quiltmc.loader.impl.util.QuiltLoaderInternalType;
import org.quiltmc.loader.impl.util.SystemProperties;
Expand All @@ -48,16 +54,20 @@
import net.fabricmc.tinyremapper.NonClassCopyMode;
import net.fabricmc.tinyremapper.OutputConsumerPath;
import net.fabricmc.tinyremapper.TinyRemapper;
import net.fabricmc.tinyremapper.extension.mixin.MixinExtension;

@QuiltLoaderInternal(QuiltLoaderInternalType.NEW_INTERNAL)
final class RuntimeModRemapper {
private static final String REMAP_TYPE_MANIFEST_KEY = "Fabric-Loom-Mixin-Remap-Type";
private static final String REMAP_TYPE_STATIC = "static";

static final boolean COPY_ON_WRITE = true;

public static void remap(TransformCache cache) {
List<ModLoadOption> modsToRemap = cache.getMods().stream()
.filter(modLoadOption -> modLoadOption.namespaceMappingFrom() != null)
.collect(Collectors.toList());
Set<InputTag> remapMixins = new HashSet<>();

if (modsToRemap.isEmpty()) {
return;
Expand All @@ -68,6 +78,7 @@ public static void remap(TransformCache cache) {
TinyRemapper remapper = TinyRemapper.newRemapper()
.withMappings(TinyRemapperMappingsHelper.create(launcher.getMappingConfiguration().getMappings(), "intermediary", launcher.getTargetNamespace()))
.renameInvalidLocals(false)
.extension(new MixinExtension(remapMixins::contains))
.build();

try {
Expand All @@ -85,6 +96,11 @@ public static void remap(TransformCache cache) {
InputTag tag = remapper.createInputTag();
info.tag = tag;
info.inputPath = mod.resourceRoot().toAbsolutePath();

if (requiresMixinRemap(info.inputPath)) {
remapMixins.add(tag);
}

remapper.readInputsAsync(tag, info.inputPath);
}

Expand Down Expand Up @@ -152,6 +168,12 @@ private static List<Path> getRemapClasspath() throws IOException {
.collect(Collectors.toList());
}

private static boolean requiresMixinRemap(Path inputPath) throws IOException {
final Manifest manifest = ManifestUtil.readManifest(inputPath);
final Attributes mainAttributes = manifest.getMainAttributes();
return REMAP_TYPE_STATIC.equalsIgnoreCase(mainAttributes.getValue(REMAP_TYPE_MANIFEST_KEY));
}

private static class RemapInfo {
InputTag tag;
Path inputPath;
Expand Down

0 comments on commit 309a30d

Please sign in to comment.