Archiviert
13
0

Update key gen for 1.20.4 (#10015)

Dieser Commit ist enthalten in:
Jake Potrebic 2023-12-10 10:25:01 -08:00 committet von GitHub
Ursprung 166761f29f
Commit 3434a6fc66
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
6 geänderte Dateien mit 313 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> 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<Structure> create(final @NotNull Key key) {
return TypedKey.create(RegistryKey.STRUCTURE, key);
}
}

Datei anzeigen

@ -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)
);

Datei anzeigen

@ -8,12 +8,14 @@ import org.jetbrains.annotations.NotNull;
public final class Annotations {
public static final List<AnnotationSpec> EXPERIMENTAL_ANNOTATIONS = List.of(
AnnotationSpec.builder(ApiStatus.Experimental.class).build(),
AnnotationSpec.builder(MinecraftExperimental.class)
.addMember("value", "$S", "update 1.20")
.build()
);
public static List<AnnotationSpec> 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();

Datei anzeigen

@ -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<T, A> implements SourceGenerator {
// don't exist anymore
// private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> EXPERIMENTAL_REGISTRY_ENTRIES = UpdateOneTwentyRegistries.BUILDER.entries.stream()
// .collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap));
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> EXPERIMENTAL_REGISTRY_ENTRIES = Collections.emptyMap();
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> EXPERIMENTAL_REGISTRY_ENTRIES = UpdateOneTwentyOneRegistries.BUILDER.entries.stream()
.collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap));
private static final Map<RegistryKey<?>, String> REGISTRY_KEY_FIELD_NAMES;
static {
@ -158,15 +158,15 @@ public class GeneratedKeyType<T, A> 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();
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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> BIOME = create("worldgen/biome");
+ /**
+ * Data-driven registry for structure types.
+ * Data-driven registry for structures.
+ * @see io.papermc.paper.registry.keys.StructureKeys
+ */
+ RegistryKey<Structure> STRUCTURE = create("worldgen/structure");
+ /**
+ * Data-driven registry for trim materials.
+ * @see io.papermc.paper.registry.keys.TrimMaterialKeys
+ */
+ RegistryKey<TrimMaterial> 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<TrimPattern> TRIM_PATTERN = create("trim_pattern");