Skip to content

Commit b911bb4

Browse files
committed
1.21.11
1 parent c6ad1fb commit b911bb4

File tree

101 files changed

+731
-580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+731
-580
lines changed

build.gradle.kts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.eclipse.jgit.api.Git
88
plugins {
99
java
1010
`maven-publish`
11-
id("band.kessoku.koom") // Version declared in buildSrc
11+
id("dev.architectury.loom") // Version declared in buildSrc
1212
id("me.modmuss50.mod-publish-plugin") version "0.5.+"
1313
}
1414

@@ -71,7 +71,7 @@ allprojects {
7171
}
7272

7373
apply(plugin = "java-library")
74-
apply(plugin = "band.kessoku.koom")
74+
apply(plugin = "dev.architectury.loom")
7575

7676
loom.silentMojangMappingsLicense()
7777

@@ -104,11 +104,7 @@ allprojects {
104104
dependencies {
105105
minecraft(group = "com.mojang", name = "minecraft", version = versionMc)
106106
neoForge(group = "net.neoforged", name = "neoforge", version = versionForge)
107-
mappings(loom.layered {
108-
officialMojangMappings {
109-
nameSyntheticMembers = true
110-
}
111-
})
107+
mappings(loom.officialMojangMappings())
112108
}
113109

114110
// Run this task after updating minecraft to regenerate any required resources

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ repositories {
3232
}
3333

3434
dependencies {
35-
implementation("band.kessoku:koom:1.13-SNAPSHOT")
35+
implementation("dev.architectury:architectury-loom:1.13-SNAPSHOT")
3636

3737
implementation("net.fabricmc:fabric-loader:0.16.9")
3838

fabric-api-base/src/main/java/net/fabricmc/fabric/api/event/Event.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
package net.fabricmc.fabric.api.event;
1818

19-
import net.minecraft.resources.ResourceLocation;
2019
import org.jetbrains.annotations.ApiStatus;
2120

21+
import net.minecraft.resources.Identifier;
22+
2223
/**
2324
* Base class for Fabric's event implementations.
2425
*
@@ -59,7 +60,7 @@ public final T invoker() {
5960
* The identifier of the default phase.
6061
* Have a look at {@link EventFactory#createWithPhases} for an explanation of event phases.
6162
*/
62-
public static final ResourceLocation DEFAULT_PHASE = ResourceLocation.fromNamespaceAndPath("fabric", "default");
63+
public static final Identifier DEFAULT_PHASE = Identifier.fromNamespaceAndPath("fabric", "default");
6364

6465
/**
6566
* Register a listener to the event for the specified phase.
@@ -68,7 +69,7 @@ public final T invoker() {
6869
* @param phase Identifier of the phase this listener should be registered for. It will be created if it didn't exist yet.
6970
* @param listener The desired listener.
7071
*/
71-
public void register(ResourceLocation phase, T listener) {
72+
public void register(Identifier phase, T listener) {
7273
// This is done to keep compatibility with existing Event subclasses, but they should really not be subclassing Event.
7374
register(listener);
7475
}
@@ -84,7 +85,7 @@ public void register(ResourceLocation phase, T listener) {
8485
* @param firstPhase The identifier of the phase that should run before the other. It will be created if it didn't exist yet.
8586
* @param secondPhase The identifier of the phase that should run after the other. It will be created if it didn't exist yet.
8687
*/
87-
public void addPhaseOrdering(ResourceLocation firstPhase, ResourceLocation secondPhase) {
88+
public void addPhaseOrdering(Identifier firstPhase, Identifier secondPhase) {
8889
// This is not abstract to avoid breaking existing Event subclasses, but they should really not be subclassing Event.
8990
}
9091
}

fabric-api-base/src/main/java/net/fabricmc/fabric/api/event/EventFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
package net.fabricmc.fabric.api.event;
1818

1919
import java.util.function.Function;
20+
21+
import net.minecraft.resources.Identifier;
22+
2023
import net.fabricmc.fabric.impl.base.event.EventFactoryImpl;
21-
import net.minecraft.resources.ResourceLocation;
2224

2325
/**
2426
* Helper for creating {@link Event} classes.
@@ -94,7 +96,7 @@ public static <T> Event<T> createArrayBacked(Class<T> type, T emptyInvoker, Func
9496
* @param <T> The listener type.
9597
* @return The Event instance.
9698
*/
97-
public static <T> Event<T> createWithPhases(Class<? super T> type, Function<T[], T> invokerFactory, ResourceLocation... defaultPhases) {
99+
public static <T> Event<T> createWithPhases(Class<? super T> type, Function<T[], T> invokerFactory, Identifier... defaultPhases) {
98100
EventFactoryImpl.ensureContainsDefault(defaultPhases);
99101
EventFactoryImpl.ensureNoDuplicates(defaultPhases);
100102

fabric-api-base/src/main/java/net/fabricmc/fabric/api/util/NbtType.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616

1717
package net.fabricmc.fabric.api.util;
1818

19-
import net.minecraft.nbt.CompoundTag;
2019
import net.minecraft.nbt.Tag;
2120

2221
/**
2322
* NBT type ID constants. Useful for filtering by value type in a few cases.
2423
*
2524
* <p>For the current list of types, check with {@link Tag}.
2625
*
27-
* @see CompoundTag#contains(String, int)
2826
* @see net.minecraft.nbt.TagTypes#getType(int)
2927
* @deprecated Use the constants in {@link Tag} instead.
3028
*/
@@ -44,12 +42,5 @@ public final class NbtType {
4442
public static final int INT_ARRAY = 11;
4543
public static final int LONG_ARRAY = 12;
4644

47-
/**
48-
* Any numeric value: byte, short, int, long, float, double.
49-
*
50-
* @see CompoundTag#contains(String, int)
51-
*/
52-
public static final int NUMBER = 99;
53-
5445
private NbtType() { }
5546
}

fabric-api-base/src/main/java/net/fabricmc/fabric/api/util/TriState.java

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,31 @@
2121
import java.util.function.BooleanSupplier;
2222
import java.util.function.Supplier;
2323

24-
import org.jetbrains.annotations.Nullable;
24+
import com.mojang.serialization.Codec;
25+
import org.jspecify.annotations.Nullable;
26+
27+
import net.minecraft.util.StringRepresentable;
2528

2629
/**
2730
* Represents a boolean value which can be true, false or refer to a default value.
2831
*/
29-
public enum TriState {
32+
public enum TriState implements StringRepresentable {
3033
/**
3134
* Represents the boolean value of {@code false}.
3235
*/
33-
FALSE,
36+
FALSE("false"),
3437
/**
3538
* Represents a value that refers to a "default" value, often as a fallback.
3639
*/
37-
DEFAULT,
40+
DEFAULT("default"),
3841
/**
3942
* Represents the boolean value of {@code true}.
4043
*/
41-
TRUE;
44+
TRUE("true");
45+
46+
public static final Codec<TriState> CODEC = StringRepresentable.fromEnum(TriState::values);
47+
48+
private final String name;
4249

4350
/**
4451
* Gets the corresponding tri-state from a boolean value.
@@ -136,4 +143,33 @@ public <X extends Throwable> boolean orElseThrow(Supplier<X> exceptionSupplier)
136143

137144
throw exceptionSupplier.get();
138145
}
146+
147+
/**
148+
* {@return a parsed TriState from a system property}
149+
*
150+
* @param property the system property
151+
*/
152+
public static TriState fromSystemProperty(String property) {
153+
String value = System.getProperty(property);
154+
155+
if (value != null) {
156+
return Boolean.parseBoolean(value) ? TRUE : FALSE;
157+
}
158+
159+
return DEFAULT;
160+
}
161+
162+
/**
163+
* Value of this enum as string.
164+
*
165+
* @return lowercase name of the value.
166+
*/
167+
@Override
168+
public String getSerializedName() {
169+
return this.name;
170+
}
171+
172+
TriState(String name) {
173+
this.name = name;
174+
}
139175
}

fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/event/ArrayBackedEvent.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
import java.util.Map;
2525
import java.util.Objects;
2626
import java.util.function.Function;
27+
28+
import net.minecraft.resources.Identifier;
29+
2730
import net.fabricmc.fabric.api.event.Event;
2831
import net.fabricmc.fabric.impl.base.toposort.NodeSorting;
29-
import net.minecraft.resources.ResourceLocation;
3032

3133
class ArrayBackedEvent<T> extends Event<T> {
3234
private final Function<T[], T> invokerFactory;
@@ -35,7 +37,7 @@ class ArrayBackedEvent<T> extends Event<T> {
3537
/**
3638
* Registered event phases.
3739
*/
38-
private final Map<ResourceLocation, EventPhaseData<T>> phases = new LinkedHashMap<>();
40+
private final Map<Identifier, EventPhaseData<T>> phases = new LinkedHashMap<>();
3941
/**
4042
* Phases sorted in the correct dependency order.
4143
*/
@@ -58,7 +60,7 @@ public void register(T listener) {
5860
}
5961

6062
@Override
61-
public void register(ResourceLocation phaseIdentifier, T listener) {
63+
public void register(Identifier phaseIdentifier, T listener) {
6264
Objects.requireNonNull(phaseIdentifier, "Tried to register a listener for a null phase!");
6365
Objects.requireNonNull(listener, "Tried to register a null listener!");
6466

@@ -68,7 +70,7 @@ public void register(ResourceLocation phaseIdentifier, T listener) {
6870
}
6971
}
7072

71-
private EventPhaseData<T> getOrCreatePhase(ResourceLocation id, boolean sortIfCreate) {
73+
private EventPhaseData<T> getOrCreatePhase(Identifier id, boolean sortIfCreate) {
7274
EventPhaseData<T> phase = phases.get(id);
7375

7476
if (phase == null) {
@@ -108,7 +110,7 @@ private void rebuildInvoker(int newLength) {
108110
}
109111

110112
@Override
111-
public void addPhaseOrdering(ResourceLocation firstPhase, ResourceLocation secondPhase) {
113+
public void addPhaseOrdering(Identifier firstPhase, Identifier secondPhase) {
112114
Objects.requireNonNull(firstPhase, "Tried to add an ordering for a null phase.");
113115
Objects.requireNonNull(secondPhase, "Tried to add an ordering for a null phase.");
114116
if (firstPhase.equals(secondPhase)) throw new IllegalArgumentException("Tried to add a phase that depends on itself.");

fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/event/EventFactoryImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
import java.util.function.Function;
2929

3030
import com.google.common.collect.MapMaker;
31+
32+
import net.minecraft.resources.Identifier;
33+
3134
import net.fabricmc.fabric.api.event.Event;
32-
import net.minecraft.resources.ResourceLocation;
3335

3436
public final class EventFactoryImpl {
3537
private static final Set<ArrayBackedEvent<?>> ARRAY_BACKED_EVENTS
@@ -47,8 +49,8 @@ public static <T> Event<T> createArrayBacked(Class<? super T> type, Function<T[]
4749
return event;
4850
}
4951

50-
public static void ensureContainsDefault(ResourceLocation[] defaultPhases) {
51-
for (ResourceLocation id : defaultPhases) {
52+
public static void ensureContainsDefault(Identifier[] defaultPhases) {
53+
for (Identifier id : defaultPhases) {
5254
if (id.equals(Event.DEFAULT_PHASE)) {
5355
return;
5456
}
@@ -57,7 +59,7 @@ public static void ensureContainsDefault(ResourceLocation[] defaultPhases) {
5759
throw new IllegalArgumentException("The event phases must contain Event.DEFAULT_PHASE.");
5860
}
5961

60-
public static void ensureNoDuplicates(ResourceLocation[] defaultPhases) {
62+
public static void ensureNoDuplicates(Identifier[] defaultPhases) {
6163
for (int i = 0; i < defaultPhases.length; ++i) {
6264
for (int j = i+1; j < defaultPhases.length; ++j) {
6365
if (defaultPhases[i].equals(defaultPhases[j])) {

fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/event/EventPhaseData.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@
1818

1919
import java.lang.reflect.Array;
2020
import java.util.Arrays;
21+
22+
import net.minecraft.resources.Identifier;
23+
2124
import net.fabricmc.fabric.impl.base.toposort.SortableNode;
22-
import net.minecraft.resources.ResourceLocation;
2325

2426
/**
2527
* Data of an {@link ArrayBackedEvent} phase.
2628
*/
2729
class EventPhaseData<T> extends SortableNode<EventPhaseData<T>> {
28-
final ResourceLocation id;
30+
final Identifier id;
2931
T[] listeners;
3032

3133
@SuppressWarnings("unchecked")
32-
EventPhaseData(ResourceLocation id, Class<?> listenerClass) {
34+
EventPhaseData(Identifier id, Class<?> listenerClass) {
3335
this.id = id;
3436
this.listeners = (T[]) Array.newInstance(listenerClass, 0);
3537
}

fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/toposort/SortableNode.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,29 @@
2020
import java.util.List;
2121

2222
public abstract class SortableNode<N extends SortableNode<N>> {
23-
final List<N> subsequentNodes = new ArrayList<>();
24-
final List<N> previousNodes = new ArrayList<>();
23+
protected final List<N> subsequentNodes = new ArrayList<>();
24+
protected final List<N> previousNodes = new ArrayList<>();
2525
boolean visited = false;
2626

2727
/**
2828
* @return Description of this node, used to print the cycle warning.
2929
*/
3030
protected abstract String getDescription();
3131

32+
protected void addSubsequentNode(N node) {
33+
this.subsequentNodes.add(node);
34+
}
35+
36+
protected void addPreviousNode(N node) {
37+
this.previousNodes.add(node);
38+
}
39+
3240
public static <N extends SortableNode<N>> void link(N first, N second) {
3341
if (first == second) {
3442
throw new IllegalArgumentException("Cannot link a node to itself!");
3543
}
3644

37-
first.subsequentNodes.add(second);
38-
second.previousNodes.add(first);
45+
first.addSubsequentNode(second);
46+
second.addPreviousNode(first);
3947
}
4048
}

0 commit comments

Comments
 (0)