Skip to content

Commit f24b4c0

Browse files
committed
Merge branch 'api-14' into api-15
2 parents e6dbf7a + 090e9f4 commit f24b4c0

File tree

19 files changed

+231
-40
lines changed

19 files changed

+231
-40
lines changed

bootstrap/src/main/java/org/spongepowered/bootstrap/dev/DevClasspath.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public static List<Path[]> resolve() {
4949
final Set<String> gameShadedNames = Set.of(System.getProperty("sponge.dev.gameShaded").split(File.pathSeparator));
5050

5151
// boot layer
52-
final Multimap<String, Path> bootUnions = new Multimap<>();
52+
final Multimap<String, WeightedPath> bootUnions = new Multimap<>();
5353
final List<Path> bootLibs = new ArrayList<>();
5454

5555
// game or plugin layer
56-
final Multimap<String, Path> unions = new Multimap<>();
56+
final Multimap<String, WeightedPath> unions = new Multimap<>();
5757
final List<Path> libs = new ArrayList<>();
5858

5959
final AtomicBoolean hasAPISourceSet = new AtomicBoolean(false);
@@ -80,7 +80,7 @@ public static List<Path[]> resolve() {
8080
// ignore
8181
break;
8282
case "modlauncher-transformers", "library-manager":
83-
bootUnions.add(projectName, path);
83+
bootUnions.add(projectName, new WeightedPath(0, path));
8484
break;
8585
case "SpongeAPI":
8686
switch (sourceSet.name()) {
@@ -91,34 +91,35 @@ public static List<Path[]> resolve() {
9191
hasAPISourceSet.set(true);
9292
// no break
9393
default:
94-
unions.add("sponge", path);
94+
unions.add("sponge", new WeightedPath(0, path));
9595
break;
9696
}
9797
break;
9898
case "", "vanilla", "forge", "neoforge":
99+
final WeightedPath weightedPath = new WeightedPath(projectName.isEmpty() ? 1 : 2, path);
99100
switch (sourceSet.name()) {
100101
case "applaunchConfig":
101102
case "applaunch":
102-
bootUnions.add("applaunch", path);
103+
bootUnions.add("applaunch", weightedPath);
103104
break;
104105
case "lang":
105-
unions.add("lang", path);
106+
unions.add("lang", weightedPath);
106107
break;
107108
default:
108-
unions.add("sponge", path);
109+
unions.add("sponge", weightedPath);
109110
break;
110111
}
111112
break;
112113
default:
113-
unions.add(projectName, path);
114+
unions.add(projectName, new WeightedPath(0, path));
114115
break;
115116
}
116117
} else {
117118
if (Bootstrap.DEBUG) {
118119
System.out.println("External SourceSet (" + sourceSet + "): " + path);
119120
}
120121

121-
unions.add(sourceSet.project().toString(), path);
122+
unions.add(sourceSet.project().toString(), new WeightedPath(0, path));
122123
}
123124
continue;
124125
}
@@ -144,7 +145,7 @@ public static List<Path[]> resolve() {
144145
if (Bootstrap.DEBUG) {
145146
System.out.println("Sponge: " + path);
146147
}
147-
unions.add("sponge", path);
148+
unions.add("sponge", new WeightedPath(0, path));
148149
continue;
149150
}
150151

@@ -160,12 +161,13 @@ public static List<Path[]> resolve() {
160161
classpath.add(new Path[] { lib });
161162
}
162163

