Skip to content

Commit 6f72877

Browse files
ZidaneDaniel Naylor
authored andcommitted
[WIP] Add short-hand registry getters
For Game/Server scope, a REGISTRY field For world scope, a static util method that is passed a ServerWorld Signed-off-by: Chris Sanders <[email protected]>
1 parent 96baed5 commit 6f72877

File tree

16 files changed

+111
-0
lines changed

16 files changed

+111
-0
lines changed

src/main/java/org/spongepowered/api/block/BlockTypes.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class BlockTypes {
4142

4243
// @formatter:off
44+
public static final Registry<BlockType> REGISTRY = BlockTypes.registry();
45+
4346
public static final DefaultedRegistryReference<BlockType> ACACIA_BUTTON = BlockTypes.key(ResourceKey.minecraft("acacia_button"));
4447

4548
public static final DefaultedRegistryReference<BlockType> ACACIA_DOOR = BlockTypes.key(ResourceKey.minecraft("acacia_door"));
@@ -1570,6 +1573,10 @@ public final class BlockTypes {
15701573
private BlockTypes() {
15711574
}
15721575

1576+
private static Registry<BlockType> registry() {
1577+
return Sponge.game().registries().registry(RegistryTypes.BLOCK_TYPE);
1578+
}
1579+
15731580
private static DefaultedRegistryReference<BlockType> key(final ResourceKey location) {
15741581
return RegistryKey.of(RegistryTypes.BLOCK_TYPE, location).asDefaultedReference(Sponge::game);
15751582
}

src/main/java/org/spongepowered/api/block/entity/BlockEntityTypes.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class BlockEntityTypes {
4142

4243
// @formatter:off
44+
public static final Registry<BlockEntityType> REGISTRY = BlockEntityTypes.registry();
45+
4346
public static final DefaultedRegistryReference<BlockEntityType> BANNER = BlockEntityTypes.key(ResourceKey.minecraft("banner"));
4447

4548
public static final DefaultedRegistryReference<BlockEntityType> BARREL = BlockEntityTypes.key(ResourceKey.minecraft("barrel"));
@@ -110,6 +113,10 @@ public final class BlockEntityTypes {
110113
private BlockEntityTypes() {
111114
}
112115

116+
private static Registry<BlockEntityType> registry() {
117+
return Sponge.game().registries().registry(RegistryTypes.BLOCK_ENTITY_TYPE);
118+
}
119+
113120
private static DefaultedRegistryReference<BlockEntityType> key(final ResourceKey location) {
114121
return RegistryKey.of(RegistryTypes.BLOCK_ENTITY_TYPE, location).asDefaultedReference(Sponge::game);
115122
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class ArtTypes {
4142

4243
// @formatter:off
44+
public static final Registry<ArtType> REGISTRY = ArtTypes.registry();
45+
4346
public static final DefaultedRegistryReference<ArtType> ALBAN = ArtTypes.key(ResourceKey.minecraft("alban"));
4447

4548
public static final DefaultedRegistryReference<ArtType> AZTEC = ArtTypes.key(ResourceKey.minecraft("aztec"));
@@ -96,6 +99,10 @@ public final class ArtTypes {
9699
private ArtTypes() {
97100
}
98101

102+
private static Registry<ArtType> registry() {
103+
return Sponge.game().registries().registry(RegistryTypes.ART_TYPE);
104+
}
105+
99106
private static DefaultedRegistryReference<ArtType> key(final ResourceKey location) {
100107
return RegistryKey.of(RegistryTypes.ART_TYPE, location).asDefaultedReference(Sponge::game);
101108
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class ProfessionTypes {
4142

4243
// @formatter:off
44+
public static final Registry<ProfessionType> REGISTRY = ProfessionTypes.registry();
45+
4346
public static final DefaultedRegistryReference<ProfessionType> ARMORER = ProfessionTypes.key(ResourceKey.minecraft("armorer"));
4447

4548
public static final DefaultedRegistryReference<ProfessionType> BUTCHER = ProfessionTypes.key(ResourceKey.minecraft("butcher"));
@@ -74,6 +77,10 @@ public final class ProfessionTypes {
7477
private ProfessionTypes() {
7578
}
7679

80+
private static Registry<ProfessionType> registry() {
81+
return Sponge.game().registries().registry(RegistryTypes.PROFESSION_TYPE);
82+
}
83+
7784
private static DefaultedRegistryReference<ProfessionType> key(final ResourceKey location) {
7885
return RegistryKey.of(RegistryTypes.PROFESSION_TYPE, location).asDefaultedReference(Sponge::game);
7986
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class VillagerTypes {
4142

4243
// @formatter:off
44+
public static final Registry<VillagerType> REGISTRY = VillagerTypes.registry();
45+
4346
public static final DefaultedRegistryReference<VillagerType> DESERT = VillagerTypes.key(ResourceKey.minecraft("desert"));
4447

4548
public static final DefaultedRegistryReference<VillagerType> JUNGLE = VillagerTypes.key(ResourceKey.minecraft("jungle"));
@@ -58,6 +61,10 @@ public final class VillagerTypes {
5861
private VillagerTypes() {
5962
}
6063

64+
private static Registry<VillagerType> registry() {
65+
return Sponge.game().registries().registry(RegistryTypes.VILLAGER_TYPE);
66+
}
67+
6168
private static DefaultedRegistryReference<VillagerType> key(final ResourceKey location) {
6269
return RegistryKey.of(RegistryTypes.VILLAGER_TYPE, location).asDefaultedReference(Sponge::game);
6370
}

src/main/java/org/spongepowered/api/effect/particle/ParticleTypes.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class ParticleTypes {
4142

4243
// @formatter:off
44+
public static final Registry<ParticleType> REGISTRY = ParticleTypes.registry();
45+
4346
public static final DefaultedRegistryReference<ParticleType> AMBIENT_ENTITY_EFFECT = ParticleTypes.key(ResourceKey.minecraft("ambient_entity_effect"));
4447

4548
public static final DefaultedRegistryReference<ParticleType> ANGRY_VILLAGER = ParticleTypes.key(ResourceKey.minecraft("angry_villager"));
@@ -188,6 +191,10 @@ public final class ParticleTypes {
188191
private ParticleTypes() {
189192
}
190193

194+
private static Registry<ParticleType> registry() {
195+
return Sponge.game().registries().registry(RegistryTypes.PARTICLE_TYPE);
196+
}
197+
191198
private static DefaultedRegistryReference<ParticleType> key(final ResourceKey location) {
192199
return RegistryKey.of(RegistryTypes.PARTICLE_TYPE, location).asDefaultedReference(Sponge::game);
193200
}

src/main/java/org/spongepowered/api/effect/potion/PotionEffectTypes.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class PotionEffectTypes {
4142

4243
// @formatter:off
44+
public static final Registry<PotionEffectType> REGISTRY = PotionEffectTypes.registry();
45+
4346
public static final DefaultedRegistryReference<PotionEffectType> ABSORPTION = PotionEffectTypes.key(ResourceKey.minecraft("absorption"));
4447

4548
public static final DefaultedRegistryReference<PotionEffectType> BAD_OMEN = PotionEffectTypes.key(ResourceKey.minecraft("bad_omen"));
@@ -108,6 +111,10 @@ public final class PotionEffectTypes {
108111
private PotionEffectTypes() {
109112
}
110113

114+
private static Registry<PotionEffectType> registry() {
115+
return Sponge.game().registries().registry(RegistryTypes.POTION_EFFECT_TYPE);
116+
}
117+
111118
private static DefaultedRegistryReference<PotionEffectType> key(final ResourceKey location) {
112119
return RegistryKey.of(RegistryTypes.POTION_EFFECT_TYPE, location).asDefaultedReference(Sponge::game);
113120
}

src/main/java/org/spongepowered/api/effect/sound/SoundTypes.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class SoundTypes {
4142

4243
// @formatter:off
44+
public static final Registry<SoundType> REGISTRY = SoundTypes.registry();
45+
4346
public static final DefaultedRegistryReference<SoundType> AMBIENT_BASALT_DELTAS_ADDITIONS = SoundTypes.key(ResourceKey.minecraft("ambient.basalt_deltas.additions"));
4447

4548
public static final DefaultedRegistryReference<SoundType> AMBIENT_BASALT_DELTAS_LOOP = SoundTypes.key(ResourceKey.minecraft("ambient.basalt_deltas.loop"));
@@ -2028,6 +2031,10 @@ public final class SoundTypes {
20282031
private SoundTypes() {
20292032
}
20302033

2034+
private static Registry<SoundType> registry() {
2035+
return Sponge.game().registries().registry(RegistryTypes.SOUND_TYPE);
2036+
}
2037+
20312038
private static DefaultedRegistryReference<SoundType> key(final ResourceKey location) {
20322039
return RegistryKey.of(RegistryTypes.SOUND_TYPE, location).asDefaultedReference(Sponge::game);
20332040
}

src/main/java/org/spongepowered/api/entity/attribute/type/AttributeTypes.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class AttributeTypes {
4142

4243
// @formatter:off
44+
public static final Registry<RangedAttributeType> REGISTRY = AttributeTypes.registry();
45+
4346
public static final DefaultedRegistryReference<RangedAttributeType> GENERIC_ARMOR = AttributeTypes.key(ResourceKey.minecraft("generic.armor"));
4447

4548
public static final DefaultedRegistryReference<RangedAttributeType> GENERIC_ARMOR_TOUGHNESS = AttributeTypes.key(ResourceKey.minecraft("generic.armor_toughness"));
@@ -70,6 +73,10 @@ public final class AttributeTypes {
7073
private AttributeTypes() {
7174
}
7275

76+
private static Registry<RangedAttributeType> registry() {
77+
return Sponge.game().registries().registry(RegistryTypes.ATTRIBUTE_TYPE);
78+
}
79+
7380
private static DefaultedRegistryReference<RangedAttributeType> key(final ResourceKey location) {
7481
return RegistryKey.of(RegistryTypes.ATTRIBUTE_TYPE, location).asDefaultedReference(Sponge::game);
7582
}

src/main/java/org/spongepowered/api/fluid/FluidTypes.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.spongepowered.api.ResourceKey;
2828
import org.spongepowered.api.Sponge;
2929
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
3031
import org.spongepowered.api.registry.RegistryKey;
3132
import org.spongepowered.api.registry.RegistryScope;
3233
import org.spongepowered.api.registry.RegistryScopes;
@@ -40,6 +41,8 @@
4041
public final class FluidTypes {
4142

4243
// @formatter:off
44+
public static final Registry<FluidType> REGISTRY = FluidTypes.registry();
45+
4346
public static final DefaultedRegistryReference<FluidType> EMPTY = FluidTypes.key(ResourceKey.minecraft("empty"));
4447

4548
public static final DefaultedRegistryReference<FluidType> FLOWING_LAVA = FluidTypes.key(ResourceKey.minecraft("flowing_lava"));
@@ -54,6 +57,10 @@ public final class FluidTypes {
5457
private FluidTypes() {
5558
}
5659

60+
private static Registry<FluidType> registry() {
61+
return Sponge.game().registries().registry(RegistryTypes.FLUID_TYPE);
62+
}
63+
5764
private static DefaultedRegistryReference<FluidType> key(final ResourceKey location) {
5865
return RegistryKey.of(RegistryTypes.FLUID_TYPE, location).asDefaultedReference(Sponge::game);
5966
}

0 commit comments

Comments
 (0)