Skip to content

Commit

Permalink
Merge branch 'develop' into mappings-fun
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexIIL authored Sep 18, 2024
2 parents 39d7537 + 3379b2e commit 90782d5
Show file tree
Hide file tree
Showing 20 changed files with 296 additions and 91 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ group = org.quiltmc
description = The mod loading component of Quilt
url = https://github.com/quiltmc/quilt-loader
# Don't forget to change this in QuiltLoaderImpl as well
quilt_loader = 0.26.4-beta.1
quilt_loader = 0.26.4

# Fabric & Quilt Libraries
asm = 9.6
sponge_mixin = 0.13.3+mixin.0.8.5
sponge_mixin = 0.15.3+mixin.0.8.7
tiny_mappings_parser = 0.3.0+build.17
tiny_remapper = 0.10.3
tiny_remapper = 0.10.4
access_widener = 2.1.0
mapping_io = 0.6.1
quilt_json5 = 1.0.4+final
Expand All @@ -27,4 +27,4 @@ annotations = 24.0.1
junit_bom = 5.9.3
github_api = 1.315
flexver = 1.1.0
mixin_extras = 0.3.5
mixin_extras = 0.4.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

package org.quiltmc.loader.impl.game.minecraft;

import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
import java.util.concurrent.CompletableFuture;