163-
for (final List<Path> sourceSets : bootUnions.values()) {
164-
classpath.add(sourceSets.toArray(Path[]::new));
164+
for (final List<WeightedPath> sourceSets : bootUnions.values()) {
165+
classpath.add(sourceSets.stream().sorted().map(WeightedPath::path).toArray(Path[]::new));
165166
}
166167

167168
if (hasAPISourceSet.get()) {
168-
unions.get("sponge").removeIf((path) -> {
169+
unions.get("sponge").removeIf((w) -> {
170+
final Path path = w.path();
169171
if (Files.isRegularFile(path)) {
170172
final String fileName = path.getFileName().toString();
171173
if (fileName.startsWith("spongeapi") && fileName.endsWith(".jar")) {
@@ -183,10 +185,8 @@ public static List<Path[]> resolve() {
183185
for (final Path resource : libs) {
184186
resourcesEnvBuilder.append(resource).append(File.pathSeparator);
185187
}
186-
for (final List<Path> project : unions.values()) {
187-
for (final Path resource : project) {
188-
resourcesEnvBuilder.append(resource).append('&');
189-
}
188+
for (final List<WeightedPath> project : unions.values()) {
189+
project.stream().sorted().forEachOrdered(w -> resourcesEnvBuilder.append(w.path()).append('&'));
190190
resourcesEnvBuilder.setCharAt(resourcesEnvBuilder.length() - 1, File.pathSeparatorChar);
191191
}
192192
resourcesEnvBuilder.setLength(resourcesEnvBuilder.length() - 1);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of Sponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.bootstrap.dev;
26+
27+
import java.nio.file.Path;
28+
29+
public record WeightedPath(int weight, Path path) implements Comparable<WeightedPath> {
30+
@Override
31+
public int compareTo(WeightedPath o) {
32+
final int result = Integer.compare(this.weight, o.weight);
33+
if (result != 0) {
34+
return result;
35+
}
36+
return this.path.compareTo(o.path);
37+
}
38+
}

forge/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ tasks {
436436
jvmArgs("-Dsponge.test.args=" + runServer.args.joinToString(" "))
437437
jvmArgs("-Dsponge.jacoco.packages=org.spongepowered")
438438
jvmArgs("-Djunit.platform.launcher.interceptors.enabled=true")
439+
jvmArgs("-Djunit.jupiter.extensions.autodetection.enabled=true")
439440
workingDir = layout.buildDirectory.dir("test-run").get().asFile
440441

441442
doFirst {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Superclass-Transformer: common.superclasschange,forge.superclasschange

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ projectDescription=The SpongeAPI implementation targeting vanilla Minecraft and
1010
mixinConfigs=mixins.sponge.accessors.json,mixins.sponge.api.json,mixins.sponge.concurrent.json,mixins.sponge.core.json,\
1111
mixins.sponge.entityactivation.json,mixins.sponge.exploit.json,mixins.sponge.inventory.json,mixins.sponge.movementcheck.json,\
1212
mixins.sponge.tracker.json,mixins.sponge.ipforward.json,mixins.sponge.optimization.json,mixins.sponge.test.json
13-
superClassChanges=common.superclasschange
1413

1514
minecraftVersion=1.21.5
1615
recommendedVersion=0-SNAPSHOT

neoforge/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ tasks {
411411
jvmArgs("-Dsponge.test.args=" + runServer.get().args!!.joinToString(" "))
412412
jvmArgs("-Dsponge.jacoco.packages=org.spongepowered")
413413
jvmArgs("-Djunit.platform.launcher.interceptors.enabled=true")
414+
jvmArgs("-Djunit.jupiter.extensions.autodetection.enabled=true")
414415
workingDir = layout.buildDirectory.dir("test-run").get().asFile
415416

416417
doFirst {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Superclass-Transformer: common.superclasschange,neoforge.superclasschange

src/main/java/org/spongepowered/common/bridge/server/MinecraftServerBridge.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,8 @@ public interface MinecraftServerBridge {
5353
default void bridge$tickServer(int ticks) {
5454
throw new UnsupportedOperationException("Cannot trigger manual server tick outside test environment");
5555
}
56+
57+
default boolean bridge$insideTestEnvironment() {
58+
return false;
59+
}
5660
}

src/main/java/org/spongepowered/common/event/tracking/PhaseTracker.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,17 @@ public static PhaseTracker getInstance() {
111111
return PhaseTracker.CLIENT;
112112
}
113113

114-
return PhaseTracker.SPINOFF_TRACKERS.computeIfAbsent(current, (thread) -> {
115-
try {
116-
final PhaseTracker phaseTracker = new PhaseTracker();
117-
phaseTracker.setThread(thread);
118-
return phaseTracker;
119-
} catch (final IllegalAccessException e) {
120-
throw new RuntimeException("Unable to create a new PhaseTracker for Thread: " + thread, e);
121-
}
122-
});
114+
return PhaseTracker.SPINOFF_TRACKERS.computeIfAbsent(current, PhaseTracker::createNew);
115+
}
116+
117+
public static PhaseTracker createNew(final Thread thread) {
118+
try {
119+
final PhaseTracker phaseTracker = new PhaseTracker();
120+
phaseTracker.setThread(thread);
121+
return phaseTracker;
122+
} catch (final IllegalAccessException e) {
123+
throw new RuntimeException("Unable to create a new PhaseTracker for Thread: " + thread, e);
124+
}
123125
}
124126

125127
/**
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
org.spongepowered.api.event.cause.entity.damage.source.common.AbstractDamageSource:org.spongepowered.common.event.cause.entity.damage.SpongeCommonDamageSource
2-
org.spongepowered.api.event.cause.entity.damage.source.common.AbstractEntityDamageSource:org.spongepowered.common.event.cause.entity.damage.SpongeCommonEntityDamageSource
3-
org.spongepowered.api.event.cause.entity.damage.source.common.AbstractIndirectEntityDamageSource:org.spongepowered.common.event.cause.entity.damage.SpongeCommonIndirectEntityDamageSource
41
org.spongepowered.api.entity.ai.goal.AbstractGoal:net.minecraft.world.entity.ai.goal.Goal

0 commit comments

Comments
 (0)