Skip to content

Commit

Permalink
Merge branch 'develop' into qconf-update-2
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai authored Feb 10, 2024
2 parents 2e5b77c + 362d2f8 commit d56bc44
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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.23.0-beta.1
quilt_loader = 0.23.1

# Fabric & Quilt Libraries
asm = 9.6
Expand Down
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 >= 23 && week >= 40) {
if (year >= 23 && week >= 51) {
return "1.20.5";
} else if (year == 23 && week >= 40 && week <= 46) {
return "1.20.3";
} else if (year >= 23 && week >= 31 && week <= 35) {
return "1.20.2";
Expand Down
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 @@ -129,7 +129,7 @@ public final class QuiltLoaderImpl {

public static final int ASM_VERSION = Opcodes.ASM9;

public static final String VERSION = "0.23.0-beta.1";
public static final String VERSION = "0.23.1";
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 @@ -22,6 +22,8 @@
import java.util.List;
import java.util.Map;

import net.fabricmc.api.EnvType;

import org.jetbrains.annotations.Nullable;
import org.quiltmc.loader.api.ModContributor;
import org.quiltmc.loader.api.ModDependency;
Expand Down Expand Up @@ -61,7 +63,7 @@ public class V1ModMetadataBuilder {
public final Map<String, String> languageAdapters = new LinkedHashMap<>();
public final List<String> repositories = new ArrayList<>();
/* TODO: Move to plugins */
public final List<String> mixins = new ArrayList<>();
public final Map<EnvType, List<String>> mixins = new HashMap<>();
public final List<String> accessWideners = new ArrayList<>();
public ModEnvironment env = ModEnvironment.UNIVERSAL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final class V1ModMetadataImpl implements InternalModMetadata {
private final Collection<String> jars;
private final Map<String, String> languageAdapters;
private final Collection<String> repositories;
private final Collection<String> mixins;
private final Map<EnvType, Collection<String>> mixins;
private final Collection<String> accessWideners;
private final ModEnvironment environment;
private final @Nullable ModPlugin plugin;
Expand Down Expand Up @@ -131,7 +131,7 @@ final class V1ModMetadataImpl implements InternalModMetadata {
this.repositories = Collections.unmodifiableCollection(builder.repositories);

// Move to plugins
this.mixins = Collections.unmodifiableCollection(builder.mixins);
this.mixins = Collections.unmodifiableMap(builder.mixins);
this.accessWideners = Collections.unmodifiableCollection(builder.accessWideners);
this.environment = builder.env;

Expand Down Expand Up @@ -307,7 +307,7 @@ public Collection<String> repositories() {

@Override
public Collection<String> mixins(EnvType env) {
return this.mixins;
return this.mixins.getOrDefault(env, Collections.emptyList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand All @@ -33,11 +32,12 @@
import java.util.SortedMap;
import java.util.TreeMap;

import net.fabricmc.api.EnvType;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.quiltmc.json5.exception.ParseException;
import org.quiltmc.loader.api.LoaderValue;
import org.quiltmc.loader.api.LoaderValue.LArray;
import org.quiltmc.loader.api.LoaderValue.LType;
import org.quiltmc.loader.api.ModDependency;
import org.quiltmc.loader.api.ModDependencyIdentifier;
Expand Down Expand Up @@ -371,13 +371,17 @@ private V1ModMetadataImpl readFields(JsonLoaderValue.ObjectImpl root) {
if (mixinValue != null) {
switch (mixinValue.type()) {
case ARRAY:
readStringList((JsonLoaderValue.ArrayImpl) mixinValue, "mixin", builder.mixins);
readMixins((JsonLoaderValue.ArrayImpl) mixinValue, builder.mixins);
break;
case STRING:
builder.mixins.add(mixinValue.asString());
builder.mixins.computeIfAbsent(EnvType.CLIENT, (env) -> new ArrayList<>()).add(mixinValue.asString());
builder.mixins.computeIfAbsent(EnvType.SERVER, (env) -> new ArrayList<>()).add(mixinValue.asString());
break;
case OBJECT:
readMixin(mixinValue.asObject(), builder.mixins);
break;
default:
throw parseException(mixinValue, "mixin value must be an array of strings or a string");
throw parseException(mixinValue, "mixin value must be a string, a mixin entry, or a mixed array of either");
}
}

Expand Down Expand Up @@ -1008,4 +1012,53 @@ public static VersionRange readVersionSpecifier(String string) throws VersionFor
}
}
}

private static void readMixins(JsonLoaderValue.ArrayImpl array, Map<EnvType, List<String>> destination) {
for (LoaderValue value : array) {
if (value.type() == LoaderValue.LType.STRING) {
destination.computeIfAbsent(EnvType.CLIENT, (env) -> new ArrayList<>()).add(value.asString());
destination.computeIfAbsent(EnvType.SERVER, (env) -> new ArrayList<>()).add(value.asString());
} else if (value.type() == LoaderValue.LType.OBJECT) {
LoaderValue.LObject object = value.asObject();
readMixin(object, destination);
} else {
throw parseException((JsonLoaderValue) value, "Entry inside mixin must be a string or object");
}
}
}

private static void readMixin(LoaderValue.LObject object, Map<EnvType, List<String>> destination) {
LoaderValue config = object.get("config");

if (config == null) {
throw parseException((JsonLoaderValue) object, "Mixin entry inside must have a config value");
} else if (config.type() != LoaderValue.LType.STRING) {
throw parseException((JsonLoaderValue) object, "Mixin entry config must be a string");
}
LoaderValue environment = object.get("environment");

if (environment == null) {
destination.computeIfAbsent(EnvType.CLIENT, (env) -> new ArrayList<>()).add(config.asString());
destination.computeIfAbsent(EnvType.SERVER, (env) -> new ArrayList<>()).add(config.asString());
} else {
if (environment.type() != LoaderValue.LType.STRING) {
throw parseException((JsonLoaderValue) object, "Mixin entry environment must be a string");
}

switch (environment.asString()) {
case "client":
destination.computeIfAbsent(EnvType.CLIENT, (env) -> new ArrayList<>()).add(config.asString());
break;
case "dedicated_server":
destination.computeIfAbsent(EnvType.SERVER, (env) -> new ArrayList<>()).add(config.asString());
break;
case "*":
destination.computeIfAbsent(EnvType.CLIENT, (env) -> new ArrayList<>()).add(config.asString());
destination.computeIfAbsent(EnvType.SERVER, (env) -> new ArrayList<>()).add(config.asString());
break;
default:
throw parseException((JsonLoaderValue) object, "Mixin entry environment must be one of 'client', 'dedicated_server', or '*'");
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/changelog/0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Features:

- Changed the solver pre-processor to include it's state in the crash report when it encounters a contradiction.
- This makes it easy for a loader developer to reproduce the solver state in order to debug it.
- Bumped provided version of Fabric Loader from 0.14.24 to 0.15.2
- Bumped provided version of Fabric Loader from 0.14.24 to 0.15.3
- Added MixinExtras as a jar-in-jar mod inside of quilt loader.
- This is an additional library for creating mixins in more expressive and compatible ways.
For example "@WrapOperation" is a more compatible way of doing "@Redirect", if you don't need
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/changelog/0.23.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Features:

- Added support for sided mixins in a quilt.mod.json files:
- See https://github.com/QuiltMC/rfcs/pull/89/files for the spec changes

For example:

"mixin": [
{
"config": "modid_client.mixins.json",
"environment": "client"
},
"modid.mixins.json"
]

would load `modid.mixins.json` on both dedicated servers and clients, and not load `modid_client.mixins.json` on the dedicated server.
2 changes: 1 addition & 1 deletion src/main/resources/quilt.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"provides": [
{
"id": "fabricloader",
"version": "0.15.2"
"version": "0.15.3"
}
],
"depends": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"schema_version": 1,
"quilt_loader": {
"group": "org.example",
"id": "some_id",
"version": "1.0.0",
"intermediate_mappings": "net.fabricmc:intermediary"
},
"mixin": [
"mixin.config.json",
{
"config": "mixin2.config.json"
},
{
"config": "mixin3.config.json",
"environment": "client"
},
{
"config": "mixin4.config.json",
"environment": "dedicated_server"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"schema_version": 1,
"quilt_loader": {
"group": "org.example",
"id": "some_id",
"version": "1.0.0",
"intermediate_mappings": "net.fabricmc:intermediary"
},
"mixin": {
"config": "mixin.config.json",
"environment": "client"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"schema_version": 1,
"quilt_loader": {
"group": "org.example",
"id": "some_id",
"version": "1.0.0",
"intermediate_mappings": "net.fabricmc:intermediary"
},
"mixin": "mixin.config.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"schema_version": 1,
"quilt_loader": {
"group": "org.example",
"id": "some_id",
"version": "1.0.0",
"intermediate_mappings": "net.fabricmc:intermediary"
},
"mixin": [
"mixin.config.json",
"mixin2.config.json"
]
}

0 comments on commit d56bc44

Please sign in to comment.