public final class BundlerClassPathCapture {
Expand All @@ -26,9 +29,42 @@ public final class BundlerClassPathCapture {
public static void main(String[] args) { // invoked by the bundler on a thread
try {
URLClassLoader cl = (URLClassLoader) Thread.currentThread().getContextClassLoader();
FUTURE.complete(cl.getURLs());
URL[] urls = cl.getURLs();

// suppress asm library since it conflicts with Loader's, needed for MC 24w33a

URL asmUrl = cl.findResource("org/objectweb/asm/ClassReader.class");

if (asmUrl != null && (asmUrl = getJarUrl(asmUrl)) != null) {
for (int i = 0; i < urls.length; i++) {
if (urls[i].equals(asmUrl)) {
URL[] newUrls = new URL[urls.length - 1];
System.arraycopy(urls, 0, newUrls, 0, i);
System.arraycopy(urls, i + 1, newUrls, i, urls.length - i - 1);
urls = newUrls;
break;
}
}
}

FUTURE.complete(urls);
} catch (Throwable t) {
FUTURE.completeExceptionally(t);
}
}

/**
* Transform jar:file url to its outer file url.
*
* <p>jar:file:/path/to.jar!/pkg/Cls.class -> file:/path/to.jar
*/
private static URL getJarUrl(URL url) throws IOException {
URLConnection connection = url.openConnection();

if (connection instanceof JarURLConnection) {
return ((JarURLConnection) connection).getJarFileURL();
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ protected static String getRelease(String version) {
int year = Integer.parseInt(matcher.group(1));
int week = Integer.parseInt(matcher.group(2));

if (year >= 24 && week >= 18) {
if (year >= 24 && week >= 33) {
return "1.21.2";
} else if (year == 24 && week >= 18 && week <= 21) {
return "1.21";
} else if (year == 23 && week >= 51 || year == 24 && week <= 14) {
return "1.20.5";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ public interface EntrypointContainer<T> {
* Returns the mod that provided this entrypoint.
*/
ModContainer getProvider();

/**
* Returns a string representation of the entrypoint's definition.
*/
default String getDefinition() {
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ public T getEntrypoint() {
public ModContainer getProvider() {
return new ModContainerImpl(quilt.getProvider());
}

@Override
public String getDefinition() {
return quilt.getDefinition();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ public interface EntrypointContainer<T> {
* Returns the mod that provided this entrypoint.
*/
ModContainer getProvider();

/**
* Returns a string representation of the entrypoint's definition.
*/
default String getDefinition() {
return "";
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/quiltmc/loader/impl/QuiltLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public final class QuiltLoaderImpl {

public static final int ASM_VERSION = Opcodes.ASM9;

public static final String VERSION = "0.26.4-beta.1";
public static final String VERSION = "0.26.4";
public static final String MOD_ID = "quilt_loader";
public static final String DEFAULT_MODS_DIR = "mods";
public static final String DEFAULT_CACHE_DIR = ".cache";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ interface Entry {
boolean isOptional();

ModContainerExt getModContainer();

String getDefinition();
}

@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -87,6 +89,11 @@ public boolean isOptional() {
public ModContainerExt getModContainer() {
return mod;
}

@Override
public String getDefinition() {
return value;
}
}

private static final class NewEntry implements Entry {
Expand Down Expand Up @@ -131,6 +138,11 @@ public boolean isOptional() {
public ModContainerExt getModContainer() {
return mod;
}

@Override
public String getDefinition() {
return value;
}
}

private final Map<String, List<Entry>> entryMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ private static <T> void invoke0(String name, Class<T> type, Consumer<EntrypointC
} catch (Throwable t) {
exception = ExceptionUtil.gatherExceptions(t,
exception,
exc -> new RuntimeException(String.format("Could not execute entrypoint stage '%s' due to errors, provided by '%s'!",
name, container.getProvider().metadata().id()),
exc -> new RuntimeException(String.format("Could not execute entrypoint stage '%s' due to errors, provided by '%s' at '%s'!",
name, container.getProvider().metadata().id(), container.getDefinition()),
exc));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static final class MixinConfigDecorator {
// maximum loader version and bundled fabric mixin version, DESCENDING ORDER, LATEST FIRST
// loader versions with new mixin versions need to be added here

// addVersion("0.13", FabricUtil.COMPATIBILITY_0_11_0); // example for next entry (latest first!)
addVersion("0.16.0", FabricUtil.COMPATIBILITY_0_14_0);
addVersion("0.12.0-", FabricUtil.COMPATIBILITY_0_10_0);
}

Expand All @@ -173,9 +173,11 @@ public static int getMixinCompat(boolean isFabric, ModMetadata metadata) {
List<VersionInterval> reqIntervals = Collections.singletonList(VersionInterval.INFINITE);

if (!isFabric) {
// quilt or builtin mod, we can assume it uses latest compat
Log.debug(LogCategory.MIXIN, "Assuming Quilt mod %s uses latest mixin compatibility", metadata.id());
return FabricUtil.COMPATIBILITY_LATEST;
// quilt or builtin mod, we can assume it uses latest (0.10.0 at the time) compat
// Except since <insert update that introduces mixin 0.14.0 compat>, we can't assume that anymore!
// TODO - Handle Quilt mods like Fabric mods but with our own version ranges
Log.debug(LogCategory.MIXIN, "Assuming Quilt mod %s uses 0.10.0 mixin compatibility", metadata.id());
return FabricUtil.COMPATIBILITY_0_10_0;
}

FabricLoaderModMetadata fabricMeta = ((InternalModMetadata) metadata).asFabricModMetadata();
Expand All @@ -202,11 +204,10 @@ public static int getMixinCompat(boolean isFabric, ModMetadata metadata) {
if (minLoaderVersion.compareTo(version.loaderVersion) >= 0) { // lower bound is >= current version
Log.debug(LogCategory.MIXIN, "Mod %s requires loader version %s, using mixin compatibility %s", metadata.id(), minLoaderVersion, version.mixinVersion);
return version.mixinVersion;
} else {
Log.debug(LogCategory.MIXIN, "Mod %s requires loader version %s, using 0.9.2 mixin compatability", metadata.id(), minLoaderVersion);
return FabricUtil.COMPATIBILITY_0_9_2;
}
}
Log.debug(LogCategory.MIXIN, "Mod %s requires loader version %s, using 0.9.2 mixin compatability", metadata.id(), minLoaderVersion);
return FabricUtil.COMPATIBILITY_0_9_2;
}

// Mod doesn't declare a dependency on a loader version; use oldest mixin compat version
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ public ClassNode getClassNode(String name) throws ClassNotFoundException, IOExce

@Override
public ClassNode getClassNode(String name, boolean runTransformers) throws ClassNotFoundException, IOException {
return getClassNode(name, runTransformers, 0);
}

@Override
public ClassNode getClassNode(String name, boolean runTransformers, int readerFlags) throws ClassNotFoundException, IOException {
ClassReader reader = new ClassReader(getClassBytes(name, runTransformers));
ClassNode node = new ClassNode();
reader.accept(node, 0);
reader.accept(node, readerFlags);
return node;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public QuiltPluginClassLoader(QuiltPluginContextImpl context, ClassLoader parent

@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
Class<?> c = loadClassInner(name);
Class<?> c = findLoadedClass(name);
if (c != null) {
return c;
}
c = loadClassInner(name);
if (c == null) {
return super.loadClass(name, resolve);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1590,24 +1590,37 @@ ModSolveResultImpl getPartialSolution() throws ModSolvingError, TimeoutException
Map<Class<?>, LoadOptionResult<?>> extraResults;
final Map<Class<?>, Map<Object, Boolean>> optionMap = new HashMap<>();

for (LoadOption option : solution) {
try {
for (LoadOption option : solution) {

boolean load = true;
if (LoadOption.isNegated(option)) {
option = option.negate();
load = false;
}
boolean load = true;
if (LoadOption.isNegated(option)) {
option = option.negate();
load = false;
}

if (load && option instanceof ModLoadOption) {
ModLoadOption mod = (ModLoadOption) option;
putMod(directModsMap, mod.id(), mod);
if (load && option instanceof ModLoadOption) {
ModLoadOption mod = (ModLoadOption) option;
putMod(directModsMap, mod.id(), mod);

for (ProvidedMod provided : mod.metadata().provides()) {
putMod(providedModsMap, provided.id(), mod);
for (ProvidedMod provided : mod.metadata().provides()) {
putMod(providedModsMap, provided.id(), mod);
}
}
}

putHierarchy(option, load, optionMap);
putHierarchy(option, load, optionMap);
}
} catch (ModSolvingError cause) {
// Something went wrong during solving
StringBuilder errorDesc = new StringBuilder("The solver returned a solution with duplicate mods!\n");
errorDesc.append(cause.getMessage());
errorDesc.append("\n\nCurrent Solution:");
for (LoadOption option : solution) {
errorDesc.append("\n\t-" + option);
}
errorDesc.append("\n\n");
solver.appendRules(errorDesc);
throw new ModSolvingError(errorDesc.toString(), cause);
}

extraResults = new HashMap<>();
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/quiltmc/loader/impl/solver/Sat4jWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,16 @@ public void cancel() {
cancelled = true;
}

// #############
// # Debugging #
// #############

/** Appends all current rules and options using the {@link SolverPreProcessor} format. */
public void appendRules(StringBuilder sb) {
InputRuleSet ruleSet = new InputRuleSet(optionToWeight, ruleToDefinitions);
SolverPreProcessor.appendRuleSet(ruleSet, ruleSet, str -> sb.append("\n" + str));
}

// ############
// # Internal #
// ############
Expand Down Expand Up @@ -525,7 +535,7 @@ boolean hasSolution() throws TimeoutException, ModSolvingError {
}
}
Log.info(CATEGORY, "Constant values:");
for (LoadOption option : processed.getConstantSolution()) {
for (String option : processed.getConstantSolution().stream().map(LoadOption::toString).sorted().toArray(String[]::new)) {
Log.info(CATEGORY, option.toString());
}
Log.info(CATEGORY, "Unknown values:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,13 @@ private ProcessedRuleSet process() throws ContradictionException, PreProcessExce
remaining.add(currentMin);
remaining.add(currentMax);
remaining.remove(null);
final Set<RuleDefinition> removing;
if (remaining.size() == 1) {
removing = new HashSet<>();
Set<RuleDefinition> removing = new HashSet<>();
removing.addAll(rules);
removing.removeAll(remaining);
removing.forEach(this::removeRule);
} else {
removing = rules;
rules.forEach(this::removeRule);
final Rule rule = remaining.iterator().next().rule;
final LoadOption[] array = optionSet.toArray(new LoadOption[0]);
if (max < optionSet.size()) {
Expand All @@ -487,7 +487,6 @@ private ProcessedRuleSet process() throws ContradictionException, PreProcessExce
// None of the rules affect the options
}
}
removing.forEach(this::removeRule);
changed = true;
}

Expand Down
Loading

0 comments on commit 90782d5

Please sign in to comment.