Skip to content

Commit 0d17081

Browse files
Su5eDPlayer3324SHsuperCMPlayermodmuss50
authored
Fabric Loader 0.16.14 (#7)
* Rename ModCandidate to ModCandidateImpl (cherry picked from commit da94132) * Specify full entrypoint name on crash (#928) * Specify full entrypoint name on crash * Default getEntrypointName for EntrypointContainer * Rephrased entrypoint exception message (cherry picked from commit 12dd25f) * Use less path normalization due to poor performance on Windows (#971) (cherry picked from commit fcd01e5) * Add missing normalization, cache normalization (#974) (cherry picked from commit 2908ef3) * Always normalize path for mods on the class path (cherry picked from commit 7c36ee4ac890244a6f0f6a69b9c89fb8d780188b) * Fix crash when trying to scan an empty list of mods. (cherry picked from commit e7694f0ff638a1fcb4b66ac64cee20a02058e815) * Add Korean translation (#980) (cherry picked from commit e41ae16f9c9d44decda4898c06619df36fe977b3) * Bump version Signed-off-by: unilock <[email protected]> --------- Signed-off-by: unilock <[email protected]> Co-authored-by: Player <[email protected]> Co-authored-by: SHsuperCM <[email protected]> Co-authored-by: Player <[email protected]> Co-authored-by: modmuss50 <[email protected]> Co-authored-by: AsseyGithub <[email protected]>
2 parents 63f15bf + 3f1b88f commit 0d17081

15 files changed

+395
-225
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ org.gradle.jvmargs=-Xmx3G
55
loom.platform=neoforge
66

77
versionMc=1.21.1
8-
versionForge=21.1.4
9-
versionLoaderUpstream=0.16.0
8+
versionForge=21.1.169
9+
versionLoaderUpstream=0.16.14
1010
versionYarn=1.21.1+build.3

src/main/java/net/fabricmc/loader/api/entrypoint/EntrypointContainer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@ public interface EntrypointContainer<T> {
3434
* Returns the mod that provided this entrypoint.
3535
*/
3636
ModContainer getProvider();
37+
38+
/**
39+
* Returns a string representation of the entrypoint's definition.
40+
*/
41+
default String getDefinition() {
42+
return "";
43+
}
3744
}

src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ public <T> void invokeEntrypoints(String key, Class<T> type, Consumer<? super T>
130130
} catch (Throwable t) {
131131
exception = ExceptionUtil.gatherExceptions(t,
132132
exception,
133-
exc -> new RuntimeException(String.format("Could not execute entrypoint stage '%s' due to errors, provided by '%s'!",
134-
key, container.getProvider().getMetadata().getId()),
133+
exc -> new RuntimeException(String.format("Could not execute entrypoint stage '%s' due to errors, provided by '%s' at '%s'!",
134+
key, container.getProvider().getMetadata().getId(), container.getDefinition()),
135135
exc));
136136
}
137137
}

src/main/java/net/fabricmc/loader/impl/discovery/ClasspathModCandidateFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void findCandidates(ModCandidateConsumer out) {
4646
URL url = mods.nextElement();
4747

4848
try {
49-
Path path = LoaderUtil.normalizeExistingPath(UrlUtil.getCodeSource(url, "fabric.mod.json"));
49+
Path path = LoaderUtil.normalizeExistingPath(UrlUtil.getCodeSource(url, "fabric.mod.json")); // code source may not be normalized if from app cl
5050
List<Path> paths = pathGroups.get(path);
5151

5252
if (paths == null) {

src/main/java/net/fabricmc/loader/impl/discovery/DirectoryModCandidateFinder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package net.fabricmc.loader.impl.discovery;
1818

19+
import net.fabricmc.loader.impl.util.LoaderUtil;
1920
import net.fabricmc.loader.impl.util.log.Log;
2021
import net.fabricmc.loader.impl.util.log.LogCategory;
2122

@@ -29,7 +30,7 @@ public class DirectoryModCandidateFinder implements ModCandidateFinder {
2930
private final boolean requiresRemap;
3031

3132
public DirectoryModCandidateFinder(Path path, boolean requiresRemap) {
32-
this.path = path;
33+
this.path = LoaderUtil.normalizePath(path);
3334
this.requiresRemap = requiresRemap;
3435
}
3536

@@ -38,6 +39,7 @@ public void findCandidates(ModCandidateConsumer out) {
3839
if (!Files.exists(path)) {
3940
try {
4041
Files.createDirectory(path);
42+
return;
4143
} catch (IOException e) {
4244
throw new RuntimeException("Could not create directory " + path, e);
4345
}

src/main/java/net/fabricmc/loader/impl/discovery/Explanation.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@ class Explanation implements Comparable<Explanation> {
2222
private static int nextCmpId;
2323

2424
final ErrorKind error;
25-
final ModCandidate mod;
25+
final ModCandidateImpl mod;
2626
final ModDependency dep;
2727
final String data;
2828
private final int cmpId;
2929

30-
Explanation(ErrorKind error, ModCandidate mod) {
30+
Explanation(ErrorKind error, ModCandidateImpl mod) {
3131
this(error, mod, null, null);
3232
}
3333

34-
Explanation(ErrorKind error, ModCandidate mod, ModDependency dep) {
34+
Explanation(ErrorKind error, ModCandidateImpl mod, ModDependency dep) {
3535
this(error, mod, dep, null);
3636
}
3737

3838
Explanation(ErrorKind error, String data) {
3939
this(error, null, data);
4040
}
4141

42-
Explanation(ErrorKind error, ModCandidate mod, String data) {
42+
Explanation(ErrorKind error, ModCandidateImpl mod, String data) {
4343
this(error, mod, null, data);
4444
}
4545

46-
private Explanation(ErrorKind error, ModCandidate mod, ModDependency dep, String data) {
46+
private Explanation(ErrorKind error, ModCandidateImpl mod, ModDependency dep, String data) {
4747
this.error = error;
4848
this.mod = mod;
4949
this.dep = dep;

src/main/java/net/fabricmc/loader/impl/discovery/ModCandidate.java renamed to src/main/java/net/fabricmc/loader/impl/discovery/ModCandidateImpl.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
import java.util.zip.ZipFile;
3838
import java.util.zip.ZipInputStream;
3939

40-
public final class ModCandidate implements DomainObject.Mod {
41-
static final Comparator<ModCandidate> ID_VERSION_COMPARATOR = new Comparator<ModCandidate>() {
40+
public final class ModCandidateImpl implements DomainObject.Mod {
41+
static final Comparator<ModCandidateImpl> ID_VERSION_COMPARATOR = new Comparator<ModCandidateImpl>() {
4242
@Override
43-
public int compare(ModCandidate a, ModCandidate b) {
43+
public int compare(ModCandidateImpl a, ModCandidateImpl b) {
4444
int cmp = a.getId().compareTo(b.getId());
4545

4646
return cmp != 0 ? cmp : a.getVersion().compareTo(b.getVersion());
@@ -53,25 +53,25 @@ public int compare(ModCandidate a, ModCandidate b) {
5353
private final long hash;
5454
private final LoaderModMetadata metadata;
5555
private final boolean requiresRemap;
56-
private final Collection<ModCandidate> nestedMods;
57-
private final Collection<ModCandidate> parentMods;
56+
private final Collection<ModCandidateImpl> nestedMods;
57+
private final Collection<ModCandidateImpl> parentMods;
5858
private int minNestLevel;
5959
private SoftReference<ByteBuffer> dataRef;
6060

61-
public static ModCandidate createBuiltin(BuiltinMod mod, VersionOverrides versionOverrides, DependencyOverrides depOverrides) {
61+
public static ModCandidateImpl createBuiltin(BuiltinMod mod, VersionOverrides versionOverrides, DependencyOverrides depOverrides) {
6262
LoaderModMetadata metadata = new BuiltinMetadataWrapper(mod.metadata);
6363
versionOverrides.apply(metadata);
6464
depOverrides.apply(metadata);
6565

66-
return new ModCandidate(mod.paths, null, -1, metadata, false, Collections.emptyList());
66+
return new ModCandidateImpl(mod.paths, null, -1, metadata, false, Collections.emptyList());
6767
}
6868

69-
public static ModCandidate createPlain(List<Path> paths, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidate> nestedMods) {
70-
return new ModCandidate(paths, null, -1, metadata, requiresRemap, nestedMods);
69+
public static ModCandidateImpl createPlain(List<Path> paths, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidateImpl> nestedMods) {
70+
return new ModCandidateImpl(paths, null, -1, metadata, requiresRemap, nestedMods);
7171
}
7272

73-
static ModCandidate createNested(String localPath, long hash, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidate> nestedMods) {
74-
return new ModCandidate(null, localPath, hash, metadata, requiresRemap, nestedMods);
73+
static ModCandidateImpl createNested(String localPath, long hash, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidateImpl> nestedMods) {
74+
return new ModCandidateImpl(null, localPath, hash, metadata, requiresRemap, nestedMods);
7575
}
7676

7777
static long hash(ZipEntry entry) {
@@ -84,7 +84,7 @@ private static long getSize(long hash) {
8484
return hash & 0xffffffffL;
8585
}
8686

87-
private ModCandidate(List<Path> paths, String localPath, long hash, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidate> nestedMods) {
87+
private ModCandidateImpl(List<Path> paths, String localPath, long hash, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidateImpl> nestedMods) {
8888
this.originPaths = paths;
8989
this.paths = paths;
9090
this.localPath = localPath;
@@ -161,15 +161,15 @@ public boolean getRequiresRemap() {
161161
return requiresRemap;
162162
}
163163

164-
public Collection<ModCandidate> getNestedMods() {
164+
public Collection<ModCandidateImpl> getNestedMods() {
165165
return nestedMods;
166166
}
167167

168-
public Collection<ModCandidate> getParentMods() {
168+
public Collection<ModCandidateImpl> getParentMods() {
169169
return parentMods;
170170
}
171171

172-
public boolean addParent(ModCandidate parent) {
172+
public boolean addParent(ModCandidateImpl parent) {
173173
if (minNestLevel == 0) return false;
174174
if (parentMods.contains(parent)) return false;
175175

@@ -192,7 +192,7 @@ boolean resetMinNestLevel() {
192192
}
193193
}
194194

195-
boolean updateMinNestLevel(ModCandidate parent) {
195+
boolean updateMinNestLevel(ModCandidateImpl parent) {
196196
if (minNestLevel <= parent.minNestLevel) return false;
197197

198198
this.minNestLevel = parent.minNestLevel + 1;
@@ -286,7 +286,7 @@ private void copyToFile(Path out) throws IOException {
286286
return;
287287
}
288288

289-
ModCandidate parent = getBestSourcingParent();
289+
ModCandidateImpl parent = getBestSourcingParent();
290290

291291
if (parent.paths != null) {
292292
if (parent.paths.size() != 1) throw new UnsupportedOperationException("multiple parent paths for "+this);
@@ -330,7 +330,7 @@ private ByteBuffer getData() throws IOException {
330330

331331
ret = ByteBuffer.wrap(Files.readAllBytes(paths.get(0)));
332332
} else {
333-
ModCandidate parent = getBestSourcingParent();
333+
ModCandidateImpl parent = getBestSourcingParent();
334334

335335
if (parent.paths != null) {
336336
if (parent.paths.size() != 1) throw new UnsupportedOperationException("multiple parent paths for "+this);
@@ -365,12 +365,12 @@ private ByteBuffer getData() throws IOException {
365365
return ret;
366366
}
367367

368-
private ModCandidate getBestSourcingParent() {
368+
private ModCandidateImpl getBestSourcingParent() {
369369
if (parentMods.isEmpty()) return null;
370370

371-
ModCandidate ret = null;
371+
ModCandidateImpl ret = null;
372372

373-
for (ModCandidate parent : parentMods) {
373+
for (ModCandidateImpl parent : parentMods) {
374374
if (parent.minNestLevel >= minNestLevel) continue;
375375

376376
if (parent.paths != null && parent.paths.size() == 1

0 commit comments

Comments
 (0)