From 42b9aeb28fbaebd7271fae243949043d28de508a Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 3 May 2024 13:36:48 -0700 Subject: [PATCH] add missing types to key data generator --- .../paper/registry/keys/DamageTypeKeys.java | 367 ++++++++++++++++++ .../paper/registry/keys/EnchantmentKeys.java | 336 ++++++++++++++++ .../paper/registry/keys/GameEventKeys.java | 9 +- .../paper/registry/keys/InstrumentKeys.java | 91 +++++ .../paper/registry/keys/MobEffectKeys.java | 321 +++++++++++++++ .../paper/registry/keys/WolfVariantKeys.java | 105 +++++ .../java/io/papermc/generator/Generators.java | 12 +- .../generator/types/GeneratedKeyType.java | 20 +- patches/api/0004-Code-Generation.patch | 54 ++- ...gistryAccess-for-managing-registries.patch | 145 ++----- .../api/0244-Add-StructuresLocateEvent.patch | 4 +- .../api/0338-More-PotionEffectType-API.patch | 4 +- patches/api/0444-Improve-Registry.patch | 6 +- 13 files changed, 1329 insertions(+), 145 deletions(-) create mode 100644 paper-api-generator/generated/io/papermc/paper/registry/keys/DamageTypeKeys.java create mode 100644 paper-api-generator/generated/io/papermc/paper/registry/keys/EnchantmentKeys.java create mode 100644 paper-api-generator/generated/io/papermc/paper/registry/keys/InstrumentKeys.java create mode 100644 paper-api-generator/generated/io/papermc/paper/registry/keys/MobEffectKeys.java create mode 100644 paper-api-generator/generated/io/papermc/paper/registry/keys/WolfVariantKeys.java diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/DamageTypeKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/DamageTypeKeys.java new file mode 100644 index 0000000000..ed52d2393e --- /dev/null +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/DamageTypeKeys.java @@ -0,0 +1,367 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.MinecraftExperimental; +import org.bukkit.damage.DamageType; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Vanilla keys for {@link RegistryKey#DAMAGE_TYPE}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@GeneratedFrom("1.20.6") +@ApiStatus.Experimental +public final class DamageTypeKeys { + /** + * {@code minecraft:arrow} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ARROW = create(key("arrow")); + + /** + * {@code minecraft:bad_respawn_point} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BAD_RESPAWN_POINT = create(key("bad_respawn_point")); + + /** + * {@code minecraft:cactus} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CACTUS = create(key("cactus")); + + /** + * {@code minecraft:cramming} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CRAMMING = create(key("cramming")); + + /** + * {@code minecraft:dragon_breath} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DRAGON_BREATH = create(key("dragon_breath")); + + /** + * {@code minecraft:drown} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DROWN = create(key("drown")); + + /** + * {@code minecraft:dry_out} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DRY_OUT = create(key("dry_out")); + + /** + * {@code minecraft:explosion} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey EXPLOSION = create(key("explosion")); + + /** + * {@code minecraft:fall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FALL = create(key("fall")); + + /** + * {@code minecraft:falling_anvil} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FALLING_ANVIL = create(key("falling_anvil")); + + /** + * {@code minecraft:falling_block} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FALLING_BLOCK = create(key("falling_block")); + + /** + * {@code minecraft:falling_stalactite} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FALLING_STALACTITE = create(key("falling_stalactite")); + + /** + * {@code minecraft:fireball} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIREBALL = create(key("fireball")); + + /** + * {@code minecraft:fireworks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIREWORKS = create(key("fireworks")); + + /** + * {@code minecraft:fly_into_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FLY_INTO_WALL = create(key("fly_into_wall")); + + /** + * {@code minecraft:freeze} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FREEZE = create(key("freeze")); + + /** + * {@code minecraft:generic} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GENERIC = create(key("generic")); + + /** + * {@code minecraft:generic_kill} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GENERIC_KILL = create(key("generic_kill")); + + /** + * {@code minecraft:hot_floor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HOT_FLOOR = create(key("hot_floor")); + + /** + * {@code minecraft:in_fire} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IN_FIRE = create(key("in_fire")); + + /** + * {@code minecraft:in_wall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IN_WALL = create(key("in_wall")); + + /** + * {@code minecraft:indirect_magic} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey INDIRECT_MAGIC = create(key("indirect_magic")); + + /** + * {@code minecraft:lava} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LAVA = create(key("lava")); + + /** + * {@code minecraft:lightning_bolt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LIGHTNING_BOLT = create(key("lightning_bolt")); + + /** + * {@code minecraft:magic} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAGIC = create(key("magic")); + + /** + * {@code minecraft:mob_attack} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MOB_ATTACK = create(key("mob_attack")); + + /** + * {@code minecraft:mob_attack_no_aggro} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MOB_ATTACK_NO_AGGRO = create(key("mob_attack_no_aggro")); + + /** + * {@code minecraft:mob_projectile} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MOB_PROJECTILE = create(key("mob_projectile")); + + /** + * {@code minecraft:on_fire} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ON_FIRE = create(key("on_fire")); + + /** + * {@code minecraft:out_of_world} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey OUT_OF_WORLD = create(key("out_of_world")); + + /** + * {@code minecraft:outside_border} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey OUTSIDE_BORDER = create(key("outside_border")); + + /** + * {@code minecraft:player_attack} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PLAYER_ATTACK = create(key("player_attack")); + + /** + * {@code minecraft:player_explosion} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PLAYER_EXPLOSION = create(key("player_explosion")); + + /** + * {@code minecraft:sonic_boom} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SONIC_BOOM = create(key("sonic_boom")); + + /** + * {@code minecraft:spit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPIT = create(key("spit")); + + /** + * {@code minecraft:stalagmite} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STALAGMITE = create(key("stalagmite")); + + /** + * {@code minecraft:starve} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STARVE = create(key("starve")); + + /** + * {@code minecraft:sting} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STING = create(key("sting")); + + /** + * {@code minecraft:sweet_berry_bush} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SWEET_BERRY_BUSH = create(key("sweet_berry_bush")); + + /** + * {@code minecraft:thorns} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey THORNS = create(key("thorns")); + + /** + * {@code minecraft:thrown} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey THROWN = create(key("thrown")); + + /** + * {@code minecraft:trident} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TRIDENT = create(key("trident")); + + /** + * {@code minecraft:unattributed_fireball} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey UNATTRIBUTED_FIREBALL = create(key("unattributed_fireball")); + + /** + * {@code minecraft:wind_charge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey WIND_CHARGE = create(key("wind_charge")); + + /** + * {@code minecraft:wither} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WITHER = create(key("wither")); + + /** + * {@code minecraft:wither_skull} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WITHER_SKULL = create(key("wither_skull")); + + private DamageTypeKeys() { + } + + /** + * Creates a key for {@link DamageType} in a registry. + * + * @param key the value's key in the registry + * @return a new typed key + */ + @ApiStatus.Experimental + public static @NotNull TypedKey create(final @NotNull Key key) { + return TypedKey.create(RegistryKey.DAMAGE_TYPE, key); + } +} diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/EnchantmentKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/EnchantmentKeys.java new file mode 100644 index 0000000000..3c64bc0790 --- /dev/null +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/EnchantmentKeys.java @@ -0,0 +1,336 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.MinecraftExperimental; +import org.bukkit.enchantments.Enchantment; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Vanilla keys for {@link RegistryKey#ENCHANTMENT}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@GeneratedFrom("1.20.6") +@ApiStatus.Experimental +public final class EnchantmentKeys { + /** + * {@code minecraft:aqua_affinity} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey AQUA_AFFINITY = create(key("aqua_affinity")); + + /** + * {@code minecraft:bane_of_arthropods} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BANE_OF_ARTHROPODS = create(key("bane_of_arthropods")); + + /** + * {@code minecraft:binding_curse} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BINDING_CURSE = create(key("binding_curse")); + + /** + * {@code minecraft:blast_protection} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLAST_PROTECTION = create(key("blast_protection")); + + /** + * {@code minecraft:breach} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey BREACH = create(key("breach")); + + /** + * {@code minecraft:channeling} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CHANNELING = create(key("channeling")); + + /** + * {@code minecraft:density} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey DENSITY = create(key("density")); + + /** + * {@code minecraft:depth_strider} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DEPTH_STRIDER = create(key("depth_strider")); + + /** + * {@code minecraft:efficiency} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey EFFICIENCY = create(key("efficiency")); + + /** + * {@code minecraft:feather_falling} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FEATHER_FALLING = create(key("feather_falling")); + + /** + * {@code minecraft:fire_aspect} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIRE_ASPECT = create(key("fire_aspect")); + + /** + * {@code minecraft:fire_protection} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIRE_PROTECTION = create(key("fire_protection")); + + /** + * {@code minecraft:flame} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FLAME = create(key("flame")); + + /** + * {@code minecraft:fortune} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FORTUNE = create(key("fortune")); + + /** + * {@code minecraft:frost_walker} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FROST_WALKER = create(key("frost_walker")); + + /** + * {@code minecraft:impaling} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IMPALING = create(key("impaling")); + + /** + * {@code minecraft:infinity} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey INFINITY = create(key("infinity")); + + /** + * {@code minecraft:knockback} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey KNOCKBACK = create(key("knockback")); + + /** + * {@code minecraft:looting} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LOOTING = create(key("looting")); + + /** + * {@code minecraft:loyalty} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LOYALTY = create(key("loyalty")); + + /** + * {@code minecraft:luck_of_the_sea} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LUCK_OF_THE_SEA = create(key("luck_of_the_sea")); + + /** + * {@code minecraft:lure} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LURE = create(key("lure")); + + /** + * {@code minecraft:mending} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MENDING = create(key("mending")); + + /** + * {@code minecraft:multishot} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MULTISHOT = create(key("multishot")); + + /** + * {@code minecraft:piercing} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PIERCING = create(key("piercing")); + + /** + * {@code minecraft:power} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POWER = create(key("power")); + + /** + * {@code minecraft:projectile_protection} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PROJECTILE_PROTECTION = create(key("projectile_protection")); + + /** + * {@code minecraft:protection} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PROTECTION = create(key("protection")); + + /** + * {@code minecraft:punch} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PUNCH = create(key("punch")); + + /** + * {@code minecraft:quick_charge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey QUICK_CHARGE = create(key("quick_charge")); + + /** + * {@code minecraft:respiration} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RESPIRATION = create(key("respiration")); + + /** + * {@code minecraft:riptide} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RIPTIDE = create(key("riptide")); + + /** + * {@code minecraft:sharpness} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SHARPNESS = create(key("sharpness")); + + /** + * {@code minecraft:silk_touch} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SILK_TOUCH = create(key("silk_touch")); + + /** + * {@code minecraft:smite} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SMITE = create(key("smite")); + + /** + * {@code minecraft:soul_speed} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SOUL_SPEED = create(key("soul_speed")); + + /** + * {@code minecraft:sweeping_edge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SWEEPING_EDGE = create(key("sweeping_edge")); + + /** + * {@code minecraft:swift_sneak} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SWIFT_SNEAK = create(key("swift_sneak")); + + /** + * {@code minecraft:thorns} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey THORNS = create(key("thorns")); + + /** + * {@code minecraft:unbreaking} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey UNBREAKING = create(key("unbreaking")); + + /** + * {@code minecraft:vanishing_curse} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey VANISHING_CURSE = create(key("vanishing_curse")); + + /** + * {@code minecraft:wind_burst} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey WIND_BURST = create(key("wind_burst")); + + private EnchantmentKeys() { + } + + private static @NotNull TypedKey create(final @NotNull Key key) { + return TypedKey.create(RegistryKey.ENCHANTMENT, key); + } +} diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java index f220c63b8a..6d228f2f02 100644 --- a/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/GameEventKeys.java @@ -449,14 +449,7 @@ public final class GameEventKeys { private GameEventKeys() { } - /** - * Creates a key for {@link GameEvent} in a registry. - * - * @param key the value's key in the registry - * @return a new typed key - */ - @ApiStatus.Experimental - public static @NotNull TypedKey create(final @NotNull Key key) { + private static @NotNull TypedKey create(final @NotNull Key key) { return TypedKey.create(RegistryKey.GAME_EVENT, key); } } diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/InstrumentKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/InstrumentKeys.java new file mode 100644 index 0000000000..0cddaa1936 --- /dev/null +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/InstrumentKeys.java @@ -0,0 +1,91 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.MusicInstrument; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Vanilla keys for {@link RegistryKey#INSTRUMENT}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@GeneratedFrom("1.20.6") +@ApiStatus.Experimental +public final class InstrumentKeys { + /** + * {@code minecraft:admire_goat_horn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ADMIRE_GOAT_HORN = create(key("admire_goat_horn")); + + /** + * {@code minecraft:call_goat_horn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CALL_GOAT_HORN = create(key("call_goat_horn")); + + /** + * {@code minecraft:dream_goat_horn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DREAM_GOAT_HORN = create(key("dream_goat_horn")); + + /** + * {@code minecraft:feel_goat_horn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FEEL_GOAT_HORN = create(key("feel_goat_horn")); + + /** + * {@code minecraft:ponder_goat_horn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PONDER_GOAT_HORN = create(key("ponder_goat_horn")); + + /** + * {@code minecraft:seek_goat_horn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SEEK_GOAT_HORN = create(key("seek_goat_horn")); + + /** + * {@code minecraft:sing_goat_horn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SING_GOAT_HORN = create(key("sing_goat_horn")); + + /** + * {@code minecraft:yearn_goat_horn} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey YEARN_GOAT_HORN = create(key("yearn_goat_horn")); + + private InstrumentKeys() { + } + + private static @NotNull TypedKey create(final @NotNull Key key) { + return TypedKey.create(RegistryKey.INSTRUMENT, key); + } +} diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/MobEffectKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/MobEffectKeys.java new file mode 100644 index 0000000000..83835bd7ff --- /dev/null +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/MobEffectKeys.java @@ -0,0 +1,321 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.MinecraftExperimental; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Vanilla keys for {@link RegistryKey#MOB_EFFECT}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@GeneratedFrom("1.20.6") +@ApiStatus.Experimental +public final class MobEffectKeys { + /** + * {@code minecraft:absorption} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ABSORPTION = create(key("absorption")); + + /** + * {@code minecraft:bad_omen} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BAD_OMEN = create(key("bad_omen")); + + /** + * {@code minecraft:blindness} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLINDNESS = create(key("blindness")); + + /** + * {@code minecraft:conduit_power} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CONDUIT_POWER = create(key("conduit_power")); + + /** + * {@code minecraft:darkness} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DARKNESS = create(key("darkness")); + + /** + * {@code minecraft:dolphins_grace} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DOLPHINS_GRACE = create(key("dolphins_grace")); + + /** + * {@code minecraft:fire_resistance} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIRE_RESISTANCE = create(key("fire_resistance")); + + /** + * {@code minecraft:glowing} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GLOWING = create(key("glowing")); + + /** + * {@code minecraft:haste} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HASTE = create(key("haste")); + + /** + * {@code minecraft:health_boost} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HEALTH_BOOST = create(key("health_boost")); + + /** + * {@code minecraft:hero_of_the_village} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HERO_OF_THE_VILLAGE = create(key("hero_of_the_village")); + + /** + * {@code minecraft:hunger} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HUNGER = create(key("hunger")); + + /** + * {@code minecraft:infested} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey INFESTED = create(key("infested")); + + /** + * {@code minecraft:instant_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey INSTANT_DAMAGE = create(key("instant_damage")); + + /** + * {@code minecraft:instant_health} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey INSTANT_HEALTH = create(key("instant_health")); + + /** + * {@code minecraft:invisibility} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey INVISIBILITY = create(key("invisibility")); + + /** + * {@code minecraft:jump_boost} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey JUMP_BOOST = create(key("jump_boost")); + + /** + * {@code minecraft:levitation} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LEVITATION = create(key("levitation")); + + /** + * {@code minecraft:luck} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LUCK = create(key("luck")); + + /** + * {@code minecraft:mining_fatigue} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MINING_FATIGUE = create(key("mining_fatigue")); + + /** + * {@code minecraft:nausea} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NAUSEA = create(key("nausea")); + + /** + * {@code minecraft:night_vision} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NIGHT_VISION = create(key("night_vision")); + + /** + * {@code minecraft:oozing} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey OOZING = create(key("oozing")); + + /** + * {@code minecraft:poison} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POISON = create(key("poison")); + + /** + * {@code minecraft:raid_omen} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey RAID_OMEN = create(key("raid_omen")); + + /** + * {@code minecraft:regeneration} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey REGENERATION = create(key("regeneration")); + + /** + * {@code minecraft:resistance} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RESISTANCE = create(key("resistance")); + + /** + * {@code minecraft:saturation} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SATURATION = create(key("saturation")); + + /** + * {@code minecraft:slow_falling} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SLOW_FALLING = create(key("slow_falling")); + + /** + * {@code minecraft:slowness} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SLOWNESS = create(key("slowness")); + + /** + * {@code minecraft:speed} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPEED = create(key("speed")); + + /** + * {@code minecraft:strength} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STRENGTH = create(key("strength")); + + /** + * {@code minecraft:trial_omen} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey TRIAL_OMEN = create(key("trial_omen")); + + /** + * {@code minecraft:unluck} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey UNLUCK = create(key("unluck")); + + /** + * {@code minecraft:water_breathing} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WATER_BREATHING = create(key("water_breathing")); + + /** + * {@code minecraft:weakness} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WEAKNESS = create(key("weakness")); + + /** + * {@code minecraft:weaving} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey WEAVING = create(key("weaving")); + + /** + * {@code minecraft:wind_charged} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental(MinecraftExperimental.Requires.UPDATE_1_21) + public static final TypedKey WIND_CHARGED = create(key("wind_charged")); + + /** + * {@code minecraft:wither} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WITHER = create(key("wither")); + + private MobEffectKeys() { + } + + private static @NotNull TypedKey create(final @NotNull Key key) { + return TypedKey.create(RegistryKey.MOB_EFFECT, key); + } +} diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/WolfVariantKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/WolfVariantKeys.java new file mode 100644 index 0000000000..5ae854aba8 --- /dev/null +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/WolfVariantKeys.java @@ -0,0 +1,105 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.entity.Wolf; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Vanilla keys for {@link RegistryKey#WOLF_VARIANT}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@GeneratedFrom("1.20.6") +@ApiStatus.Experimental +public final class WolfVariantKeys { + /** + * {@code minecraft:ashen} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ASHEN = create(key("ashen")); + + /** + * {@code minecraft:black} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLACK = create(key("black")); + + /** + * {@code minecraft:chestnut} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CHESTNUT = create(key("chestnut")); + + /** + * {@code minecraft:pale} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PALE = create(key("pale")); + + /** + * {@code minecraft:rusty} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RUSTY = create(key("rusty")); + + /** + * {@code minecraft:snowy} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SNOWY = create(key("snowy")); + + /** + * {@code minecraft:spotted} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SPOTTED = create(key("spotted")); + + /** + * {@code minecraft:striped} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STRIPED = create(key("striped")); + + /** + * {@code minecraft:woods} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WOODS = create(key("woods")); + + private WolfVariantKeys() { + } + + /** + * Creates a key for {@link Wolf.Variant} in a registry. + * + * @param key the value's key in the registry + * @return a new typed key + */ + @ApiStatus.Experimental + public static @NotNull TypedKey create(final @NotNull Key key) { + return TypedKey.create(RegistryKey.WOLF_VARIANT, key); + } +} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/Generators.java b/paper-api-generator/src/main/java/io/papermc/generator/Generators.java index ac62e26e93..4afed26dd5 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/Generators.java +++ b/paper-api-generator/src/main/java/io/papermc/generator/Generators.java @@ -8,21 +8,31 @@ import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import org.bukkit.GameEvent; +import org.bukkit.MusicInstrument; import org.bukkit.block.Biome; +import org.bukkit.damage.DamageType; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Wolf; import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.StructureType; import org.bukkit.inventory.meta.trim.TrimMaterial; import org.bukkit.inventory.meta.trim.TrimPattern; +import org.bukkit.potion.PotionEffectType; public interface Generators { SourceGenerator[] API = { - simpleKey("GameEventKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT, true), + simpleKey("GameEventKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT, false), simpleKey("BiomeKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME, true), simpleKey("TrimMaterialKeys", TrimMaterial.class, Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL, true), simpleKey("TrimPatternKeys", TrimPattern.class, Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, true), simpleKey("StructureKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE, true), simpleKey("StructureTypeKeys", StructureType.class, Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, false), + simpleKey("InstrumentKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT, false), + simpleKey("EnchantmentKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, false), + simpleKey("MobEffectKeys", PotionEffectType.class, Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, false), + simpleKey("DamageTypeKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, true), + simpleKey("WolfVariantKeys", Wolf.Variant.class, Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, true), new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai") }; diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java b/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java index 66c4a4b14f..8307fcad4c 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java +++ b/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java @@ -25,11 +25,14 @@ import java.util.Set; import java.util.stream.Collectors; import net.kyori.adventure.key.Key; import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.core.Registry; import net.minecraft.core.RegistrySetBuilder; import net.minecraft.data.registries.UpdateOneTwentyOneRegistries; import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.resources.ResourceKey; +import net.minecraft.world.flag.FeatureElement; +import net.minecraft.world.flag.FeatureFlags; import org.bukkit.MinecraftExperimental; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -151,8 +154,23 @@ public class GeneratedKeyType extends SimpleGenerator { return typeBuilder.addMethod(createMethod.build()).build(); } - @SuppressWarnings("unchecked") private Set> collectExperimentalKeys(final Registry registry) { + if (FeatureElement.FILTERED_REGISTRIES.contains(registry.key())) { + return this.collectExperimentalKeysBuiltIn(registry); + } else { + return this.collectExperimentalKeysDataDriven(registry); + } + } + + private Set> collectExperimentalKeysBuiltIn(final Registry registry) { + final HolderLookup.RegistryLookup filteredLookup = registry.asLookup().filterElements(v -> { + return ((FeatureElement) v).requiredFeatures().contains(FeatureFlags.UPDATE_1_21); + }); + return filteredLookup.listElementIds().collect(Collectors.toUnmodifiableSet()); + } + + @SuppressWarnings("unchecked") + private Set> collectExperimentalKeysDataDriven(final Registry registry) { final RegistrySetBuilder.@Nullable RegistryBootstrap experimentalBootstrap = (RegistrySetBuilder.RegistryBootstrap) EXPERIMENTAL_REGISTRY_ENTRIES.get(this.registryKey); if (experimentalBootstrap == null) { return Collections.emptySet(); diff --git a/patches/api/0004-Code-Generation.patch b/patches/api/0004-Code-Generation.patch index edbc6ff3ef..f09f795c4b 100644 --- a/patches/api/0004-Code-Generation.patch +++ b/patches/api/0004-Code-Generation.patch @@ -85,19 +85,24 @@ 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..c4b30b16ce4db754b958c493ad86d0863592c263 +index 0000000000000000000000000000000000000000..44e2abdde6eda412412c78daa6bae68041b297fd --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java -@@ -0,0 +1,67 @@ +@@ -0,0 +1,98 @@ +package io.papermc.paper.registry; + +import net.kyori.adventure.key.Keyed; +import org.bukkit.GameEvent; ++import org.bukkit.MusicInstrument; +import org.bukkit.block.Biome; ++import org.bukkit.damage.DamageType; ++import org.bukkit.enchantments.Enchantment; ++import org.bukkit.entity.Wolf; +import org.bukkit.generator.structure.Structure; +import org.bukkit.generator.structure.StructureType; +import org.bukkit.inventory.meta.trim.TrimMaterial; +import org.bukkit.inventory.meta.trim.TrimPattern; ++import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.ApiStatus; + +import static io.papermc.paper.registry.RegistryKeyImpl.create; @@ -131,6 +136,22 @@ index 0000000000000000000000000000000000000000..c4b30b16ce4db754b958c493ad86d086 + * @see io.papermc.paper.registry.keys.StructureTypeKeys + */ + RegistryKey STRUCTURE_TYPE = create("worldgen/structure_type"); ++ /** ++ * Built-in registry for instruments. ++ * @see io.papermc.paper.registry.keys.InstrumentKeys ++ */ ++ RegistryKey INSTRUMENT = create("instrument"); ++ /** ++ * Built-in registry for enchantments. ++ * @see io.papermc.paper.registry.keys.EnchantmentKeys ++ */ ++ RegistryKey ENCHANTMENT = create("enchantment"); ++ /** ++ * Built-in registry for potion effect types (mob effects). ++ * @see io.papermc.paper.registry.keys.MobEffectKeys ++ */ ++ RegistryKey MOB_EFFECT = create("mob_effect"); ++ + + /* ********************** * + * Data-driven Registries * @@ -155,13 +176,23 @@ index 0000000000000000000000000000000000000000..c4b30b16ce4db754b958c493ad86d086 + * @see io.papermc.paper.registry.keys.TrimPatternKeys + */ + RegistryKey TRIM_PATTERN = create("trim_pattern"); ++ /** ++ * Data-driven registry for damage types. ++ * @see io.papermc.paper.registry.keys.DamageTypeKeys ++ */ ++ RegistryKey DAMAGE_TYPE = create("damage_type"); ++ /** ++ * Data-driven registry for wolf variants ++ * @see io.papermc.paper.registry.keys.WolfVariantKeys ++ */ ++ RegistryKey WOLF_VARIANT = create("wolf_variant"); +} diff --git a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java new file mode 100644 -index 0000000000000000000000000000000000000000..9ad300fa1668cb59bbd85ff8091591db69b8c9dc +index 0000000000000000000000000000000000000000..791813220b2504214b1adecc69093cd600fb0f8c --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java -@@ -0,0 +1,19 @@ +@@ -0,0 +1,24 @@ +package io.papermc.paper.registry; + +import com.google.common.collect.Sets; @@ -175,15 +206,20 @@ index 0000000000000000000000000000000000000000..9ad300fa1668cb59bbd85ff8091591db + static final Set> REGISTRY_KEYS = Sets.newIdentityHashSet(); + + static RegistryKey create(@Subst("some_key") final String key) { -+ final RegistryKey registryKey = new RegistryKeyImpl<>(Key.key(Key.MINECRAFT_NAMESPACE, key)); ++ final RegistryKey registryKey = createInternal(key); + REGISTRY_KEYS.add(registryKey); + return registryKey; + } + ++ // creates the key without adding to the internal set of keys ++ static RegistryKey createInternal(@Subst("some_key") final String key) { ++ return new RegistryKeyImpl<>(Key.key(Key.MINECRAFT_NAMESPACE, key)); ++ } ++ +} diff --git a/src/main/java/io/papermc/paper/registry/TypedKey.java b/src/main/java/io/papermc/paper/registry/TypedKey.java new file mode 100644 -index 0000000000000000000000000000000000000000..271454cd1b92ada4301025b57348ea77da9116a1 +index 0000000000000000000000000000000000000000..6f5a062ba7ee7173468ecea3c1855a233bf3855e --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/TypedKey.java @@ -0,0 +1,44 @@ @@ -227,13 +263,13 @@ index 0000000000000000000000000000000000000000..271454cd1b92ada4301025b57348ea77 + * @return a new key for the value key and registry key + */ + @ApiStatus.Experimental -+ static @NotNull TypedKey create(final @NotNull RegistryKey registryKey, final @NotNull Key key) { ++ static @NotNull TypedKey create(final @NotNull RegistryKey registryKey, final @NotNull Key key) { + return new TypedKeyImpl<>(key, registryKey); + } +} diff --git a/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java new file mode 100644 -index 0000000000000000000000000000000000000000..3c3fd73f7742bb8602e2f9164dd4c1208a412255 +index 0000000000000000000000000000000000000000..1a97b3359c4ece5c29131da7c3f208aaa8fab66e --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java @@ -0,0 +1,8 @@ @@ -243,7 +279,7 @@ index 0000000000000000000000000000000000000000..3c3fd73f7742bb8602e2f9164dd4c120 +import net.kyori.adventure.key.Keyed; +import org.jetbrains.annotations.NotNull; + -+record TypedKeyImpl(@NotNull Key key, @NotNull RegistryKey registryKey) implements TypedKey { ++record TypedKeyImpl(@NotNull Key key, @NotNull RegistryKey registryKey) implements TypedKey { +} diff --git a/src/main/java/org/bukkit/MinecraftExperimental.java b/src/main/java/org/bukkit/MinecraftExperimental.java index b6f4810e387c22c4a70609ea1d605130245689a5..03824ae54e1bdb8b14f79b3c5e0294ae725e43f8 100644 diff --git a/patches/api/0243-Add-RegistryAccess-for-managing-registries.patch b/patches/api/0243-Add-RegistryAccess-for-managing-registries.patch index dee50d07c0..42c6e0c151 100644 --- a/patches/api/0243-Add-RegistryAccess-for-managing-registries.patch +++ b/patches/api/0243-Add-RegistryAccess-for-managing-registries.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Add RegistryAccess for managing registries diff --git a/src/main/java/io/papermc/paper/registry/Reference.java b/src/main/java/io/papermc/paper/registry/Reference.java new file mode 100644 -index 0000000000000000000000000000000000000000..92ec13c2bd515fedfd5057201ae4ba15c184bacd +index 0000000000000000000000000000000000000000..d8656772e0c983df7c40ddc367a73ce473348339 --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/Reference.java @@ -0,0 +1,47 @@ @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..92ec13c2bd515fedfd5057201ae4ba15 + * + * @param type of the value + */ -+@Deprecated(forRemoval = true, since = "1.20.4") ++@Deprecated(forRemoval = true, since = "1.20.6") +public interface Reference extends Keyed { + + /** @@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..92ec13c2bd515fedfd5057201ae4ba15 + * @return the value + * @throws java.util.NoSuchElementException if there is no value with this key + */ -+ @Deprecated(forRemoval = true, since = "1.20.4") ++ @Deprecated(forRemoval = true, since = "1.20.6") + @NotNull T value(); + + /** @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..92ec13c2bd515fedfd5057201ae4ba15 + * + * @return the value or null if it doesn't exist + */ -+ @Deprecated(forRemoval = true, since = "1.20.4") ++ @Deprecated(forRemoval = true, since = "1.20.6") + @Nullable T valueOrNull(); + + /** @@ -52,7 +52,7 @@ index 0000000000000000000000000000000000000000..92ec13c2bd515fedfd5057201ae4ba15 + * @param the type of the value + * @return a reference + */ -+ @Deprecated(forRemoval = true, since = "1.20.4") ++ @Deprecated(forRemoval = true, since = "1.20.6") + static @NotNull Reference create(@NotNull Registry registry, @NotNull NamespacedKey key) { + return new ReferenceImpl<>(registry, key); + } @@ -96,7 +96,7 @@ index 0000000000000000000000000000000000000000..f29e76a6b66ddfec12ddf8db6dcb2df6 +} diff --git a/src/main/java/io/papermc/paper/registry/RegistryAccess.java b/src/main/java/io/papermc/paper/registry/RegistryAccess.java new file mode 100644 -index 0000000000000000000000000000000000000000..e3034bd90443f355201d72c2fc9a2960c98d2649 +index 0000000000000000000000000000000000000000..54b0041e6b9b7aaa077d764e671e386e762ba25c --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/RegistryAccess.java @@ -0,0 +1,45 @@ @@ -129,7 +129,7 @@ index 0000000000000000000000000000000000000000..e3034bd90443f355201d72c2fc9a2960 + * @param the type + * @deprecated use {@link #getRegistry(RegistryKey)} with keys from {@link RegistryKey} + */ -+ @Deprecated(since = "1.20.4", forRemoval = true) ++ @Deprecated(since = "1.20.6", forRemoval = true) + @Nullable Registry getRegistry(@NotNull Class type); + + /** @@ -163,106 +163,8 @@ index 0000000000000000000000000000000000000000..b89e19c070f97c9662f1e16309446494 + private RegistryAccessHolder() { + } +} -diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java -index c4b30b16ce4db754b958c493ad86d0863592c263..e376c95ac4db43a1c5233287f01b20b9c8b614bc 100644 ---- a/src/main/java/io/papermc/paper/registry/RegistryKey.java -+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java -@@ -2,11 +2,16 @@ package io.papermc.paper.registry; - - import net.kyori.adventure.key.Keyed; - import org.bukkit.GameEvent; -+import org.bukkit.MusicInstrument; - import org.bukkit.block.Biome; -+import org.bukkit.damage.DamageType; -+import org.bukkit.enchantments.Enchantment; -+import org.bukkit.entity.Wolf; - import org.bukkit.generator.structure.Structure; - import org.bukkit.generator.structure.StructureType; - import org.bukkit.inventory.meta.trim.TrimMaterial; - import org.bukkit.inventory.meta.trim.TrimPattern; -+import org.bukkit.potion.PotionEffectType; - import org.jetbrains.annotations.ApiStatus; - - import static io.papermc.paper.registry.RegistryKeyImpl.create; -@@ -40,6 +45,19 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { - * @see io.papermc.paper.registry.keys.StructureTypeKeys - */ - RegistryKey STRUCTURE_TYPE = create("worldgen/structure_type"); -+ /** -+ * Built-in registry for instruments. -+ */ -+ RegistryKey INSTRUMENT = create("instrument"); -+ /** -+ * Built-in registry for enchantments. -+ */ -+ RegistryKey ENCHANTMENT = create("enchantment"); -+ /** -+ * Built-in registry for potion effect types (mob effects). -+ */ -+ RegistryKey MOB_EFFECT = create("mob_effect"); -+ - - /* ********************** * - * Data-driven Registries * -@@ -64,4 +82,12 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { - * @see io.papermc.paper.registry.keys.TrimPatternKeys - */ - RegistryKey TRIM_PATTERN = create("trim_pattern"); -+ /** -+ * Data-driven registry for damage types. -+ */ -+ RegistryKey DAMAGE_TYPE = create("damage_type"); -+ /** -+ * Data-driven registry for wolf variants -+ */ -+ RegistryKey WOLF_VARIANT = create("wolf_variant"); - } -diff --git a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java -index 9ad300fa1668cb59bbd85ff8091591db69b8c9dc..791813220b2504214b1adecc69093cd600fb0f8c 100644 ---- a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java -+++ b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java -@@ -11,9 +11,14 @@ record RegistryKeyImpl(@NotNull Key key) implements RegistryKey { - static final Set> REGISTRY_KEYS = Sets.newIdentityHashSet(); - - static RegistryKey create(@Subst("some_key") final String key) { -- final RegistryKey registryKey = new RegistryKeyImpl<>(Key.key(Key.MINECRAFT_NAMESPACE, key)); -+ final RegistryKey registryKey = createInternal(key); - REGISTRY_KEYS.add(registryKey); - return registryKey; - } - -+ // creates the key without adding to the internal set of keys -+ static RegistryKey createInternal(@Subst("some_key") final String key) { -+ return new RegistryKeyImpl<>(Key.key(Key.MINECRAFT_NAMESPACE, key)); -+ } -+ - } -diff --git a/src/main/java/io/papermc/paper/registry/TypedKey.java b/src/main/java/io/papermc/paper/registry/TypedKey.java -index 271454cd1b92ada4301025b57348ea77da9116a1..6f5a062ba7ee7173468ecea3c1855a233bf3855e 100644 ---- a/src/main/java/io/papermc/paper/registry/TypedKey.java -+++ b/src/main/java/io/papermc/paper/registry/TypedKey.java -@@ -38,7 +38,7 @@ public sealed interface TypedKey extends Keyed permits TypedKeyImpl { - * @return a new key for the value key and registry key - */ - @ApiStatus.Experimental -- static @NotNull TypedKey create(final @NotNull RegistryKey registryKey, final @NotNull Key key) { -+ static @NotNull TypedKey create(final @NotNull RegistryKey registryKey, final @NotNull Key key) { - return new TypedKeyImpl<>(key, registryKey); - } - } -diff --git a/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java -index 3c3fd73f7742bb8602e2f9164dd4c1208a412255..1a97b3359c4ece5c29131da7c3f208aaa8fab66e 100644 ---- a/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java -+++ b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java -@@ -4,5 +4,5 @@ import net.kyori.adventure.key.Key; - import net.kyori.adventure.key.Keyed; - import org.jetbrains.annotations.NotNull; - --record TypedKeyImpl(@NotNull Key key, @NotNull RegistryKey registryKey) implements TypedKey { -+record TypedKeyImpl(@NotNull Key key, @NotNull RegistryKey registryKey) implements TypedKey { - } diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 732ed3724e784ad659cb4411dbd73b42a8330a2c..cbf660db860e73df21be426e63928f8aeec0ac90 100644 +index 732ed3724e784ad659cb4411dbd73b42a8330a2c..7be6710d28dea19bd0f9054c1c2e32dacd355c45 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -2398,8 +2398,11 @@ public final class Bukkit { @@ -273,12 +175,12 @@ index 732ed3724e784ad659cb4411dbd73b42a8330a2c..cbf660db860e73df21be426e63928f8a + * with keys from {@link io.papermc.paper.registry.RegistryKey} */ @Nullable -+ @Deprecated(since = "1.20.4") ++ @Deprecated(since = "1.20.6") public static Registry getRegistry(@NotNull Class tClass) { return server.getRegistry(tClass); } diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java -index a04d279561676e825905f5512c399d14a3d8f828..e2aea210de4f37f6ca1afe3e6fdbc790410539ac 100644 +index a04d279561676e825905f5512c399d14a3d8f828..7aee2cee892492c523ae06902c6582b0ab827ffa 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java @@ -129,7 +129,7 @@ public interface Registry extends Iterable { @@ -315,7 +217,7 @@ index a04d279561676e825905f5512c399d14a3d8f828..e2aea210de4f37f6ca1afe3e6fdbc790 + * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#STRUCTURE} */ - Registry STRUCTURE = Bukkit.getRegistry(Structure.class); -+ @Deprecated(since = "1.20.4") // Paper ++ @Deprecated(since = "1.20.6") // Paper + Registry STRUCTURE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Structure.class); // Paper /** * Server structure types. @@ -327,14 +229,14 @@ index a04d279561676e825905f5512c399d14a3d8f828..e2aea210de4f37f6ca1afe3e6fdbc790 /** * Sound keys. * -@@ -200,21 +202,25 @@ public interface Registry extends Iterable { +@@ -200,21 +202,26 @@ public interface Registry extends Iterable { * Trim materials. * * @see TrimMaterial + * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#TRIM_MATERIAL} */ - Registry TRIM_MATERIAL = Bukkit.getRegistry(TrimMaterial.class); -+ @Deprecated(since = "1.20.4") // Paper ++ @Deprecated(since = "1.20.6") // Paper + Registry TRIM_MATERIAL = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(TrimMaterial.class); // Paper /** * Trim patterns. @@ -343,29 +245,34 @@ index a04d279561676e825905f5512c399d14a3d8f828..e2aea210de4f37f6ca1afe3e6fdbc790 + * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#TRIM_PATTERN} */ - Registry TRIM_PATTERN = Bukkit.getRegistry(TrimPattern.class); -+ @Deprecated(since = "1.20.4") ++ @Deprecated(since = "1.20.6") + Registry TRIM_PATTERN = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(TrimPattern.class); // Paper /** * Damage types. * * @see DamageType ++ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#DAMAGE_TYPE} */ - @ApiStatus.Experimental +- @ApiStatus.Experimental - Registry DAMAGE_TYPE = Objects.requireNonNull(Bukkit.getRegistry(DamageType.class), "No registry present for DamageType. This is a bug."); ++ @Deprecated(since = "1.20.6") + Registry DAMAGE_TYPE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(DamageType.class); // Paper /** * Villager profession. * -@@ -269,7 +275,7 @@ public interface Registry extends Iterable { +@@ -268,8 +275,10 @@ public interface Registry extends Iterable { + * Wolf variants. * * @see Wolf.Variant ++ * @deprecated use {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)} with {@link io.papermc.paper.registry.RegistryKey#WOLF_VARIANT} */ - Registry WOLF_VARIANT = Objects.requireNonNull(Bukkit.getRegistry(Wolf.Variant.class), "No registry present for Wolf Variant. This is a bug."); ++ @Deprecated(since = "1.20.6") + Registry WOLF_VARIANT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(Wolf.Variant.class); // Paper /** * Map cursor types. * -@@ -282,7 +288,7 @@ public interface Registry extends Iterable { +@@ -282,7 +291,7 @@ public interface Registry extends Iterable { * * @see GameEvent */ @@ -375,7 +282,7 @@ index a04d279561676e825905f5512c399d14a3d8f828..e2aea210de4f37f6ca1afe3e6fdbc790 * Get the object by its key. * diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 395f7910f535bfd33a5676b011ab62a53e30e140..84397dd36027fffcb3e7216c877be29c31da560f 100644 +index 395f7910f535bfd33a5676b011ab62a53e30e140..5644af8154373923791e3ed5f8b01c3f5d357b9c 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -2046,8 +2046,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @@ -386,13 +293,13 @@ index 395f7910f535bfd33a5676b011ab62a53e30e140..84397dd36027fffcb3e7216c877be29c + * with keys from {@link io.papermc.paper.registry.RegistryKey} */ @Nullable -+ @Deprecated(since = "1.20.4") // Paper ++ @Deprecated(since = "1.20.6") // Paper Registry getRegistry(@NotNull Class tClass); /** diff --git a/src/test/java/io/papermc/paper/registry/TestRegistryAccess.java b/src/test/java/io/papermc/paper/registry/TestRegistryAccess.java new file mode 100644 -index 0000000000000000000000000000000000000000..5e99d7d84150664f16cbbd6f58eb3a316017fe5f +index 0000000000000000000000000000000000000000..f5ece852f97017f71bc129e194cb212979b2537b --- /dev/null +++ b/src/test/java/io/papermc/paper/registry/TestRegistryAccess.java @@ -0,0 +1,20 @@ @@ -406,7 +313,7 @@ index 0000000000000000000000000000000000000000..5e99d7d84150664f16cbbd6f58eb3a31 +public class TestRegistryAccess implements RegistryAccess { + + @Override -+ @Deprecated(since = "1.20.4", forRemoval = true) ++ @Deprecated(since = "1.20.6", forRemoval = true) + public @Nullable Registry getRegistry(final @NotNull Class type) { + throw new UnsupportedOperationException("Not supported"); + } diff --git a/patches/api/0244-Add-StructuresLocateEvent.patch b/patches/api/0244-Add-StructuresLocateEvent.patch index 7f05fa3b18..517815d777 100644 --- a/patches/api/0244-Add-StructuresLocateEvent.patch +++ b/patches/api/0244-Add-StructuresLocateEvent.patch @@ -513,10 +513,10 @@ index 0000000000000000000000000000000000000000..1e7b53f9bc13dcd5a0a4a40004591e4f + } +} diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java -index e2aea210de4f37f6ca1afe3e6fdbc790410539ac..29f21ac76fc5226e03ef0a01985718a8a9b72460 100644 +index 7aee2cee892492c523ae06902c6582b0ab827ffa..3adc243fa7e1aecf8a271b38a25c7fa3ef6fcc03 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java -@@ -289,6 +289,15 @@ public interface Registry extends Iterable { +@@ -292,6 +292,15 @@ public interface Registry extends Iterable { * @see GameEvent */ Registry GAME_EVENT = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.registry.RegistryKey.GAME_EVENT); // Paper diff --git a/patches/api/0338-More-PotionEffectType-API.patch b/patches/api/0338-More-PotionEffectType-API.patch index ec42b4c6e0..197d1f3222 100644 --- a/patches/api/0338-More-PotionEffectType-API.patch +++ b/patches/api/0338-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 29f21ac76fc5226e03ef0a01985718a8a9b72460..7fdce09618505fad9b6f4781ac81b1e373bc1114 100644 +index 3adc243fa7e1aecf8a271b38a25c7fa3ef6fcc03..9a8be5c730802e5750de1fc31e65f254f5894e63 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java -@@ -297,6 +297,31 @@ public interface Registry extends Iterable { +@@ -300,6 +300,31 @@ public interface Registry extends Iterable { */ @Deprecated(forRemoval = true) Registry CONFIGURED_STRUCTURE = io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(io.papermc.paper.world.structure.ConfiguredStructure.class); diff --git a/patches/api/0444-Improve-Registry.patch b/patches/api/0444-Improve-Registry.patch index 858b177b9b..9ae821e422 100644 --- a/patches/api/0444-Improve-Registry.patch +++ b/patches/api/0444-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 7fdce09618505fad9b6f4781ac81b1e373bc1114..c63a2d5d21eb599939ec7ae5e57506ff746e4174 100644 +index 9a8be5c730802e5750de1fc31e65f254f5894e63..0f7f23738c57ebe37846714159bb49e5b61e9f3d 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java -@@ -332,6 +332,49 @@ public interface Registry extends Iterable { +@@ -335,6 +335,49 @@ public interface Registry extends Iterable { @Nullable T get(@NotNull NamespacedKey key); @@ -84,7 +84,7 @@ index 7fdce09618505fad9b6f4781ac81b1e373bc1114..c63a2d5d21eb599939ec7ae5e57506ff /** * Returns a new stream, which contains all registry items, which are registered to the registry. * -@@ -398,5 +441,12 @@ public interface Registry extends Iterable { +@@ -401,5 +444,12 @@ public interface Registry extends Iterable { public Iterator iterator() { return map.values().iterator(); }