diff --git a/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java new file mode 100644 index 000000000..37fc87330 --- /dev/null +++ b/paper-api-generator/generated/io/papermc/paper/registry/keys/StructureKeys.java @@ -0,0 +1,283 @@ +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.generator.structure.Structure; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Vanilla keys for {@link RegistryKey#STRUCTURE}. + * + * @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.4") +@ApiStatus.Experimental +public final class StructureKeys { + /** + * {@code minecraft:ancient_city} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ANCIENT_CITY = create(key("ancient_city")); + + /** + * {@code minecraft:bastion_remnant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BASTION_REMNANT = create(key("bastion_remnant")); + + /** + * {@code minecraft:buried_treasure} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BURIED_TREASURE = create(key("buried_treasure")); + + /** + * {@code minecraft:desert_pyramid} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DESERT_PYRAMID = create(key("desert_pyramid")); + + /** + * {@code minecraft:end_city} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey END_CITY = create(key("end_city")); + + /** + * {@code minecraft:fortress} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FORTRESS = create(key("fortress")); + + /** + * {@code minecraft:igloo} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IGLOO = create(key("igloo")); + + /** + * {@code minecraft:jungle_pyramid} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey JUNGLE_PYRAMID = create(key("jungle_pyramid")); + + /** + * {@code minecraft:mansion} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MANSION = create(key("mansion")); + + /** + * {@code minecraft:mineshaft} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MINESHAFT = create(key("mineshaft")); + + /** + * {@code minecraft:mineshaft_mesa} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MINESHAFT_MESA = create(key("mineshaft_mesa")); + + /** + * {@code minecraft:monument} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MONUMENT = create(key("monument")); + + /** + * {@code minecraft:nether_fossil} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NETHER_FOSSIL = create(key("nether_fossil")); + + /** + * {@code minecraft:ocean_ruin_cold} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey OCEAN_RUIN_COLD = create(key("ocean_ruin_cold")); + + /** + * {@code minecraft:ocean_ruin_warm} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey OCEAN_RUIN_WARM = create(key("ocean_ruin_warm")); + + /** + * {@code minecraft:pillager_outpost} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PILLAGER_OUTPOST = create(key("pillager_outpost")); + + /** + * {@code minecraft:ruined_portal} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RUINED_PORTAL = create(key("ruined_portal")); + + /** + * {@code minecraft:ruined_portal_desert} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RUINED_PORTAL_DESERT = create(key("ruined_portal_desert")); + + /** + * {@code minecraft:ruined_portal_jungle} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RUINED_PORTAL_JUNGLE = create(key("ruined_portal_jungle")); + + /** + * {@code minecraft:ruined_portal_mountain} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RUINED_PORTAL_MOUNTAIN = create(key("ruined_portal_mountain")); + + /** + * {@code minecraft:ruined_portal_nether} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RUINED_PORTAL_NETHER = create(key("ruined_portal_nether")); + + /** + * {@code minecraft:ruined_portal_ocean} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RUINED_PORTAL_OCEAN = create(key("ruined_portal_ocean")); + + /** + * {@code minecraft:ruined_portal_swamp} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RUINED_PORTAL_SWAMP = create(key("ruined_portal_swamp")); + + /** + * {@code minecraft:shipwreck} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SHIPWRECK = create(key("shipwreck")); + + /** + * {@code minecraft:shipwreck_beached} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SHIPWRECK_BEACHED = create(key("shipwreck_beached")); + + /** + * {@code minecraft:stronghold} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STRONGHOLD = create(key("stronghold")); + + /** + * {@code minecraft:swamp_hut} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SWAMP_HUT = create(key("swamp_hut")); + + /** + * {@code minecraft:trail_ruins} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TRAIL_RUINS = create(key("trail_ruins")); + + /** + * {@code minecraft:trial_chambers} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + @ApiStatus.Experimental + @MinecraftExperimental("update 1.21") + public static final TypedKey TRIAL_CHAMBERS = create(key("trial_chambers")); + + /** + * {@code minecraft:village_desert} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey VILLAGE_DESERT = create(key("village_desert")); + + /** + * {@code minecraft:village_plains} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey VILLAGE_PLAINS = create(key("village_plains")); + + /** + * {@code minecraft:village_savanna} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey VILLAGE_SAVANNA = create(key("village_savanna")); + + /** + * {@code minecraft:village_snowy} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey VILLAGE_SNOWY = create(key("village_snowy")); + + /** + * {@code minecraft:village_taiga} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey VILLAGE_TAIGA = create(key("village_taiga")); + + private StructureKeys() { + } + + /** + * Creates a key for {@link Structure} 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.STRUCTURE, key); + } +} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/Main.java b/paper-api-generator/src/main/java/io/papermc/generator/Main.java index 6e02e0b48..4ce510a6d 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/Main.java +++ b/paper-api-generator/src/main/java/io/papermc/generator/Main.java @@ -8,7 +8,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import net.kyori.adventure.key.Keyed; import net.minecraft.SharedConstants; import net.minecraft.core.LayeredRegistryAccess; import net.minecraft.core.Registry; @@ -27,6 +26,7 @@ import net.minecraft.server.packs.resources.MultiPackResourceManager; import org.apache.commons.io.file.PathUtils; import org.bukkit.GameEvent; import org.bukkit.block.Biome; +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; @@ -53,6 +53,7 @@ public final class Main { 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) ); diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/Annotations.java b/paper-api-generator/src/main/java/io/papermc/generator/types/Annotations.java index 342d80454..0886a360a 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/Annotations.java +++ b/paper-api-generator/src/main/java/io/papermc/generator/types/Annotations.java @@ -8,12 +8,14 @@ import org.jetbrains.annotations.NotNull; public final class Annotations { - public static final List EXPERIMENTAL_ANNOTATIONS = List.of( - AnnotationSpec.builder(ApiStatus.Experimental.class).build(), - AnnotationSpec.builder(MinecraftExperimental.class) - .addMember("value", "$S", "update 1.20") - .build() - ); + public static List experimentalAnnotations(final String version) { + return List.of( + AnnotationSpec.builder(ApiStatus.Experimental.class).build(), + AnnotationSpec.builder(MinecraftExperimental.class) + .addMember("value", "$S", version) + .build() + ); + } @ApiStatus.Experimental public static final AnnotationSpec EXPERIMENTAL_API_ANNOTATION = AnnotationSpec.builder(ApiStatus.Experimental.class).build(); 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 2af1bc8fb..4ecb1d102 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,19 +25,21 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.stream.Collectors; import net.kyori.adventure.key.Key; import net.minecraft.SharedConstants; import net.minecraft.core.Registry; import net.minecraft.core.RegistrySetBuilder; +import net.minecraft.data.registries.UpdateOneTwentyOneRegistries; import net.minecraft.resources.ResourceKey; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.framework.qual.DefaultQualifier; import static com.squareup.javapoet.TypeSpec.classBuilder; -import static io.papermc.generator.types.Annotations.EXPERIMENTAL_ANNOTATIONS; import static io.papermc.generator.types.Annotations.EXPERIMENTAL_API_ANNOTATION; import static io.papermc.generator.types.Annotations.NOT_NULL; +import static io.papermc.generator.types.Annotations.experimentalAnnotations; import static java.util.Objects.requireNonNull; import static javax.lang.model.element.Modifier.FINAL; import static javax.lang.model.element.Modifier.PRIVATE; @@ -47,10 +49,8 @@ import static javax.lang.model.element.Modifier.STATIC; @DefaultQualifier(NonNull.class) public class GeneratedKeyType implements SourceGenerator { - // don't exist anymore - // private static final Map>, RegistrySetBuilder.RegistryBootstrap> EXPERIMENTAL_REGISTRY_ENTRIES = UpdateOneTwentyRegistries.BUILDER.entries.stream() - // .collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap)); - private static final Map>, RegistrySetBuilder.RegistryBootstrap> EXPERIMENTAL_REGISTRY_ENTRIES = Collections.emptyMap(); + private static final Map>, RegistrySetBuilder.RegistryBootstrap> EXPERIMENTAL_REGISTRY_ENTRIES = UpdateOneTwentyOneRegistries.BUILDER.entries.stream() + .collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap)); private static final Map, String> REGISTRY_KEY_FIELD_NAMES; static { @@ -158,15 +158,15 @@ public class GeneratedKeyType implements SourceGenerator { .initializer("$N(key($S))", createMethod.build(), keyPath) .addJavadoc(FIELD_JAVADOC, key.location().toString()); if (experimental.contains(key)) { - fieldBuilder.addAnnotations(EXPERIMENTAL_ANNOTATIONS); + fieldBuilder.addAnnotations(experimentalAnnotations("update 1.21")); } else { allExperimental = false; } typeBuilder.addField(fieldBuilder.build()); } if (allExperimental) { - typeBuilder.addAnnotations(EXPERIMENTAL_ANNOTATIONS); - createMethod.addAnnotations(EXPERIMENTAL_ANNOTATIONS); + typeBuilder.addAnnotations(experimentalAnnotations("update 1.21")); + createMethod.addAnnotations(experimentalAnnotations("update 1.21")); } return typeBuilder.addMethod(createMethod.build()).build(); } diff --git a/paper-api-generator/wideners.at b/paper-api-generator/wideners.at index cc899edd9..80ce0310c 100644 --- a/paper-api-generator/wideners.at +++ b/paper-api-generator/wideners.at @@ -4,3 +4,4 @@ accessible method net/minecraft/server/WorldLoader loadAndReplaceLayer (Lnet/min # for auto-marking experimental stuff accessible field net/minecraft/core/RegistrySetBuilder entries Ljava/util/List; accessible class net/minecraft/core/RegistrySetBuilder$RegistryStub +accessible field net/minecraft/data/registries/UpdateOneTwentyOneRegistries BUILDER Lnet/minecraft/core/RegistrySetBuilder; diff --git a/patches/api/0004-Code-Generation.patch b/patches/api/0004-Code-Generation.patch index 5acadae36..294139088 100644 --- a/patches/api/0004-Code-Generation.patch +++ b/patches/api/0004-Code-Generation.patch @@ -85,15 +85,16 @@ 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..5251f922d2d14da35f61098c11694371f591cd2a +index 0000000000000000000000000000000000000000..c4b30b16ce4db754b958c493ad86d0863592c263 --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java -@@ -0,0 +1,61 @@ +@@ -0,0 +1,67 @@ +package io.papermc.paper.registry; + +import net.kyori.adventure.key.Keyed; +import org.bukkit.GameEvent; +import org.bukkit.block.Biome; ++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; @@ -135,17 +136,22 @@ index 0000000000000000000000000000000000000000..5251f922d2d14da35f61098c11694371 + * Data-driven Registries * + * ********************** */ + /** -+ * Data-driven registry for structure types. ++ * Data-driven registry for biomes. + * @see io.papermc.paper.registry.keys.BiomeKeys + */ + RegistryKey BIOME = create("worldgen/biome"); + /** -+ * Data-driven registry for structure types. ++ * Data-driven registry for structures. ++ * @see io.papermc.paper.registry.keys.StructureKeys ++ */ ++ RegistryKey STRUCTURE = create("worldgen/structure"); ++ /** ++ * Data-driven registry for trim materials. + * @see io.papermc.paper.registry.keys.TrimMaterialKeys + */ + RegistryKey TRIM_MATERIAL = create("trim_material"); + /** -+ * Data-driven registry for structure types. ++ * Data-driven registry for trim patterns. + * @see io.papermc.paper.registry.keys.TrimPatternKeys + */ + RegistryKey TRIM_PATTERN = create("trim_pattern");