diff options
author | Jake Potrebic <[email protected]> | 2024-06-15 12:04:06 -0700 |
---|---|---|
committer | Jake Potrebic <[email protected]> | 2024-06-15 12:04:06 -0700 |
commit | c1aefeecc6fef3fd53bbc6e0501a75b7d78189ee (patch) | |
tree | e858921f326fa65565e3114f8cb9a8e057407030 | |
parent | 56b5b7d452e8173ee005c941010632aeb6dbecaf (diff) | |
download | Paper-c1aefeecc6fef3fd53bbc6e0501a75b7d78189ee.tar.gz Paper-c1aefeecc6fef3fd53bbc6e0501a75b7d78189ee.zip |
correctly change enchantment registry to a 'delayed' version
5 files changed, 31 insertions, 25 deletions
diff --git a/patches/api/0004-Code-Generation.patch b/patches/api/0004-Code-Generation.patch index 5beaa783a2..db8cb5a43c 100644 --- a/patches/api/0004-Code-Generation.patch +++ b/patches/api/0004-Code-Generation.patch @@ -85,10 +85,10 @@ index 0000000000000000000000000000000000000000..2512dba27edfdccbc4430815b6cba048 +} diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java new file mode 100644 -index 0000000000000000000000000000000000000000..adf24eb062460e2fd08d3e91337eba379d76a27d +index 0000000000000000000000000000000000000000..76daccf4ea502e1747a6f9176dc16fd20c561286 --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java -@@ -0,0 +1,146 @@ +@@ -0,0 +1,147 @@ +package io.papermc.paper.registry; + +import net.kyori.adventure.key.Keyed; @@ -157,11 +157,6 @@ index 0000000000000000000000000000000000000000..adf24eb062460e2fd08d3e91337eba37 + */ + RegistryKey<MusicInstrument> INSTRUMENT = create("instrument"); + /** -+ * Built-in registry for enchantments. -+ * @see io.papermc.paper.registry.keys.EnchantmentKeys -+ */ -+ RegistryKey<Enchantment> ENCHANTMENT = create("enchantment"); -+ /** + * Built-in registry for potion effect types (mob effects). + * @see io.papermc.paper.registry.keys.MobEffectKeys + */ @@ -212,8 +207,14 @@ index 0000000000000000000000000000000000000000..adf24eb062460e2fd08d3e91337eba37 + */ + RegistryKey<Wolf.Variant> WOLF_VARIANT = create("wolf_variant"); + /** ++ * Data-driven registry for enchantments. ++ * @see io.papermc.paper.registry.keys.EnchantmentKeys ++ */ ++ RegistryKey<Enchantment> ENCHANTMENT = create("enchantment"); ++ /** + * Data-driven registry for jukebox songs. + */ ++ @ApiStatus.Experimental + RegistryKey<JukeboxSong> JUKEBOX_SONG = create("jukebox_song"); + + diff --git a/patches/api/0236-Add-RegistryAccess-for-managing-registries.patch b/patches/api/0236-Add-RegistryAccess-for-managing-registries.patch index 9740622000..841078a110 100644 --- a/patches/api/0236-Add-RegistryAccess-for-managing-registries.patch +++ b/patches/api/0236-Add-RegistryAccess-for-managing-registries.patch @@ -206,7 +206,7 @@ index 188280a8fdf35a70a5a358f8cfe7cf44f05855b1..ceaa901fa830e904d6ac7a1727d1e7d1 return server.getRegistry(tClass); } diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java -index 3effaea369d9c7a6a22979fbfc270f55f9f25cf2..d40c2b492a2be6ce87105ce910a05c7c344ddf84 100644 +index 3effaea369d9c7a6a22979fbfc270f55f9f25cf2..93e898c14728491a59bb2d08aff0dd678feef26a 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java @@ -102,7 +102,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { @@ -218,16 +218,19 @@ index 3effaea369d9c7a6a22979fbfc270f55f9f25cf2..d40c2b492a2be6ce87105ce910a05c7c /** * Custom boss bars. * -@@ -140,7 +140,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -139,8 +139,10 @@ public interface Registry<T extends Keyed> extends Iterable<T> { + * Server enchantments. * * @see Enchantment ++ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#ENCHANTMENT} */ - Registry<Enchantment> ENCHANTMENT = Objects.requireNonNull(Bukkit.getRegistry(Enchantment.class), "No registry present for Enchantment. This is a bug."); -+ Registry<Enchantment> ENCHANTMENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.ENCHANTMENT); // Paper ++ @Deprecated(since = "1.21") ++ Registry<Enchantment> ENCHANTMENT = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Enchantment.class), "No registry present for Enchantment. This is a bug."); // Paper /** * Server entity types. * -@@ -152,7 +152,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -152,7 +154,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { * * @see MusicInstrument */ @@ -236,7 +239,7 @@ index 3effaea369d9c7a6a22979fbfc270f55f9f25cf2..d40c2b492a2be6ce87105ce910a05c7c /** * Server item types. * -@@ -160,7 +160,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -160,7 +162,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { * @apiNote ItemType is not ready for public usage yet */ @ApiStatus.Internal @@ -245,7 +248,7 @@ index 3effaea369d9c7a6a22979fbfc270f55f9f25cf2..d40c2b492a2be6ce87105ce910a05c7c /** * Default server loot tables. * -@@ -178,7 +178,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -178,7 +180,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { * * @see PotionEffectType */ @@ -254,7 +257,7 @@ index 3effaea369d9c7a6a22979fbfc270f55f9f25cf2..d40c2b492a2be6ce87105ce910a05c7c /** * Server particles. * -@@ -201,14 +201,16 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -201,14 +203,16 @@ public interface Registry<T extends Keyed> extends Iterable<T> { * Server structures. * * @see Structure @@ -273,7 +276,7 @@ index 3effaea369d9c7a6a22979fbfc270f55f9f25cf2..d40c2b492a2be6ce87105ce910a05c7c /** * Sound keys. * -@@ -219,28 +221,33 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -219,28 +223,35 @@ public interface Registry<T extends Keyed> extends Iterable<T> { * Trim materials. * * @see TrimMaterial @@ -305,14 +308,16 @@ index 3effaea369d9c7a6a22979fbfc270f55f9f25cf2..d40c2b492a2be6ce87105ce910a05c7c * Jukebox songs. * * @see JukeboxSong ++ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#JUKEBOX_SONG} */ @ApiStatus.Experimental - Registry<JukeboxSong> JUKEBOX_SONG = Objects.requireNonNull(Bukkit.getRegistry(JukeboxSong.class), "No registry present for JukeboxSong. This is a bug."); -+ Registry<JukeboxSong> JUKEBOX_SONG = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.JUKEBOX_SONG); // Paper ++ @Deprecated(since = "1.21") ++ Registry<JukeboxSong> JUKEBOX_SONG = Objects.requireNonNull(io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(JukeboxSong.class), "No registry present for JukeboxSong. This is a bug."); // Paper /** * Villager profession. * -@@ -294,8 +301,10 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -294,8 +305,10 @@ public interface Registry<T extends Keyed> extends Iterable<T> { * Wolf variants. * * @see Wolf.Variant @@ -324,7 +329,7 @@ index 3effaea369d9c7a6a22979fbfc270f55f9f25cf2..d40c2b492a2be6ce87105ce910a05c7c /** * Map cursor types. * -@@ -308,7 +317,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -308,7 +321,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> { * * @see GameEvent */ diff --git a/patches/api/0329-More-PotionEffectType-API.patch b/patches/api/0329-More-PotionEffectType-API.patch index 9c8d856b06..7a43cc36d6 100644 --- a/patches/api/0329-More-PotionEffectType-API.patch +++ b/patches/api/0329-More-PotionEffectType-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] More PotionEffectType API diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java -index d40c2b492a2be6ce87105ce910a05c7c344ddf84..5ba5cf06bf12fc2e81500e09209e26047e683fa9 100644 +index 93e898c14728491a59bb2d08aff0dd678feef26a..17714f04fdd87ed4332ea62bcfab7063560bf1be 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java -@@ -318,6 +318,33 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -322,6 +322,33 @@ public interface Registry<T extends Keyed> extends Iterable<T> { * @see GameEvent */ Registry<GameEvent> GAME_EVENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.GAME_EVENT); // Paper diff --git a/patches/api/0434-Improve-Registry.patch b/patches/api/0434-Improve-Registry.patch index 1d2d6fa13c..8a49d39633 100644 --- a/patches/api/0434-Improve-Registry.patch +++ b/patches/api/0434-Improve-Registry.patch @@ -31,10 +31,10 @@ index 62d2b3f950860dee0898d77b0a29635c3f9a7e23..704dba92f9246ef398ed8d162ebee3cf @Override public @NotNull String translationKey() { diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java -index 5ba5cf06bf12fc2e81500e09209e26047e683fa9..802511eaf697d703cadb4b418fe51ea6d31ff3c8 100644 +index 17714f04fdd87ed4332ea62bcfab7063560bf1be..bc7144f02ac6857dbeec13c3995b71f6920e022a 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java -@@ -354,6 +354,49 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -358,6 +358,49 @@ public interface Registry<T extends Keyed> extends Iterable<T> { @Nullable T get(@NotNull NamespacedKey key); @@ -84,7 +84,7 @@ index 5ba5cf06bf12fc2e81500e09209e26047e683fa9..802511eaf697d703cadb4b418fe51ea6 /** * Returns a new stream, which contains all registry items, which are registered to the registry. * -@@ -428,5 +471,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> { +@@ -432,5 +475,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> { public Class<T> getType() { return this.type; } diff --git a/patches/server/0475-Add-RegistryAccess-for-managing-Registries.patch b/patches/server/0475-Add-RegistryAccess-for-managing-Registries.patch index e99ffb23f3..6ddf9741cc 100644 --- a/patches/server/0475-Add-RegistryAccess-for-managing-Registries.patch +++ b/patches/server/0475-Add-RegistryAccess-for-managing-Registries.patch @@ -12,7 +12,7 @@ public net.minecraft.server.RegistryLayer STATIC_ACCESS diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java new file mode 100644 -index 0000000000000000000000000000000000000000..55feffc03d2924e5ec0f55fc65e8aa148cb0cc62 +index 0000000000000000000000000000000000000000..c1ee87876af79d0fcacd7b930d17d110464ac9d1 --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java @@ -0,0 +1,122 @@ @@ -72,7 +72,6 @@ index 0000000000000000000000000000000000000000..55feffc03d2924e5ec0f55fc65e8aa14 + static { + REGISTRY_ENTRIES = List.of( + // built-ins -+ entry(Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, Enchantment.class, CraftEnchantment::new).withSerializationUpdater(FieldRename.ENCHANTMENT_RENAME), + entry(Registries.GAME_EVENT, RegistryKey.GAME_EVENT, GameEvent.class, CraftGameEvent::new), + entry(Registries.INSTRUMENT, RegistryKey.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument::new), + entry(Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType::new), @@ -86,6 +85,7 @@ index 0000000000000000000000000000000000000000..55feffc03d2924e5ec0f55fc65e8aa14 + entry(Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, TrimPattern.class, CraftTrimPattern::new).delayed(), + entry(Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, DamageType.class, CraftDamageType::new).delayed(), + entry(Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, Wolf.Variant.class, CraftWolf.CraftVariant::new).delayed(), ++ entry(Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, Enchantment.class, CraftEnchantment::new).withSerializationUpdater(FieldRename.ENCHANTMENT_RENAME).delayed(), + entry(Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, JukeboxSong.class, CraftJukeboxSong::new).delayed(), + + // api-only |