Skip to content

Commit

Permalink
Initialise fabric to quilt metadata wrapping early, since this will a…
Browse files Browse the repository at this point in the history
…llow us to debug an issue where it doesn't work sometimes.
  • Loading branch information
AlexIIL committed Feb 10, 2024
1 parent 362d2f8 commit 0455613
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 219 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ final class V0ModMetadataFabric extends AbstractModMetadata implements FabricLoa
private final ContactInformation links;
private final String license;

private FabricModMetadataWrapper cache2quilt;
private final FabricModMetadataWrapper wrapped2quilt;

V0ModMetadataFabric(String id, Version version, Collection<ModDependency> dependencies, Mixins mixins, ModEnvironment environment, String initializer, Collection<String> initializers,
String name, String description, Collection<Person> authors, Collection<Person> contributors, ContactInformation links, String license) {
String name, String description, Collection<Person> authors, Collection<Person> contributors, ContactInformation links, String license) throws ParseMetadataException {
this.id = id;
this.version = version;
this.dependencies = Collections.unmodifiableCollection(dependencies);
Expand All @@ -94,14 +94,14 @@ final class V0ModMetadataFabric extends AbstractModMetadata implements FabricLoa
this.contributors = Collections.unmodifiableCollection(contributors);
this.links = links;
this.license = license;

// Must come last
this.wrapped2quilt = new FabricModMetadataWrapper(this);
}

@Override
public InternalModMetadata asQuiltModMetadata() {
if (cache2quilt == null) {
cache2quilt = new FabricModMetadataWrapper(this);
}
return cache2quilt;
return wrapped2quilt;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ final class V1ModMetadataFabric extends AbstractModMetadata implements FabricLoa
// Optional (custom values)
private final Map<String, CustomValue> customValues;

private FabricModMetadataWrapper cache2quilt;
private final FabricModMetadataWrapper wrapped2quilt;

V1ModMetadataFabric(String id, Version version, Collection<String> provides,
ModEnvironment environment, Map<String, List<EntrypointMetadata>> entrypoints, Collection<NestedJarEntry> jars,
Expand All @@ -93,7 +93,7 @@ final class V1ModMetadataFabric extends AbstractModMetadata implements FabricLoa
/* @Nullable */ String name, @Nullable String description,
Collection<Person> authors, Collection<Person> contributors, @Nullable ContactInformation contact, Collection<String> license, IconEntry icon,
Map<String, String> languageAdapters,
Map<String, CustomValue> customValues) {
Map<String, CustomValue> customValues) throws ParseMetadataException {
this.id = id;
this.version = version;
this.provides = Collections.unmodifiableCollection(provides);
Expand Down Expand Up @@ -132,14 +132,13 @@ final class V1ModMetadataFabric extends AbstractModMetadata implements FabricLoa

this.languageAdapters = Collections.unmodifiableMap(languageAdapters);
this.customValues = Collections.unmodifiableMap(customValues);

this.wrapped2quilt = new FabricModMetadataWrapper(this);
}

@Override
public InternalModMetadata asQuiltModMetadata() {
if (cache2quilt == null) {
cache2quilt = new FabricModMetadataWrapper(this);
}
return cache2quilt;
return wrapped2quilt;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.quiltmc.loader.api.ModLicense;
import org.quiltmc.loader.api.Version;
import org.quiltmc.loader.api.VersionRange;
import org.quiltmc.loader.impl.fabric.metadata.ParseMetadataException;
import org.quiltmc.loader.impl.metadata.EntrypointMetadata;
import org.quiltmc.loader.impl.metadata.FabricLoaderModMetadata;
import org.quiltmc.loader.impl.metadata.NestedJarEntry;
Expand Down Expand Up @@ -61,7 +62,7 @@ public class FabricModMetadataWrapper implements InternalModMetadata {
private final Map<String, Collection<ModEntrypoint>> entrypoints;
private final List<ProvidedMod> provides;

public FabricModMetadataWrapper(FabricLoaderModMetadata fabricMeta) {
public FabricModMetadataWrapper(FabricLoaderModMetadata fabricMeta) throws ParseMetadataException {
this.fabricMeta = fabricMeta;
net.fabricmc.loader.api.Version fabricVersion = fabricMeta.getVersion();
this.version = Version.of(fabricVersion.getFriendlyString());
Expand Down Expand Up @@ -196,7 +197,7 @@ public ModLoadType loadType() {
return null;
}

private static Collection<ModDependency> genDepends(Collection<net.fabricmc.loader.api.metadata.ModDependency> from) {
private static Collection<ModDependency> genDepends(Collection<net.fabricmc.loader.api.metadata.ModDependency> from) throws ParseMetadataException {
List<ModDependency> out = new ArrayList<>();
for (net.fabricmc.loader.api.metadata.ModDependency f : from) {
List<org.quiltmc.loader.api.VersionInterval> quiltIntervals = new ArrayList<>();
Expand All @@ -216,7 +217,11 @@ private static Collection<ModDependency> genDepends(Collection<net.fabricmc.load
quiltIntervals.add(new VersionIntervalImpl(newMin, versionInterval.isMinInclusive(), newMax, versionInterval.isMaxInclusive()));
}

out.add(new ModDependencyImpl.OnlyImpl("Fabric Dependency", new ModDependencyIdentifierImpl(f.getModId()), VersionRange.ofIntervals(quiltIntervals), null, false, null));
VersionRange range = VersionRange.ofIntervals(quiltIntervals);
if (range.isEmpty()) {
throw new ParseMetadataException("Dependency version range was empty for " + f);
}
out.add(new ModDependencyImpl.OnlyImpl("Fabric Dependency", new ModDependencyIdentifierImpl(f.getModId()), range, null, false, null));
}
return Collections.unmodifiableList(Arrays.asList(out.toArray(new ModDependency[0])));
}
Expand Down

0 comments on commit 0455613

Please sign in to comment.