Skip to content

Commit 69b4c97

Browse files
committed
introduce scoped registry holder using PhaseTracker
1 parent cb15506 commit 69b4c97

28 files changed

+37
-27
lines changed

src/main/java/org/spongepowered/api/adventure/ChatTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ public static Registry<ChatType> registry() {
9898
}
9999

100100
public static DefaultedRegistryReference<ChatType> key(final ResourceKey location) {
101-
return RegistryKey.of(RegistryTypes.CHAT_TYPE, location).asDefaultedReference(Sponge::server);
101+
return RegistryKey.of(RegistryTypes.CHAT_TYPE, location).asScopedReference();
102102
}
103103
}

src/main/java/org/spongepowered/api/command/registrar/tree/CommandTreeNodeTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,6 @@ public static Registry<CommandTreeNodeType<?>> registry() {
138138
}
139139

140140
private static <T extends CommandTreeNode<T>> DefaultedRegistryReference<CommandTreeNodeType<T>> key(final ResourceKey location) {
141-
return RegistryKey.of(RegistryTypes.COMMAND_TREE_NODE_TYPE, location).asDefaultedReference(Sponge::server);
141+
return RegistryKey.of(RegistryTypes.COMMAND_TREE_NODE_TYPE, location).asScopedReference();
142142
}
143143
}

src/main/java/org/spongepowered/api/data/type/ArtTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,6 @@ public static Registry<ArtType> registry() {
148148
}
149149

150150
private static DefaultedRegistryReference<ArtType> key(final ResourceKey location) {
151-
return RegistryKey.of(RegistryTypes.ART_TYPE, location).asDefaultedReference(Sponge::server);
151+
return RegistryKey.of(RegistryTypes.ART_TYPE, location).asScopedReference();
152152
}
153153
}

src/main/java/org/spongepowered/api/data/type/BannerPatternShapes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,6 @@ public static Registry<BannerPatternShape> registry() {
134134
}
135135

136136
private static DefaultedRegistryReference<BannerPatternShape> key(final ResourceKey location) {
137-
return RegistryKey.of(RegistryTypes.BANNER_PATTERN_SHAPE, location).asDefaultedReference(Sponge::server);
137+
return RegistryKey.of(RegistryTypes.BANNER_PATTERN_SHAPE, location).asScopedReference();
138138
}
139139
}

src/main/java/org/spongepowered/api/effect/sound/music/MusicDiscs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@ public static Registry<MusicDisc> registry() {
8686
}
8787

8888
private static DefaultedRegistryReference<MusicDisc> key(final ResourceKey location) {
89-
return RegistryKey.of(RegistryTypes.MUSIC_DISC, location).asDefaultedReference(Sponge::server);
89+
return RegistryKey.of(RegistryTypes.MUSIC_DISC, location).asScopedReference();
9090
}
9191
}

src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,6 @@ public static Registry<DamageType> registry() {
146146
}
147147

148148
private static DefaultedRegistryReference<DamageType> key(final ResourceKey location) {
149-
return RegistryKey.of(RegistryTypes.DAMAGE_TYPE, location).asDefaultedReference(Sponge::server);
149+
return RegistryKey.of(RegistryTypes.DAMAGE_TYPE, location).asScopedReference();
150150
}
151151
}

src/main/java/org/spongepowered/api/item/enchantment/EnchantmentTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,6 @@ public static Registry<EnchantmentType> registry() {
284284
}
285285

286286
private static DefaultedRegistryReference<EnchantmentType> key(final ResourceKey location) {
287-
return RegistryKey.of(RegistryTypes.ENCHANTMENT_TYPE, location).asDefaultedReference(Sponge::server);
287+
return RegistryKey.of(RegistryTypes.ENCHANTMENT_TYPE, location).asScopedReference();
288288
}
289289
}

src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterials.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ public static Registry<TrimMaterial> registry() {
6767
}
6868

6969
private static DefaultedRegistryReference<TrimMaterial> key(final ResourceKey location) {
70-
return RegistryKey.of(RegistryTypes.TRIM_MATERIAL, location).asDefaultedReference(Sponge::server);
70+
return RegistryKey.of(RegistryTypes.TRIM_MATERIAL, location).asScopedReference();
7171
}
7272
}

src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPatterns.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ public static Registry<TrimPattern> registry() {
8181
}
8282

8383
private static DefaultedRegistryReference<TrimPattern> key(final ResourceKey location) {
84-
return RegistryKey.of(RegistryTypes.TRIM_PATTERN, location).asDefaultedReference(Sponge::server);
84+
return RegistryKey.of(RegistryTypes.TRIM_PATTERN, location).asScopedReference();
8585
}
8686
}

src/main/java/org/spongepowered/api/registry/RegistryKey.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ static <T> RegistryKey<T> of(final RegistryType<T> registry, final ResourceKey l
7373
*/
7474
<V extends T> DefaultedRegistryReference<V> asDefaultedReference(final Supplier<RegistryHolder> defaultHolder);
7575

76+
/**
77+
* Generates a utility {@link DefaultedRegistryReference reference} used to assist in querying a value from this key.
78+
* This uses the current Cause to determine the {@link RegistryHolder}
79+
*
80+
* @return The reference
81+
*/
82+
<V extends T> DefaultedRegistryReference<V> asScopedReference();
83+
7684
interface Factory {
7785

7886
<T> RegistryKey<T> of(RegistryType<T> registry, ResourceKey location);

0 commit comments

Comments
 (0)