Generators

Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
Lulu13022002 2024-07-05 18:00:34 +02:00
parent 5f0932b6c8
commit 85f704e537
No known key found for this signature in database
GPG Key ID: 491C8F0B8ACDEB01
379 changed files with 41617 additions and 1380 deletions

View File

@ -1,3 +1,5 @@
root = true
[*]
charset=utf-8
end_of_line=lf
@ -37,6 +39,3 @@ ij_java_use_fq_class_names = false
[Paper-Server/src/main/resources/data/**/*.json]
indent_size = 2
[paper-api-generator/generated/**/*.java]
ij_java_imports_layout = $*,|,*

2
.gitignore vendored
View File

@ -73,4 +73,4 @@ paperclip.properties
!gradle/wrapper/gradle-wrapper.jar
test-plugin.settings.gradle.kts
paper-api-generator.settings.gradle.kts
paper-generator.settings.gradle.kts

View File

@ -1,35 +0,0 @@
import io.papermc.paperweight.PaperweightSourceGeneratorHelper
import io.papermc.paperweight.extension.PaperweightSourceGeneratorExt
plugins {
java
}
plugins.apply(PaperweightSourceGeneratorHelper::class)
extensions.configure(PaperweightSourceGeneratorExt::class) {
atFile.set(projectDir.toPath().resolve("wideners.at").toFile())
}
dependencies {
implementation("com.squareup:javapoet:1.13.0")
implementation(project(":paper-api"))
implementation("io.github.classgraph:classgraph:4.8.47")
implementation("org.jetbrains:annotations:24.1.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
tasks.register<JavaExec>("generate") {
dependsOn(tasks.check)
mainClass.set("io.papermc.generator.Main")
classpath(sourceSets.main.map { it.runtimeClasspath })
args(projectDir.toPath().resolve("generated").toString())
}
tasks.test {
useJUnitPlatform()
}
group = "io.papermc.paper"
version = "1.0-SNAPSHOT"

View File

@ -1,92 +0,0 @@
package io.papermc.generator;
import io.papermc.generator.types.GeneratedKeyType;
import io.papermc.generator.types.GeneratedTagKeyType;
import io.papermc.generator.types.SourceGenerator;
import io.papermc.generator.types.goal.MobGoalGenerator;
import io.papermc.paper.registry.RegistryKey;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import org.bukkit.Art;
import org.bukkit.Fluid;
import org.bukkit.GameEvent;
import org.bukkit.JukeboxSong;
import org.bukkit.MusicInstrument;
import org.bukkit.Sound;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.Biome;
import org.bukkit.block.BlockType;
import org.bukkit.block.banner.PatternType;
import org.bukkit.damage.DamageType;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Cat;
import org.bukkit.entity.Frog;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Wolf;
import org.bukkit.generator.structure.Structure;
import org.bukkit.generator.structure.StructureType;
import org.bukkit.inventory.ItemType;
import org.bukkit.inventory.MenuType;
import org.bukkit.inventory.meta.trim.TrimMaterial;
import org.bukkit.inventory.meta.trim.TrimPattern;
import org.bukkit.map.MapCursor;
import org.bukkit.potion.PotionEffectType;
public interface Generators {
SourceGenerator[] API = {
// built-ins
simpleKey("GameEventKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT, true),
simpleKey("StructureTypeKeys", StructureType.class, Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, false),
simpleKey("MobEffectKeys", PotionEffectType.class, Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, false),
simpleKey("BlockTypeKeys", BlockType.class, Registries.BLOCK, RegistryKey.BLOCK, false),
simpleKey("ItemTypeKeys", ItemType.class, Registries.ITEM, RegistryKey.ITEM, false),
simpleKey("CatVariantKeys", Cat.Type.class, Registries.CAT_VARIANT, RegistryKey.CAT_VARIANT, false),
simpleKey("FrogVariantKeys", Frog.Variant.class, Registries.FROG_VARIANT, RegistryKey.FROG_VARIANT, false),
simpleKey("VillagerProfessionKeys", Villager.Profession.class, Registries.VILLAGER_PROFESSION, RegistryKey.VILLAGER_PROFESSION, false),
simpleKey("VillagerTypeKeys", Villager.Type.class, Registries.VILLAGER_TYPE, RegistryKey.VILLAGER_TYPE, false),
simpleKey("MapDecorationTypeKeys", MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, RegistryKey.MAP_DECORATION_TYPE, false),
simpleKey("MenuTypeKeys", MenuType.class, Registries.MENU, RegistryKey.MENU, false),
simpleKey("AttributeKeys", Attribute.class, Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, false),
simpleKey("FluidKeys", Fluid.class, Registries.FLUID, RegistryKey.FLUID, false),
simpleKey("SoundEventKeys", Sound.class, Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT, false),
// data-driven
simpleKey("BiomeKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME, true),
simpleKey("StructureKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE, true),
simpleKey("TrimMaterialKeys", TrimMaterial.class, Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL, true),
simpleKey("TrimPatternKeys", TrimPattern.class, Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, true),
simpleKey("DamageTypeKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, true),
simpleKey("WolfVariantKeys", Wolf.Variant.class, Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, true),
simpleKey("EnchantmentKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, true),
simpleKey("JukeboxSongKeys", JukeboxSong.class, Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, true),
simpleKey("BannerPatternKeys", PatternType.class, Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, true),
simpleKey("PaintingVariantKeys", Art.class, Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, true),
simpleKey("InstrumentKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT, true),
// tags
simpleTagKey("GameEventTagKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT),
simpleTagKey("BlockTypeTagKeys", BlockType.class, Registries.BLOCK, RegistryKey.BLOCK),
simpleTagKey("ItemTypeTagKeys", ItemType.class, Registries.ITEM, RegistryKey.ITEM),
simpleTagKey("CatVariantTagKeys", Cat.Type.class, Registries.CAT_VARIANT, RegistryKey.CAT_VARIANT),
simpleTagKey("FluidTagKeys", Fluid.class, Registries.FLUID, RegistryKey.FLUID),
simpleTagKey("BiomeTagKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME),
simpleTagKey("StructureTagKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE),
simpleTagKey("DamageTypeTagKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE),
simpleTagKey("EnchantmentTagKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT),
simpleTagKey("BannerPatternTagKeys", PatternType.class, Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN),
simpleTagKey("PaintingVariantTagKeys", Art.class, Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT),
simpleTagKey("InstrumentTagKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT),
new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai")
};
private static <T, A> SourceGenerator simpleKey(final String className, final Class<A> apiType, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
return new GeneratedKeyType<>(className, apiType, "io.papermc.paper.registry.keys", registryKey, apiRegistryKey, publicCreateKeyMethod);
}
private static <T, A> SourceGenerator simpleTagKey(final String className, final Class<A> apiType, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey) {
return new GeneratedTagKeyType<>(className, apiType, "io.papermc.paper.registry.keys.tags", registryKey, apiRegistryKey, true);
}
}

View File

@ -1,93 +0,0 @@
package io.papermc.generator;
import com.google.common.util.concurrent.MoreExecutors;
import com.mojang.logging.LogUtils;
import io.papermc.generator.types.SourceGenerator;
import io.papermc.generator.utils.TagCollector;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import net.minecraft.SharedConstants;
import net.minecraft.commands.Commands;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.LayeredRegistryAccess;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.RegistryDataLoader;
import net.minecraft.server.Bootstrap;
import net.minecraft.server.RegistryLayer;
import net.minecraft.server.ReloadableServerResources;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackRepository;
import net.minecraft.server.packs.repository.ServerPacksSource;
import net.minecraft.server.packs.resources.MultiPackResourceManager;
import net.minecraft.tags.TagKey;
import net.minecraft.tags.TagLoader;
import net.minecraft.world.flag.FeatureFlags;
import org.apache.commons.io.file.PathUtils;
import org.slf4j.Logger;
public final class Main {
private static final Logger LOGGER = LogUtils.getLogger();
public static final RegistryAccess.Frozen REGISTRY_ACCESS;
public static final Map<TagKey<?>, String> EXPERIMENTAL_TAGS;
static {
SharedConstants.tryDetectVersion();
Bootstrap.bootStrap();
Bootstrap.validate();
final PackRepository resourceRepository = ServerPacksSource.createVanillaTrustedRepository();
resourceRepository.reload();
final MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().map(Pack::open).toList());
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
final List<Registry.PendingTags<?>> pendingTags = TagLoader.loadTagsForExistingRegistries(resourceManager, layers.getLayer(RegistryLayer.STATIC));
final List<HolderLookup.RegistryLookup<?>> worldGenLayer = TagLoader.buildUpdatedLookups(layers.getAccessForLoading(RegistryLayer.WORLDGEN), pendingTags);
final RegistryAccess.Frozen frozenWorldgenRegistries = RegistryDataLoader.load(resourceManager, worldGenLayer, RegistryDataLoader.WORLDGEN_REGISTRIES);
layers = layers.replaceFrom(RegistryLayer.WORLDGEN, frozenWorldgenRegistries);
REGISTRY_ACCESS = layers.compositeAccess().freeze();
final ReloadableServerResources reloadableServerResources = ReloadableServerResources.loadResources(
resourceManager,
layers,
pendingTags,
FeatureFlags.VANILLA_SET,
Commands.CommandSelection.DEDICATED,
0,
MoreExecutors.directExecutor(),
MoreExecutors.directExecutor()
).join();
reloadableServerResources.updateStaticRegistryTags();
EXPERIMENTAL_TAGS = TagCollector.grabExperimental(resourceManager);
}
private Main() {
}
public static void main(final String[] args) {
LOGGER.info("Running API generators...");
generate(Paths.get(args[0]), Generators.API);
// LOGGER.info("Running Server generators...");
// generate(Paths.get(args[1]), Generators.SERVER);
}
private static void generate(Path output, SourceGenerator[] generators) {
try {
if (Files.exists(output)) {
PathUtils.deleteDirectory(output);
}
Files.createDirectories(output);
for (final SourceGenerator generator : generators) {
generator.writeToFile(output);
}
LOGGER.info("Files written to {}", output.toAbsolutePath());
} catch (final Exception ex) {
throw new RuntimeException(ex);
}
}
}

View File

@ -1,210 +0,0 @@
package io.papermc.generator.types;
import com.google.common.collect.Sets;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import io.papermc.generator.Main;
import io.papermc.generator.utils.Annotations;
import io.papermc.generator.utils.CollectingContext;
import io.papermc.generator.utils.Formatting;
import io.papermc.generator.utils.Javadocs;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.TypedKey;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.lang.model.SourceVersion;
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.core.registries.Registries;
import net.minecraft.data.registries.VanillaRegistries;
import net.minecraft.data.registries.WinterDropRegistries;
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;
import org.checkerframework.framework.qual.DefaultQualifier;
import static com.squareup.javapoet.TypeSpec.classBuilder;
import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION;
import static io.papermc.generator.utils.Annotations.experimentalAnnotations;
import static java.util.Objects.requireNonNull;
import static javax.lang.model.element.Modifier.FINAL;
import static javax.lang.model.element.Modifier.PRIVATE;
import static javax.lang.model.element.Modifier.PUBLIC;
import static javax.lang.model.element.Modifier.STATIC;
@DefaultQualifier(NonNull.class)
public class GeneratedKeyType<T, A> extends SimpleGenerator {
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> VANILLA_REGISTRY_ENTRIES = VanillaRegistries.BUILDER.entries.stream()
.collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap));
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> EXPERIMENTAL_REGISTRY_ENTRIES = WinterDropRegistries.BUILDER.entries.stream()
.collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap)); // Update for Experimental API
private static final Map<RegistryKey<?>, String> REGISTRY_KEY_FIELD_NAMES;
static {
final Map<RegistryKey<?>, String> map = new HashMap<>();
try {
for (final Field field : RegistryKey.class.getFields()) {
if (!Modifier.isStatic(field.getModifiers()) || !Modifier.isFinal(field.getModifiers()) || field.getType() != RegistryKey.class) {
continue;
}
map.put((RegistryKey<?>) field.get(null), field.getName());
}
REGISTRY_KEY_FIELD_NAMES = Map.copyOf(map);
} catch (final ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
}
private static final String CREATE_JAVADOC = """
Creates a key for {@link $T} in the registry {@code $L}.
@param key the value's key in the registry
@return a new typed key
""";
private final Class<A> apiType;
private final ResourceKey<? extends Registry<T>> registryKey;
private final RegistryKey<A> apiRegistryKey;
private final boolean publicCreateKeyMethod;
public GeneratedKeyType(final String keysClassName, final Class<A> apiType, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
super(keysClassName, pkg);
this.apiType = apiType;
this.registryKey = registryKey;
this.apiRegistryKey = apiRegistryKey;
this.publicCreateKeyMethod = publicCreateKeyMethod;
}
private MethodSpec.Builder createMethod(final TypeName returnType) {
final TypeName keyType = TypeName.get(Key.class);
final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build();
final MethodSpec.Builder create = MethodSpec.methodBuilder("create")
.addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC)
.addParameter(keyParam)
.addCode("return $T.create($T.$L, $N);", TypedKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam)
.returns(returnType);
if (this.publicCreateKeyMethod) {
create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental
create.addJavadoc(CREATE_JAVADOC, this.apiType, this.registryKey.location().toString());
}
return create;
}
private TypeSpec.Builder keyHolderType() {
return classBuilder(this.className)
.addModifiers(PUBLIC, FINAL)
.addJavadoc(Javadocs.getVersionDependentClassHeader("{@link $T#$L}"), RegistryKey.class, REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey))
.addAnnotations(Annotations.CLASS_HEADER)
.addMethod(MethodSpec.constructorBuilder()
.addModifiers(PRIVATE)
.build()
);
}
@Deprecated
private static final Map<String, String> JUKEBOX_SONG_NAMES = Map.of(
"5", "FIVE",
"11", "ELEVEN",
"13", "THIRTEEN"
);
@Override
protected TypeSpec getTypeSpec() {
final TypeName typedKey = ParameterizedTypeName.get(TypedKey.class, this.apiType);
final TypeSpec.Builder typeBuilder = this.keyHolderType();
final MethodSpec.Builder createMethod = this.createMethod(typedKey);
final Registry<T> registry = Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey);
final Set<ResourceKey<T>> experimental = this.collectExperimentalKeys(registry);
boolean allExperimental = true;
for (final Holder.Reference<T> reference : registry.listElements().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).toList()) {
final ResourceKey<T> key = reference.key();
final String keyPath = key.location().getPath();
String fieldName = Formatting.formatKeyAsField(keyPath);
if (!SourceVersion.isIdentifier(fieldName) && this.registryKey.equals(Registries.JUKEBOX_SONG) && JUKEBOX_SONG_NAMES.containsKey(fieldName)) {
fieldName = JUKEBOX_SONG_NAMES.get(fieldName);
}
final FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKey, fieldName, PUBLIC, STATIC, FINAL)
.initializer("$N(key($S))", createMethod.build(), keyPath)
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString());
if (experimental.contains(key)) {
fieldBuilder.addAnnotations(experimentalAnnotations(MinecraftExperimental.Requires.WINTER_DROP)); // Update for Experimental API
} else {
allExperimental = false;
}
typeBuilder.addField(fieldBuilder.build());
}
if (allExperimental) {
typeBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
createMethod.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
} else {
typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO experimental API
}
return typeBuilder.addMethod(createMethod.build()).build();
}
// todo at some point this should be per feature data pack not all merged
private Set<ResourceKey<T>> collectExperimentalKeys(final Registry<T> registry) {
if (FeatureElement.FILTERED_REGISTRIES.contains(registry.key())) {
return this.collectExperimentalKeysBuiltIn(registry);
} else {
return this.collectExperimentalKeysDataDriven(registry);
}
}
private Set<ResourceKey<T>> collectExperimentalKeysBuiltIn(final Registry<T> registry) {
final HolderLookup.RegistryLookup<T> filteredLookup = registry.filterElements(v -> {
return v instanceof final FeatureElement featureElement && FeatureFlags.isExperimental(featureElement.requiredFeatures()); // Update for Experimental API
});
return filteredLookup.listElementIds().collect(Collectors.toUnmodifiableSet());
}
@SuppressWarnings("unchecked")
private Set<ResourceKey<T>> collectExperimentalKeysDataDriven(final Registry<T> registry) {
final RegistrySetBuilder.@Nullable RegistryBootstrap<T> experimentalBootstrap = (RegistrySetBuilder.RegistryBootstrap<T>) EXPERIMENTAL_REGISTRY_ENTRIES.get(this.registryKey);
if (experimentalBootstrap == null) {
return Collections.emptySet();
}
final Set<ResourceKey<T>> experimental = Collections.newSetFromMap(new IdentityHashMap<>());
final CollectingContext<T> experimentalCollector = new CollectingContext<>(experimental, registry);
experimentalBootstrap.run(experimentalCollector);
final RegistrySetBuilder.@Nullable RegistryBootstrap<T> vanillaBootstrap = (RegistrySetBuilder.RegistryBootstrap<T>) VANILLA_REGISTRY_ENTRIES.get(this.registryKey);
if (vanillaBootstrap != null) {
final Set<ResourceKey<T>> vanilla = Collections.newSetFromMap(new IdentityHashMap<>());
final CollectingContext<T> vanillaCollector = new CollectingContext<>(vanilla, registry);
vanillaBootstrap.run(vanillaCollector);
return Sets.difference(experimental, vanilla);
}
return experimental;
}
@Override
protected JavaFile.Builder file(final JavaFile.Builder builder) {
return builder
.addStaticImport(Key.class, "key");
}
}

View File

@ -1,138 +0,0 @@
package io.papermc.generator.types;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import io.papermc.generator.Main;
import io.papermc.generator.utils.Annotations;
import io.papermc.generator.utils.Formatting;
import io.papermc.generator.utils.Javadocs;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.tag.TagKey;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import net.kyori.adventure.key.Key;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import org.bukkit.MinecraftExperimental;
import static com.squareup.javapoet.TypeSpec.classBuilder;
import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION;
import static io.papermc.generator.utils.Annotations.experimentalAnnotations;
import static java.util.Objects.requireNonNull;
import static javax.lang.model.element.Modifier.FINAL;
import static javax.lang.model.element.Modifier.PRIVATE;
import static javax.lang.model.element.Modifier.PUBLIC;
import static javax.lang.model.element.Modifier.STATIC;
public class GeneratedTagKeyType<T, A> extends SimpleGenerator {
private static final Map<RegistryKey<?>, String> REGISTRY_KEY_FIELD_NAMES;
static {
final Map<RegistryKey<?>, String> map = new HashMap<>();
try {
for (final Field field : RegistryKey.class.getFields()) {
if (!Modifier.isStatic(field.getModifiers()) || !Modifier.isFinal(field.getModifiers()) || field.getType() != RegistryKey.class) {
continue;
}
map.put((RegistryKey<?>) field.get(null), field.getName());
}
REGISTRY_KEY_FIELD_NAMES = Map.copyOf(map);
} catch (final ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
}
private static final String CREATE_JAVADOC = """
Creates a tag key for {@link $T} in the registry {@code $L}.
@param key the tag key's key
@return a new tag key
""";
private final Class<A> apiType;
private final ResourceKey<? extends Registry<T>> registryKey;
private final RegistryKey<A> apiRegistryKey;
private final boolean publicCreateKeyMethod;
public GeneratedTagKeyType(final String keysClassName, final Class<A> apiType, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
super(keysClassName, pkg);
this.apiType = apiType;
this.registryKey = registryKey;
this.apiRegistryKey = apiRegistryKey;
this.publicCreateKeyMethod = publicCreateKeyMethod;
}
private MethodSpec.Builder createMethod(final TypeName returnType) {
final TypeName keyType = TypeName.get(Key.class);
final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build();
final MethodSpec.Builder create = MethodSpec.methodBuilder("create")
.addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC)
.addParameter(keyParam)
.addCode("return $T.create($T.$L, $N);", TagKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam)
.returns(returnType);
if (this.publicCreateKeyMethod) {
create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental
create.addJavadoc(CREATE_JAVADOC, this.apiType, this.registryKey.location().toString());
}
return create;
}
private TypeSpec.Builder keyHolderType() {
return classBuilder(this.className)
.addModifiers(PUBLIC, FINAL)
.addJavadoc(Javadocs.getVersionDependentClassHeader("{@link $T#$L}"), RegistryKey.class, REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey))
.addAnnotations(Annotations.CLASS_HEADER)
.addMethod(MethodSpec.constructorBuilder()
.addModifiers(PRIVATE)
.build()
);
}
@Override
protected TypeSpec getTypeSpec() {
final TypeName tagKey = ParameterizedTypeName.get(TagKey.class, this.apiType);
final TypeSpec.Builder typeBuilder = this.keyHolderType();
final MethodSpec.Builder createMethod = this.createMethod(tagKey);
final Registry<T> registry = Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey);
final AtomicBoolean allExperimental = new AtomicBoolean(true);
registry.listTagIds().sorted(Formatting.alphabeticKeyOrder(nmsTagKey -> nmsTagKey.location().getPath())).forEach(nmsTagKey -> {
final String fieldName = Formatting.formatKeyAsField(nmsTagKey.location().getPath());
final FieldSpec.Builder fieldBuilder = FieldSpec.builder(tagKey, fieldName, PUBLIC, STATIC, FINAL)
.initializer("$N(key($S))", createMethod.build(), nmsTagKey.location().getPath())
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), "#" + nmsTagKey.location());
final String featureFlagName = Main.EXPERIMENTAL_TAGS.get(nmsTagKey);
if (featureFlagName != null) {
fieldBuilder.addAnnotations(experimentalAnnotations(MinecraftExperimental.Requires.valueOf(featureFlagName.toUpperCase(Locale.ENGLISH)))); // Update for Experimental API
} else {
allExperimental.set(false);
}
typeBuilder.addField(fieldBuilder.build());
});
if (allExperimental.get()) {
typeBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
createMethod.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
} else {
typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO experimental API
}
return typeBuilder.addMethod(createMethod.build()).build();
}
@Override
protected JavaFile.Builder file(final JavaFile.Builder builder) {
return builder
.addStaticImport(Key.class, "key");
}
}

View File

@ -1,65 +0,0 @@
package io.papermc.generator.utils;
import com.squareup.javapoet.AnnotationSpec;
import java.util.ArrayList;
import java.util.List;
import io.papermc.paper.generated.GeneratedFrom;
import net.minecraft.SharedConstants;
import org.bukkit.MinecraftExperimental;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
public final class Annotations {
public static List<AnnotationSpec> experimentalAnnotations(final MinecraftExperimental.@Nullable Requires requiredFeatureFlag) {
final List<AnnotationSpec> annotationSpecs = new ArrayList<>();
annotationSpecs.add(AnnotationSpec.builder(ApiStatus.Experimental.class).build());
if (requiredFeatureFlag != null) {
annotationSpecs.add(AnnotationSpec.builder(MinecraftExperimental.class)
.addMember("value", "$T.$L", MinecraftExperimental.Requires.class, requiredFeatureFlag.name())
.build());
} else {
annotationSpecs.add(AnnotationSpec.builder(MinecraftExperimental.class).build());
}
return annotationSpecs;
}
public static AnnotationSpec deprecatedVersioned(final @Nullable String version, final boolean forRemoval) {
final AnnotationSpec.Builder annotationSpec = AnnotationSpec.builder(Deprecated.class);
if (forRemoval) {
annotationSpec.addMember("forRemoval", "$L", true);
}
if (version != null) {
annotationSpec.addMember("since", "$S", version);
}
return annotationSpec.build();
}
public static AnnotationSpec scheduledRemoval(final @Nullable String version) {
return AnnotationSpec.builder(ApiStatus.ScheduledForRemoval.class)
.addMember("inVersion", "$S", version)
.build();
}
@ApiStatus.Experimental
public static final AnnotationSpec EXPERIMENTAL_API_ANNOTATION = AnnotationSpec.builder(ApiStatus.Experimental.class).build();
public static final AnnotationSpec NULL_MARKED = AnnotationSpec.builder(NullMarked.class).build();
private static final AnnotationSpec SUPPRESS_WARNINGS = AnnotationSpec.builder(SuppressWarnings.class)
.addMember("value", "$S", "unused")
.addMember("value", "$S", "SpellCheckingInspection")
.build();
private static final AnnotationSpec GENERATED_FROM = AnnotationSpec.builder(GeneratedFrom.class)
.addMember("value", "$S", SharedConstants.getCurrentVersion().getName())
.build();
public static final Iterable<AnnotationSpec> CLASS_HEADER = List.of(
SUPPRESS_WARNINGS,
GENERATED_FROM,
NULL_MARKED
);
private Annotations() {
}
}

View File

@ -1,59 +0,0 @@
package io.papermc.generator.utils;
import java.util.Optional;
import org.apache.commons.lang3.math.NumberUtils;
import java.util.Comparator;
import java.util.Locale;
import java.util.OptionalInt;
import java.util.function.Function;
import java.util.regex.Pattern;
public final class Formatting {
private static final Pattern ILLEGAL_FIELD_CHARACTERS = Pattern.compile("[.-/]");
public static String formatKeyAsField(String path) {
return ILLEGAL_FIELD_CHARACTERS.matcher(path.toUpperCase(Locale.ROOT)).replaceAll("_");
}
public static Optional<String> formatTagKey(String tagDir, String resourcePath) {
int tagsIndex = resourcePath.indexOf(tagDir);
int dotIndex = resourcePath.lastIndexOf('.');
if (tagsIndex == -1 || dotIndex == -1) {
return Optional.empty();
}
return Optional.of(resourcePath.substring(tagsIndex + tagDir.length() + 1, dotIndex)); // namespace/tags/registry_key/[tag_key].json
}
public static Comparator<String> ALPHABETIC_KEY_ORDER = alphabeticKeyOrder(path -> path);
public static <T> Comparator<T> alphabeticKeyOrder(Function<T, String> mapper) {
return (o1, o2) -> {
String path1 = mapper.apply(o1);
String path2 = mapper.apply(o2);
OptionalInt trailingInt1 = tryParseTrailingInt(path1);
OptionalInt trailingInt2 = tryParseTrailingInt(path2);
if (trailingInt1.isPresent() && trailingInt2.isPresent()) {
return Integer.compare(trailingInt1.getAsInt(), trailingInt2.getAsInt());
}
return path1.compareTo(path2);
};
}
private static OptionalInt tryParseTrailingInt(String path) {
int delimiterIndex = path.lastIndexOf('_');
if (delimiterIndex != -1) {
String score = path.substring(delimiterIndex + 1);
if (NumberUtils.isDigits(score)) {
return OptionalInt.of(Integer.parseInt(score));
}
}
return OptionalInt.empty();
}
private Formatting() {
}
}

View File

@ -1,27 +0,0 @@
package io.papermc.generator.utils;
public final class Javadocs {
public static String getVersionDependentClassHeader(String headerIdentifier) {
return """
Vanilla keys for %s.
@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.
""".formatted(headerIdentifier);
}
public static String getVersionDependentField(String headerIdentifier) {
return """
%s
@apiNote This field is version-dependant and may be removed in future Minecraft versions
""".formatted(headerIdentifier);
}
private Javadocs() {
}
}

View File

@ -1,79 +0,0 @@
package io.papermc.generator.utils;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.mojang.logging.LogUtils;
import io.papermc.generator.Main;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.BuiltInPackSource;
import net.minecraft.server.packs.resources.MultiPackResourceManager;
import net.minecraft.tags.TagKey;
import org.slf4j.Logger;
// collect all the tags by grabbing the json from the data-packs
// another (probably) way is to hook into the data generator like the typed keys generator
public final class TagCollector {
private static final Logger LOGGER = LogUtils.getLogger();
public static Map<TagKey<?>, String> grabExperimental(final MultiPackResourceManager resourceManager) {
Map<TagKey<?>, String> result = new IdentityHashMap<>();
// collect all vanilla tags
Multimap<ResourceKey<? extends Registry<?>>, String> vanillaTags = HashMultimap.create();
PackResources vanillaPack = resourceManager.listPacks()
.filter(packResources -> packResources.packId().equals(BuiltInPackSource.VANILLA_ID))
.findFirst()
.orElseThrow();
collectFromPack(vanillaPack, (entry, path) -> vanillaTags.put(entry.key(), path));
// then distinct with other data-pack tags to know for sure newly created tags and so experimental one
resourceManager.listPacks().forEach(pack -> {
String packId = pack.packId();
if (packId.equals(BuiltInPackSource.VANILLA_ID)) return;
collectFromPack(pack, (entry, path) -> {
if (vanillaTags.get(entry.key()).contains(path)) {
return;
}
result.put(entry.value().listTagIds()
.filter(tagKey -> tagKey.location().getPath().equals(path))
.findFirst()
.orElseThrow(), packId);
});
});
return Collections.unmodifiableMap(result);
}
private static void collectFromPack(PackResources pack, BiConsumer<RegistryAccess.RegistryEntry<?>, String> output) {
Set<String> namespaces = pack.getNamespaces(PackType.SERVER_DATA);
for (String namespace : namespaces) {
Main.REGISTRY_ACCESS.registries().forEach(entry -> {
// this is probably expensive but can't find another way around and data-pack loader has similar logic
// the issue is that registry key can have parent/key (and custom folder too) but tag key can also have parent/key so parsing become a mess
// without having at least one of the two values
String tagDir = Registries.tagsDirPath(entry.key());
pack.listResources(PackType.SERVER_DATA, namespace, tagDir, (id, supplier) -> {
Formatting.formatTagKey(tagDir, id.getPath()).ifPresentOrElse(path -> output.accept(entry, path), () -> {
LOGGER.warn("Unable to parse the path: {}/{}/{}.json in the data-pack {} into a tag key", namespace, tagDir, id.getPath(), pack.packId());
});
});
});
}
}
private TagCollector() {
}
}

View File

@ -0,0 +1,6 @@
[*.java]
ij_java_generate_final_locals = false
ij_java_generate_final_parameters = false
[generated{Api,Server}/**/*.java]
ij_java_imports_layout = $*, |, *

View File

@ -0,0 +1,62 @@
import io.papermc.paperweight.PaperweightSourceGeneratorHelper
import io.papermc.paperweight.extension.PaperweightSourceGeneratorExt
plugins {
java
}
plugins.apply(PaperweightSourceGeneratorHelper::class)
extensions.configure(PaperweightSourceGeneratorExt::class) {
atFile.set(file("wideners.at"))
}
repositories {
mavenLocal() // todo publish typewriter somewhere
}
dependencies {
implementation("com.squareup:javapoet:1.13.0")
implementation(project(":paper-api"))
implementation("io.github.classgraph:classgraph:4.8.47")
implementation("org.jetbrains:annotations:24.1.0")
implementation("io.papermc.typewriter:typewriter:1.0-SNAPSHOT") {
isTransitive = false // paper-api already have everything
}
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
val generatedApiPath = file("generatedApi")
val generatedServerPath = file("generatedServer")
val generate by tasks.registering(JavaExec::class) {
dependsOn(tasks.check)
mainClass.set("io.papermc.generator.Main")
classpath(sourceSets.main.map { it.runtimeClasspath })
args(generatedApiPath.toString(),
project(":paper-api").sourceSets["main"].java.srcDirs.first().toString(),
generatedServerPath.toString(),
project(":paper-server").sourceSets["main"].java.srcDirs.first().toString())
}
generate.configure {
delete(generatedApiPath, generatedServerPath)
// the module depends on paper-api but generate into the project which cause conflict
// ideally this module would only depend on vanilla source in the long
// run
}
tasks.register<JavaExec>("scanOldGeneratedSourceCode") {
mainClass.set("io.papermc.generator.rewriter.OldGeneratedCodeTest")
classpath(sourceSets.test.map { it.runtimeClasspath })
args(generatedApiPath.toString(),
generatedServerPath.toString())
}
tasks.test {
useJUnitPlatform()
}
group = "io.papermc.paper"
version = "1.0-SNAPSHOT"

View File

@ -66,8 +66,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
public interface VanillaGoal<T extends Mob> extends Goal<T> {
GoalKey<AbstractHorse> RANDOM_STAND = create("random_stand", AbstractHorse.class);

View File

@ -0,0 +1,32 @@
package io.papermc.paper.registry.event;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.data.GameEventRegistryEntry;
import io.papermc.paper.registry.data.PaintingVariantRegistryEntry;
import org.bukkit.Art;
import org.bukkit.GameEvent;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
import static io.papermc.paper.registry.event.RegistryEventProviderImpl.create;
/**
* Holds providers for {@link RegistryEntryAddEvent} and {@link RegistryFreezeEvent}
* handlers for each applicable registry.
*/
@ApiStatus.Experimental
@NullMarked
public final class RegistryEvents {
// Paper start - Generated/RegistryEvents
// @GeneratedFrom 1.21.3
public static final RegistryEventProvider<GameEvent, GameEventRegistryEntry.Builder> GAME_EVENT = create(RegistryKey.GAME_EVENT);
public static final RegistryEventProvider<Enchantment, EnchantmentRegistryEntry.Builder> ENCHANTMENT = create(RegistryKey.ENCHANTMENT);
public static final RegistryEventProvider<Art, PaintingVariantRegistryEntry.Builder> PAINTING_VARIANT = create(RegistryKey.PAINTING_VARIANT);
// Paper end - Generated/RegistryEvents
private RegistryEvents() {
}
}

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class AttributeKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class BannerPatternKeys {
/**
@ -332,7 +332,7 @@ public final class BannerPatternKeys {
}
/**
* Creates a key for {@link PatternType} in the registry {@code minecraft:banner_pattern}.
* Creates a typed key for {@link PatternType} in the registry {@code minecraft:banner_pattern}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class BiomeKeys {
/**
@ -489,7 +489,7 @@ public final class BiomeKeys {
}
/**
* Creates a key for {@link Biome} in the registry {@code minecraft:worldgen/biome}.
* Creates a typed key for {@link Biome} in the registry {@code minecraft:worldgen/biome}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class BlockTypeKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class CatVariantKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class DamageTypeKeys {
/**
@ -374,7 +374,7 @@ public final class DamageTypeKeys {
}
/**
* Creates a key for {@link DamageType} in the registry {@code minecraft:damage_type}.
* Creates a typed key for {@link DamageType} in the registry {@code minecraft:damage_type}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -0,0 +1,505 @@
package io.papermc.paper.registry.keys;
import static net.kyori.adventure.key.Key.key;
import io.papermc.paper.datacomponent.DataComponentType;
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.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#DATA_COMPONENT_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"
})
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class DataComponentTypeKeys {
/**
* {@code minecraft:attribute_modifiers}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> ATTRIBUTE_MODIFIERS = create(key("attribute_modifiers"));
/**
* {@code minecraft:banner_patterns}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> BANNER_PATTERNS = create(key("banner_patterns"));
/**
* {@code minecraft:base_color}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> BASE_COLOR = create(key("base_color"));
/**
* {@code minecraft:bees}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> BEES = create(key("bees"));
/**
* {@code minecraft:block_entity_data}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> BLOCK_ENTITY_DATA = create(key("block_entity_data"));
/**
* {@code minecraft:block_state}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> BLOCK_STATE = create(key("block_state"));
/**
* {@code minecraft:bucket_entity_data}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> BUCKET_ENTITY_DATA = create(key("bucket_entity_data"));
/**
* {@code minecraft:bundle_contents}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> BUNDLE_CONTENTS = create(key("bundle_contents"));
/**
* {@code minecraft:can_break}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CAN_BREAK = create(key("can_break"));
/**
* {@code minecraft:can_place_on}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CAN_PLACE_ON = create(key("can_place_on"));
/**
* {@code minecraft:charged_projectiles}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CHARGED_PROJECTILES = create(key("charged_projectiles"));
/**
* {@code minecraft:consumable}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CONSUMABLE = create(key("consumable"));
/**
* {@code minecraft:container}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CONTAINER = create(key("container"));
/**
* {@code minecraft:container_loot}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CONTAINER_LOOT = create(key("container_loot"));
/**
* {@code minecraft:creative_slot_lock}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CREATIVE_SLOT_LOCK = create(key("creative_slot_lock"));
/**
* {@code minecraft:custom_data}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CUSTOM_DATA = create(key("custom_data"));
/**
* {@code minecraft:custom_model_data}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CUSTOM_MODEL_DATA = create(key("custom_model_data"));
/**
* {@code minecraft:custom_name}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> CUSTOM_NAME = create(key("custom_name"));
/**
* {@code minecraft:damage}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> DAMAGE = create(key("damage"));
/**
* {@code minecraft:damage_resistant}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> DAMAGE_RESISTANT = create(key("damage_resistant"));
/**
* {@code minecraft:death_protection}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> DEATH_PROTECTION = create(key("death_protection"));
/**
* {@code minecraft:debug_stick_state}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> DEBUG_STICK_STATE = create(key("debug_stick_state"));
/**
* {@code minecraft:dyed_color}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> DYED_COLOR = create(key("dyed_color"));
/**
* {@code minecraft:enchantable}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> ENCHANTABLE = create(key("enchantable"));
/**
* {@code minecraft:enchantment_glint_override}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> ENCHANTMENT_GLINT_OVERRIDE = create(key("enchantment_glint_override"));
/**
* {@code minecraft:enchantments}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> ENCHANTMENTS = create(key("enchantments"));
/**
* {@code minecraft:entity_data}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> ENTITY_DATA = create(key("entity_data"));
/**
* {@code minecraft:equippable}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> EQUIPPABLE = create(key("equippable"));
/**
* {@code minecraft:firework_explosion}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> FIREWORK_EXPLOSION = create(key("firework_explosion"));
/**
* {@code minecraft:fireworks}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> FIREWORKS = create(key("fireworks"));
/**
* {@code minecraft:food}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> FOOD = create(key("food"));
/**
* {@code minecraft:glider}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> GLIDER = create(key("glider"));
/**
* {@code minecraft:hide_additional_tooltip}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> HIDE_ADDITIONAL_TOOLTIP = create(key("hide_additional_tooltip"));
/**
* {@code minecraft:hide_tooltip}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> HIDE_TOOLTIP = create(key("hide_tooltip"));
/**
* {@code minecraft:instrument}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> INSTRUMENT = create(key("instrument"));
/**
* {@code minecraft:intangible_projectile}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> INTANGIBLE_PROJECTILE = create(key("intangible_projectile"));
/**
* {@code minecraft:item_model}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> ITEM_MODEL = create(key("item_model"));
/**
* {@code minecraft:item_name}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> ITEM_NAME = create(key("item_name"));
/**
* {@code minecraft:jukebox_playable}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> JUKEBOX_PLAYABLE = create(key("jukebox_playable"));
/**
* {@code minecraft:lock}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> LOCK = create(key("lock"));
/**
* {@code minecraft:lodestone_tracker}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> LODESTONE_TRACKER = create(key("lodestone_tracker"));
/**
* {@code minecraft:lore}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> LORE = create(key("lore"));
/**
* {@code minecraft:map_color}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> MAP_COLOR = create(key("map_color"));
/**
* {@code minecraft:map_decorations}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> MAP_DECORATIONS = create(key("map_decorations"));
/**
* {@code minecraft:map_id}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> MAP_ID = create(key("map_id"));
/**
* {@code minecraft:map_post_processing}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> MAP_POST_PROCESSING = create(key("map_post_processing"));
/**
* {@code minecraft:max_damage}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> MAX_DAMAGE = create(key("max_damage"));
/**
* {@code minecraft:max_stack_size}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> MAX_STACK_SIZE = create(key("max_stack_size"));
/**
* {@code minecraft:note_block_sound}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> NOTE_BLOCK_SOUND = create(key("note_block_sound"));
/**
* {@code minecraft:ominous_bottle_amplifier}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> OMINOUS_BOTTLE_AMPLIFIER = create(key("ominous_bottle_amplifier"));
/**
* {@code minecraft:pot_decorations}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> POT_DECORATIONS = create(key("pot_decorations"));
/**
* {@code minecraft:potion_contents}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> POTION_CONTENTS = create(key("potion_contents"));
/**
* {@code minecraft:profile}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> PROFILE = create(key("profile"));
/**
* {@code minecraft:rarity}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> RARITY = create(key("rarity"));
/**
* {@code minecraft:recipes}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> RECIPES = create(key("recipes"));
/**
* {@code minecraft:repair_cost}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> REPAIR_COST = create(key("repair_cost"));
/**
* {@code minecraft:repairable}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> REPAIRABLE = create(key("repairable"));
/**
* {@code minecraft:stored_enchantments}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> STORED_ENCHANTMENTS = create(key("stored_enchantments"));
/**
* {@code minecraft:suspicious_stew_effects}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> SUSPICIOUS_STEW_EFFECTS = create(key("suspicious_stew_effects"));
/**
* {@code minecraft:tool}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> TOOL = create(key("tool"));
/**
* {@code minecraft:tooltip_style}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> TOOLTIP_STYLE = create(key("tooltip_style"));
/**
* {@code minecraft:trim}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> TRIM = create(key("trim"));
/**
* {@code minecraft:unbreakable}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> UNBREAKABLE = create(key("unbreakable"));
/**
* {@code minecraft:use_cooldown}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> USE_COOLDOWN = create(key("use_cooldown"));
/**
* {@code minecraft:use_remainder}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> USE_REMAINDER = create(key("use_remainder"));
/**
* {@code minecraft:writable_book_content}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> WRITABLE_BOOK_CONTENT = create(key("writable_book_content"));
/**
* {@code minecraft:written_book_content}
*
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
*/
public static final TypedKey<DataComponentType> WRITTEN_BOOK_CONTENT = create(key("written_book_content"));
private DataComponentTypeKeys() {
}
private static TypedKey<DataComponentType> create(final Key key) {
return TypedKey.create(RegistryKey.DATA_COMPONENT_TYPE, key);
}
}

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class EnchantmentKeys {
/**
@ -325,7 +325,7 @@ public final class EnchantmentKeys {
}
/**
* Creates a key for {@link Enchantment} in the registry {@code minecraft:enchantment}.
* Creates a typed key for {@link Enchantment} in the registry {@code minecraft:enchantment}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class FluidKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class FrogVariantKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class GameEventKeys {
/**
@ -451,7 +451,7 @@ public final class GameEventKeys {
}
/**
* Creates a key for {@link GameEvent} in the registry {@code minecraft:game_event}.
* Creates a typed key for {@link GameEvent} in the registry {@code minecraft:game_event}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class InstrumentKeys {
/**
@ -87,7 +87,7 @@ public final class InstrumentKeys {
}
/**
* Creates a key for {@link MusicInstrument} in the registry {@code minecraft:instrument}.
* Creates a typed key for {@link MusicInstrument} in the registry {@code minecraft:instrument}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class ItemTypeKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class JukeboxSongKeys {
/**
@ -164,7 +164,7 @@ public final class JukeboxSongKeys {
}
/**
* Creates a key for {@link JukeboxSong} in the registry {@code minecraft:jukebox_song}.
* Creates a typed key for {@link JukeboxSong} in the registry {@code minecraft:jukebox_song}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class MapDecorationTypeKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class MenuTypeKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class MobEffectKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class PaintingVariantKeys {
/**
@ -381,7 +381,7 @@ public final class PaintingVariantKeys {
}
/**
* Creates a key for {@link Art} in the registry {@code minecraft:painting_variant}.
* Creates a typed key for {@link Art} in the registry {@code minecraft:painting_variant}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class SoundEventKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class StructureKeys {
/**
@ -269,7 +269,7 @@ public final class StructureKeys {
}
/**
* Creates a key for {@link Structure} in the registry {@code minecraft:worldgen/structure}.
* Creates a typed key for {@link Structure} in the registry {@code minecraft:worldgen/structure}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class StructureTypeKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class TrimMaterialKeys {
/**
@ -101,7 +101,7 @@ public final class TrimMaterialKeys {
}
/**
* Creates a key for {@link TrimMaterial} in the registry {@code minecraft:trim_material}.
* Creates a typed key for {@link TrimMaterial} in the registry {@code minecraft:trim_material}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class TrimPatternKeys {
/**
@ -157,7 +157,7 @@ public final class TrimPatternKeys {
}
/**
* Creates a key for {@link TrimPattern} in the registry {@code minecraft:trim_pattern}.
* Creates a typed key for {@link TrimPattern} in the registry {@code minecraft:trim_pattern}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class VillagerProfessionKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class VillagerTypeKeys {
/**

View File

@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class WolfVariantKeys {
/**
@ -94,7 +94,7 @@ public final class WolfVariantKeys {
}
/**
* Creates a key for {@link Wolf.Variant} in the registry {@code minecraft:wolf_variant}.
* Creates a typed key for {@link Wolf.Variant} in the registry {@code minecraft:wolf_variant}.
*
* @param key the value's key in the registry
* @return a new typed key

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#BANNER_PATTERN}.
* Vanilla tag keys for {@link RegistryKey#BANNER_PATTERN}.
*
* @apiNote The fields provided here are a direct representation of
* what is available from the vanilla game source. They may be
@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class BannerPatternTagKeys {
/**

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#BIOME}.
* Vanilla tag keys for {@link RegistryKey#BIOME}.
*
* @apiNote The fields provided here are a direct representation of
* what is available from the vanilla game source. They may be
@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class BiomeTagKeys {
/**

View File

@ -12,7 +12,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#BLOCK}.
* Vanilla tag keys for {@link RegistryKey#BLOCK}.
*
* @apiNote The fields provided here are a direct representation of
* what is available from the vanilla game source. They may be
@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class BlockTypeTagKeys {
/**

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#CAT_VARIANT}.
* Vanilla tag keys for {@link RegistryKey#CAT_VARIANT}.
*
* @apiNote The fields provided here are a direct representation of
* what is available from the vanilla game source. They may be
@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class CatVariantTagKeys {
/**

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#DAMAGE_TYPE}.
* Vanilla tag 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
@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class DamageTypeTagKeys {
/**

View File

@ -12,7 +12,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#ENCHANTMENT}.
* Vanilla tag 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
@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class EnchantmentTagKeys {
/**

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#FLUID}.
* Vanilla tag keys for {@link RegistryKey#FLUID}.
*
* @apiNote The fields provided here are a direct representation of
* what is available from the vanilla game source. They may be
@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class FluidTagKeys {
/**

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#GAME_EVENT}.
* Vanilla tag keys for {@link RegistryKey#GAME_EVENT}.
*
* @apiNote The fields provided here are a direct representation of
* what is available from the vanilla game source. They may be
@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class GameEventTagKeys {
/**

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#INSTRUMENT}.
* Vanilla tag 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
@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class InstrumentTagKeys {
/**

View File

@ -12,7 +12,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#ITEM}.
* Vanilla tag keys for {@link RegistryKey#ITEM}.
*
* @apiNote The fields provided here are a direct representation of
* what is available from the vanilla game source. They may be
@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class ItemTypeTagKeys {
/**

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#PAINTING_VARIANT}.
* Vanilla tag keys for {@link RegistryKey#PAINTING_VARIANT}.
*
* @apiNote The fields provided here are a direct representation of
* what is available from the vanilla game source. They may be
@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class PaintingVariantTagKeys {
/**

View File

@ -12,7 +12,7 @@ import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Vanilla keys for {@link RegistryKey#STRUCTURE}.
* Vanilla tag 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
@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked;
"unused",
"SpellCheckingInspection"
})
@GeneratedFrom("1.21.3")
@NullMarked
@GeneratedFrom("1.21.3")
@ApiStatus.Experimental
public final class StructureTagKeys {
/**

View File

@ -0,0 +1,242 @@
package org.bukkit;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.packs.DataPack;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents the art on a painting.
* <p>
* The arts listed in this interface are present in the default server
* or can be enabled via a {@link FeatureFlag}.
* There may be additional arts present in the server, for example from a {@link DataPack}
* which can be accessed via {@link Registry#ART}.
*/
public interface Art extends OldEnum<Art>, Keyed {
// Paper start - Generated/Art
// @GeneratedFrom 1.21.3
Art ALBAN = getArt("alban");
Art AZTEC = getArt("aztec");
Art AZTEC2 = getArt("aztec2");
Art BACKYARD = getArt("backyard");
Art BAROQUE = getArt("baroque");
Art BOMB = getArt("bomb");
Art BOUQUET = getArt("bouquet");
Art BURNING_SKULL = getArt("burning_skull");
Art BUST = getArt("bust");
Art CAVEBIRD = getArt("cavebird");
Art CHANGING = getArt("changing");
Art COTAN = getArt("cotan");
Art COURBET = getArt("courbet");
Art CREEBET = getArt("creebet");
Art DONKEY_KONG = getArt("donkey_kong");
Art EARTH = getArt("earth");
Art ENDBOSS = getArt("endboss");
Art FERN = getArt("fern");
Art FIGHTERS = getArt("fighters");
Art FINDING = getArt("finding");
Art FIRE = getArt("fire");
Art GRAHAM = getArt("graham");
Art HUMBLE = getArt("humble");
Art KEBAB = getArt("kebab");
Art LOWMIST = getArt("lowmist");
Art MATCH = getArt("match");
Art MEDITATIVE = getArt("meditative");
Art ORB = getArt("orb");
Art OWLEMONS = getArt("owlemons");
Art PASSAGE = getArt("passage");
Art PIGSCENE = getArt("pigscene");
Art PLANT = getArt("plant");
Art POINTER = getArt("pointer");
Art POND = getArt("pond");
Art POOL = getArt("pool");
Art PRAIRIE_RIDE = getArt("prairie_ride");
Art SEA = getArt("sea");
Art SKELETON = getArt("skeleton");
Art SKULL_AND_ROSES = getArt("skull_and_roses");
Art STAGE = getArt("stage");
Art SUNFLOWERS = getArt("sunflowers");
Art SUNSET = getArt("sunset");
Art TIDES = getArt("tides");
Art UNPACKED = getArt("unpacked");
Art VOID = getArt("void");
Art WANDERER = getArt("wanderer");
Art WASTELAND = getArt("wasteland");
Art WATER = getArt("water");
Art WIND = getArt("wind");
Art WITHER = getArt("wither");
// Paper end - Generated/Art
@NotNull
private static Art getArt(@NotNull String key) {
return Registry.ART.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* Gets the width of the painting, in blocks
*
* @return The width of the painting, in blocks
*/
int getBlockWidth();
/**
* Gets the height of the painting, in blocks
*
* @return The height of the painting, in blocks
*/
int getBlockHeight();
/**
* Get the ID of this painting.
*
* @return The ID of this painting
* @deprecated Magic value
*/
@Deprecated(since = "1.6.2")
int getId();
// Paper start - deprecate getKey
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#PAINTING_VARIANT}. Painting variants can exist without a key.
*/
@Deprecated(since = "1.21")
@Override
@NotNull NamespacedKey getKey();
// Paper end - deprecate getKey
// Paper start - name and author components, assetId key
/**
* Get the painting's title.
*
* @return the title
*/
net.kyori.adventure.text.@Nullable Component title();
/**
* Get the painting's author.
*
* @return the author
*/
net.kyori.adventure.text.@Nullable Component author();
/**
* Get the painting's asset id
*
* @return the asset id
*/
net.kyori.adventure.key.@NotNull Key assetId();
// Paper end - name and author components, assetId key
/**
* Get a painting by its numeric ID
*
* @param id The ID
* @return The painting
* @deprecated Magic value
*/
@Deprecated(since = "1.6.2")
@Nullable
static Art getById(int id) {
for (Art art : Registry.ART) {
if (id == art.getId()) {
return art;
}
}
return null;
}
/**
* Get a painting by its unique name
* <p>
* This ignores capitalization
*
* @param name The name
* @return The painting
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@Deprecated(since = "1.21.3")
@Nullable
static Art getByName(@NotNull String name) {
Preconditions.checkArgument(name != null, "Name cannot be null");
return Bukkit.getUnsafe().get(Registry.ART, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
}
/**
* @param name of the art.
* @return the art with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21.3")
static Art valueOf(@NotNull String name) {
Art art = Bukkit.getUnsafe().get(Registry.ART, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(art != null, "No art found with the name %s", name);
return art;
}
/**
* @return an array of all known arts.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21.3")
static Art[] values() {
return Lists.newArrayList(Registry.ART).toArray(new Art[0]);
}
}

View File

@ -0,0 +1,57 @@
package org.bukkit;
// Paper start - overhaul FeatureFlag API
import com.google.common.base.Preconditions;
import java.util.List;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.util.Index;
import org.intellij.lang.annotations.Subst;
// Paper end - overhaul FeatureFlag API
import org.jetbrains.annotations.ApiStatus;
/**
* This represents a Feature Flag for a {@link io.papermc.paper.world.flag.FeatureFlagSetHolder}.
*/
public interface FeatureFlag extends Keyed {
// Paper start - overhaul FeatureFlag API
// Paper start - Generated/FeatureFlag
// @GeneratedFrom 1.21.3
@ApiStatus.Experimental
FeatureFlag MINECART_IMPROVEMENTS = create("minecart_improvements");
@ApiStatus.Experimental
FeatureFlag REDSTONE_EXPERIMENTS = create("redstone_experiments");
@ApiStatus.Experimental
FeatureFlag TRADE_REBALANCE = create("trade_rebalance");
FeatureFlag VANILLA = create("vanilla");
@ApiStatus.Experimental
FeatureFlag WINTER_DROP = create("winter_drop");
// Paper end - Generated/FeatureFlag
@Deprecated(since = "1.20")
FeatureFlag UPDATE_1_20 = deprecated("update_1_20");
@Deprecated(since = "1.21")
FeatureFlag UPDATE_121 = deprecated("update_1_21");
/**
* An index of all feature flags.
*/
Index<Key, FeatureFlag> ALL_FLAGS = Index.create(FeatureFlag::key, List.copyOf(FeatureFlagImpl.ALL_FLAGS));
private static FeatureFlag create(@Subst("vanilla") final String name) {
final FeatureFlag flag = new FeatureFlagImpl(NamespacedKey.minecraft(name));
Preconditions.checkState(FeatureFlagImpl.ALL_FLAGS.add(flag), "Tried to add duplicate feature flag: " + name);
return flag;
}
private static FeatureFlag deprecated(@Subst("vanilla") final String name) {
return new FeatureFlagImpl.Deprecated(NamespacedKey.minecraft(name));
}
// Paper end - overhaul FeatureFlag API
}

View File

@ -0,0 +1,54 @@
package org.bukkit;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
/**
* Represents a fluid type.
*/
public interface Fluid extends OldEnum<Fluid>, Keyed {
// Paper start - Generated/Fluid
// @GeneratedFrom 1.21.3
Fluid EMPTY = getFluid("empty");
Fluid FLOWING_LAVA = getFluid("flowing_lava");
Fluid FLOWING_WATER = getFluid("flowing_water");
Fluid LAVA = getFluid("lava");
Fluid WATER = getFluid("water");
// Paper end - Generated/Fluid
@NotNull
private static Fluid getFluid(@NotNull String key) {
return Registry.FLUID.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* @param name of the fluid.
* @return the fluid with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Fluid valueOf(@NotNull String name) {
Fluid fluid = Bukkit.getUnsafe().get(Registry.FLUID, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(fluid != null, "No fluid found with the name %s", name);
return fluid;
}
/**
* @return an array of all known fluids.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Fluid[] values() {
return Lists.newArrayList(Registry.FLUID).toArray(new Fluid[0]);
}
}

View File

@ -0,0 +1,224 @@
package org.bukkit;
import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.Collections;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a generic Mojang game event.
*/
public abstract class GameEvent implements Keyed {
// Paper start - Generated/GameEvent
// @GeneratedFrom 1.21.3
public static final GameEvent BLOCK_ACTIVATE = getEvent("block_activate");
public static final GameEvent BLOCK_ATTACH = getEvent("block_attach");
public static final GameEvent BLOCK_CHANGE = getEvent("block_change");
public static final GameEvent BLOCK_CLOSE = getEvent("block_close");
public static final GameEvent BLOCK_DEACTIVATE = getEvent("block_deactivate");
public static final GameEvent BLOCK_DESTROY = getEvent("block_destroy");
public static final GameEvent BLOCK_DETACH = getEvent("block_detach");
public static final GameEvent BLOCK_OPEN = getEvent("block_open");
public static final GameEvent BLOCK_PLACE = getEvent("block_place");
public static final GameEvent CONTAINER_CLOSE = getEvent("container_close");
public static final GameEvent CONTAINER_OPEN = getEvent("container_open");
public static final GameEvent DRINK = getEvent("drink");
public static final GameEvent EAT = getEvent("eat");
public static final GameEvent ELYTRA_GLIDE = getEvent("elytra_glide");
public static final GameEvent ENTITY_ACTION = getEvent("entity_action");
public static final GameEvent ENTITY_DAMAGE = getEvent("entity_damage");
public static final GameEvent ENTITY_DIE = getEvent("entity_die");
public static final GameEvent ENTITY_DISMOUNT = getEvent("entity_dismount");
public static final GameEvent ENTITY_INTERACT = getEvent("entity_interact");
public static final GameEvent ENTITY_MOUNT = getEvent("entity_mount");
public static final GameEvent ENTITY_PLACE = getEvent("entity_place");
public static final GameEvent EQUIP = getEvent("equip");
public static final GameEvent EXPLODE = getEvent("explode");
public static final GameEvent FLAP = getEvent("flap");
public static final GameEvent FLUID_PICKUP = getEvent("fluid_pickup");
public static final GameEvent FLUID_PLACE = getEvent("fluid_place");
public static final GameEvent HIT_GROUND = getEvent("hit_ground");
public static final GameEvent INSTRUMENT_PLAY = getEvent("instrument_play");
public static final GameEvent ITEM_INTERACT_FINISH = getEvent("item_interact_finish");
public static final GameEvent ITEM_INTERACT_START = getEvent("item_interact_start");
public static final GameEvent JUKEBOX_PLAY = getEvent("jukebox_play");
public static final GameEvent JUKEBOX_STOP_PLAY = getEvent("jukebox_stop_play");
public static final GameEvent LIGHTNING_STRIKE = getEvent("lightning_strike");
public static final GameEvent NOTE_BLOCK_PLAY = getEvent("note_block_play");
public static final GameEvent PRIME_FUSE = getEvent("prime_fuse");
public static final GameEvent PROJECTILE_LAND = getEvent("projectile_land");
public static final GameEvent PROJECTILE_SHOOT = getEvent("projectile_shoot");
public static final GameEvent RESONATE_1 = getEvent("resonate_1");
public static final GameEvent RESONATE_2 = getEvent("resonate_2");
public static final GameEvent RESONATE_3 = getEvent("resonate_3");
public static final GameEvent RESONATE_4 = getEvent("resonate_4");
public static final GameEvent RESONATE_5 = getEvent("resonate_5");
public static final GameEvent RESONATE_6 = getEvent("resonate_6");
public static final GameEvent RESONATE_7 = getEvent("resonate_7");
public static final GameEvent RESONATE_8 = getEvent("resonate_8");
public static final GameEvent RESONATE_9 = getEvent("resonate_9");
public static final GameEvent RESONATE_10 = getEvent("resonate_10");
public static final GameEvent RESONATE_11 = getEvent("resonate_11");
public static final GameEvent RESONATE_12 = getEvent("resonate_12");
public static final GameEvent RESONATE_13 = getEvent("resonate_13");
public static final GameEvent RESONATE_14 = getEvent("resonate_14");
public static final GameEvent RESONATE_15 = getEvent("resonate_15");
public static final GameEvent SCULK_SENSOR_TENDRILS_CLICKING = getEvent("sculk_sensor_tendrils_clicking");
public static final GameEvent SHEAR = getEvent("shear");
public static final GameEvent SHRIEK = getEvent("shriek");
public static final GameEvent SPLASH = getEvent("splash");
public static final GameEvent STEP = getEvent("step");
public static final GameEvent SWIM = getEvent("swim");
public static final GameEvent TELEPORT = getEvent("teleport");
public static final GameEvent UNEQUIP = getEvent("unequip");
// Paper end - Generated/GameEvent
@Deprecated
public static final GameEvent BLOCK_PRESS = getEvent("block_activate");
@Deprecated
public static final GameEvent BLOCK_SWITCH = getEvent("block_activate");
@Deprecated
public static final GameEvent BLOCK_UNPRESS = getEvent("block_deactivate");
@Deprecated
public static final GameEvent BLOCK_UNSWITCH = getEvent("block_deactivate");
@Deprecated
public static final GameEvent DISPENSE_FAIL = getEvent("block_activate");
@Deprecated
public static final GameEvent DRINKING_FINISH = getEvent("drink");
@Deprecated
public static final GameEvent ELYTRA_FREE_FALL = getEvent("elytra_glide");
@Deprecated
public static final GameEvent ENTITY_DAMAGED = getEvent("entity_damage");
@Deprecated
public static final GameEvent ENTITY_DYING = getEvent("entity_die");
@Deprecated
public static final GameEvent ENTITY_KILLED = getEvent("entity_die");
@Deprecated
public static final GameEvent ENTITY_ROAR = getEvent("entity_action");
@Deprecated
public static final GameEvent ENTITY_SHAKE = getEvent("entity_action");
@Deprecated
public static final GameEvent MOB_INTERACT = getEvent("entity_interact");
@Deprecated
public static final GameEvent PISTON_CONTRACT = getEvent("block_deactivate");
@Deprecated
public static final GameEvent PISTON_EXTEND = getEvent("block_activate");
@Deprecated
public static final GameEvent RAVAGER_ROAR = getEvent("entity_action");
@Deprecated
public static final GameEvent RING_BELL = getEvent("block_change");
@Deprecated
public static final GameEvent SHULKER_CLOSE = getEvent("container_close");
@Deprecated
public static final GameEvent SHULKER_OPEN = getEvent("container_open");
@Deprecated
public static final GameEvent WOLF_SHAKING = getEvent("entity_action");
/**
* Returns a {@link GameEvent} by a {@link NamespacedKey}.
*
* @param namespacedKey the key
* @return the event or null
* @deprecated Use {@link Registry#get(NamespacedKey)} instead.
*/
@Nullable
@Deprecated
public static GameEvent getByKey(@NotNull NamespacedKey namespacedKey) {
return Registry.GAME_EVENT.get(namespacedKey);
}
/**
* Returns the set of all GameEvents.
*
* @return the memoryKeys
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated
public static Collection<GameEvent> values() {
return Collections.unmodifiableCollection(Lists.newArrayList(Registry.GAME_EVENT));
}
@NotNull
private static GameEvent getEvent(@NotNull String key) {
return Registry.GAME_EVENT.getOrThrow(NamespacedKey.minecraft(key));
}
// Paper start
/**
* Gets the range of the event which is used to
* notify listeners of the event.
*
* @return the range
*/
public abstract int getRange();
/**
* Gets the vibration level of the game event for vibration listeners.
* Not all events have vibration levels, and a level of 0 means
* it won't cause any vibrations.
*
* @return the vibration level
*/
public abstract int getVibrationLevel();
// Paper end
}

View File

@ -0,0 +1,67 @@
package org.bukkit;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* Represents a song which may play in a Jukebox.
*/
@ApiStatus.Experimental
public interface JukeboxSong extends Keyed, Translatable {
// Paper start - Generated/JukeboxSong
// @GeneratedFrom 1.21.3
JukeboxSong ELEVEN = get("11");
JukeboxSong THIRTEEN = get("13");
JukeboxSong FIVE = get("5");
JukeboxSong BLOCKS = get("blocks");
JukeboxSong CAT = get("cat");
JukeboxSong CHIRP = get("chirp");
JukeboxSong CREATOR = get("creator");
JukeboxSong CREATOR_MUSIC_BOX = get("creator_music_box");
JukeboxSong FAR = get("far");
JukeboxSong MALL = get("mall");
JukeboxSong MELLOHI = get("mellohi");
JukeboxSong OTHERSIDE = get("otherside");
JukeboxSong PIGSTEP = get("pigstep");
JukeboxSong PRECIPICE = get("precipice");
JukeboxSong RELIC = get("relic");
JukeboxSong STAL = get("stal");
JukeboxSong STRAD = get("strad");
JukeboxSong WAIT = get("wait");
JukeboxSong WARD = get("ward");
// Paper end - Generated/JukeboxSong
@NotNull
private static JukeboxSong get(@NotNull String key) {
return Registry.JUKEBOX_SONG.getOrThrow(NamespacedKey.minecraft(key));
}
// Paper start - adventure
/**
* @deprecated this method assumes that jukebox song description will
* always be a translatable component which is not guaranteed.
*/
@Override
@Deprecated(forRemoval = true)
@org.jetbrains.annotations.NotNull String getTranslationKey();
// Paper end - adventure
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,79 @@
package org.bukkit;
import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.Collections;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class MusicInstrument implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - translation keys
// Paper start - Generated/MusicInstrument
// @GeneratedFrom 1.21.3
public static final MusicInstrument ADMIRE_GOAT_HORN = getInstrument("admire_goat_horn");
public static final MusicInstrument CALL_GOAT_HORN = getInstrument("call_goat_horn");
public static final MusicInstrument DREAM_GOAT_HORN = getInstrument("dream_goat_horn");
public static final MusicInstrument FEEL_GOAT_HORN = getInstrument("feel_goat_horn");
public static final MusicInstrument PONDER_GOAT_HORN = getInstrument("ponder_goat_horn");
public static final MusicInstrument SEEK_GOAT_HORN = getInstrument("seek_goat_horn");
public static final MusicInstrument SING_GOAT_HORN = getInstrument("sing_goat_horn");
public static final MusicInstrument YEARN_GOAT_HORN = getInstrument("yearn_goat_horn");
// Paper end - Generated/MusicInstrument
/**
* Returns a {@link MusicInstrument} by a {@link NamespacedKey}.
*
* @param namespacedKey the key
* @return the event or null
* @deprecated Use {@link Registry#get(NamespacedKey)} instead.
*/
@Nullable
@Deprecated
public static MusicInstrument getByKey(@NotNull NamespacedKey namespacedKey) {
return Registry.INSTRUMENT.get(namespacedKey);
}
/**
* Returns all known MusicInstruments.
*
* @return the memoryKeys
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated
public static Collection<MusicInstrument> values() {
return Collections.unmodifiableCollection(Lists.newArrayList(Registry.INSTRUMENT));
}
@NotNull
private static MusicInstrument getInstrument(@NotNull String key) {
return Registry.INSTRUMENT.getOrThrow(NamespacedKey.minecraft(key));
}
// Paper start - deprecate getKey
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#INSTRUMENT}. MusicInstruments can exist without a key.
*/
@Deprecated(forRemoval = true, since = "1.20.5")
@Override
public abstract @NotNull NamespacedKey getKey();
// Paper end - deprecate getKey
// Paper start - mark translation key as deprecated
/**
* @deprecated this method assumes that the instrument description
* always be a translatable component which is not guaranteed.
*/
@Override
@Deprecated(forRemoval = true)
public abstract @NotNull String translationKey();
// Paper end - mark translation key as deprecated
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,180 @@
package org.bukkit;
import java.util.Locale;
import org.jetbrains.annotations.NotNull;
/**
* Represents a countable statistic, which is tracked by the server.
*/
public enum Statistic implements Keyed {
// Paper start - Generated/StatisticCustom
// @GeneratedFrom 1.21.3
ANIMALS_BRED,
AVIATE_ONE_CM,
BELL_RING,
BOAT_ONE_CM,
ARMOR_CLEANED,
BANNER_CLEANED,
CLEAN_SHULKER_BOX,
CLIMB_ONE_CM,
CROUCH_ONE_CM,
DAMAGE_ABSORBED,
DAMAGE_BLOCKED_BY_SHIELD,
DAMAGE_DEALT,
DAMAGE_DEALT_ABSORBED,
DAMAGE_DEALT_RESISTED,
DAMAGE_RESISTED,
DAMAGE_TAKEN,
DEATHS,
DROP_COUNT,
CAKE_SLICES_EATEN,
ITEM_ENCHANTED,
FALL_ONE_CM,
CAULDRON_FILLED,
FISH_CAUGHT,
FLY_ONE_CM,
HORSE_ONE_CM,
DISPENSER_INSPECTED,
DROPPER_INSPECTED,
HOPPER_INSPECTED,
INTERACT_WITH_ANVIL,
BEACON_INTERACTION,
INTERACT_WITH_BLAST_FURNACE,
BREWINGSTAND_INTERACTION,
INTERACT_WITH_CAMPFIRE,
INTERACT_WITH_CARTOGRAPHY_TABLE,
CRAFTING_TABLE_INTERACTION,
FURNACE_INTERACTION,
INTERACT_WITH_GRINDSTONE,
INTERACT_WITH_LECTERN,
INTERACT_WITH_LOOM,
INTERACT_WITH_SMITHING_TABLE,
INTERACT_WITH_SMOKER,
INTERACT_WITH_STONECUTTER,
JUMP,
LEAVE_GAME,
MINECART_ONE_CM,
MOB_KILLS,
OPEN_BARREL,
CHEST_OPENED,
ENDERCHEST_OPENED,
SHULKER_BOX_OPENED,
PIG_ONE_CM,
NOTEBLOCK_PLAYED,
RECORD_PLAYED,
PLAY_ONE_MINUTE,
PLAYER_KILLS,
FLOWER_POTTED,
RAID_TRIGGER,
RAID_WIN,
SLEEP_IN_BED,
SNEAK_TIME,
SPRINT_ONE_CM,
STRIDER_ONE_CM,
SWIM_ONE_CM,
TALKED_TO_VILLAGER,
TARGET_HIT,
TIME_SINCE_DEATH,
TIME_SINCE_REST,
TOTAL_WORLD_TIME,
TRADED_WITH_VILLAGER,
TRAPPED_CHEST_TRIGGERED,
NOTEBLOCK_TUNED,
CAULDRON_USED,
WALK_ON_WATER_ONE_CM,
WALK_ONE_CM,
WALK_UNDER_WATER_ONE_CM,
// Paper end - Generated/StatisticCustom
// Paper start - Generated/StatisticType
// @GeneratedFrom 1.21.3
BREAK_ITEM(Type.ITEM),
CRAFT_ITEM(Type.ITEM),
DROP(Type.ITEM),
KILL_ENTITY(Type.ENTITY),
ENTITY_KILLED_BY(Type.ENTITY),
MINE_BLOCK(Type.BLOCK),
PICKUP(Type.ITEM),
USE_ITEM(Type.ITEM);
// Paper end - Generated/StatisticType
private final Type type;
private final NamespacedKey key;
private Statistic() {
this(Type.UNTYPED);
}
private Statistic(/*@NotNull*/ Type type) {
this.type = type;
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
}
/**
* Gets the type of this statistic.
*
* @return the type of this statistic
*/
@NotNull
public Type getType() {
return type;
}
/**
* Checks if this is a substatistic.
* <p>
* A substatistic exists en masse for each block, item, or entitytype, depending on
* {@link #getType()}.
* <p>
* This is a redundant method and equivalent to checking
* <code>getType() != Type.UNTYPED</code>
*
* @return true if this is a substatistic
*/
public boolean isSubstatistic() {
return type != Type.UNTYPED;
}
/**
* Checks if this is a substatistic dealing with blocks.
* <p>
* This is a redundant method and equivalent to checking
* <code>getType() == Type.BLOCK</code>
*
* @return true if this deals with blocks
*/
public boolean isBlock() {
return type == Type.BLOCK;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/**
* The type of statistic.
*
*/
public enum Type {
/**
* Statistics of this type do not require a qualifier.
*/
UNTYPED,
/**
* Statistics of this type require an Item Material qualifier.
*/
ITEM,
/**
* Statistics of this type require a Block Material qualifier.
*/
BLOCK,
/**
* Statistics of this type require an EntityType qualifier.
*/
ENTITY;
}
}

View File

@ -0,0 +1,901 @@
package org.bukkit;
import java.util.Set;
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;
/**
* Represents a tag that may be defined by the server or a resource pack to
* group like things together.
*
* Note that whilst all tags defined within this interface must be present in
* implementations, their existence is not guaranteed across future versions.
*
* <p>Custom tags defined by Paper are not present (as constants) in this class.
* To access them please refer to {@link com.destroystokyo.paper.MaterialTags}
* and {@link io.papermc.paper.tag.EntityTags}.</p>
*
* @param <T> the type of things grouped by this tag
*/
public interface Tag<T extends Keyed> extends Keyed {
// Paper start - Generated/Tag
// @GeneratedFrom 1.21.3
String REGISTRY_BLOCKS = "blocks";
Tag<Material> ACACIA_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("acacia_logs"), Material.class);
Tag<Material> AIR = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("air"), Material.class);
Tag<Material> ALL_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("all_hanging_signs"), Material.class);
Tag<Material> ALL_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("all_signs"), Material.class);
Tag<Material> ANCIENT_CITY_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ancient_city_replaceable"), Material.class);
Tag<Material> ANIMALS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("animals_spawnable_on"), Material.class);
Tag<Material> ANVIL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("anvil"), Material.class);
Tag<Material> ARMADILLO_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("armadillo_spawnable_on"), Material.class);
Tag<Material> AXOLOTLS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("axolotls_spawnable_on"), Material.class);
Tag<Material> AZALEA_GROWS_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("azalea_grows_on"), Material.class);
Tag<Material> AZALEA_ROOT_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("azalea_root_replaceable"), Material.class);
Tag<Material> BADLANDS_TERRACOTTA = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("badlands_terracotta"), Material.class);
Tag<Material> BAMBOO_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bamboo_blocks"), Material.class);
Tag<Material> BAMBOO_PLANTABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bamboo_plantable_on"), Material.class);
Tag<Material> BANNERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("banners"), Material.class);
Tag<Material> BASE_STONE_NETHER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("base_stone_nether"), Material.class);
Tag<Material> BASE_STONE_OVERWORLD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("base_stone_overworld"), Material.class);
Tag<Material> BATS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bats_spawnable_on"), Material.class);
Tag<Material> BEACON_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beacon_base_blocks"), Material.class);
Tag<Material> BEDS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beds"), Material.class);
Tag<Material> BEE_GROWABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bee_growables"), Material.class);
Tag<Material> BEEHIVES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beehives"), Material.class);
Tag<Material> BIG_DRIPLEAF_PLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("big_dripleaf_placeable"), Material.class);
Tag<Material> BIRCH_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("birch_logs"), Material.class);
Tag<Material> BLOCKS_WIND_CHARGE_EXPLOSIONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("blocks_wind_charge_explosions"), Material.class);
Tag<Material> BUTTONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("buttons"), Material.class);
Tag<Material> CAMEL_SAND_STEP_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("camel_sand_step_sound_blocks"), Material.class);
Tag<Material> CAMPFIRES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("campfires"), Material.class);
Tag<Material> CANDLE_CAKES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candle_cakes"), Material.class);
Tag<Material> CANDLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candles"), Material.class);
Tag<Material> CAULDRONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cauldrons"), Material.class);
Tag<Material> CAVE_VINES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cave_vines"), Material.class);
Tag<Material> CEILING_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ceiling_hanging_signs"), Material.class);
Tag<Material> CHERRY_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cherry_logs"), Material.class);
Tag<Material> CLIMBABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("climbable"), Material.class);
Tag<Material> COAL_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("coal_ores"), Material.class);
Tag<Material> COMBINATION_STEP_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("combination_step_sound_blocks"), Material.class);
Tag<Material> COMPLETES_FIND_TREE_TUTORIAL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("completes_find_tree_tutorial"), Material.class);
Tag<Material> CONCRETE_POWDER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("concrete_powder"), Material.class);
Tag<Material> CONVERTABLE_TO_MUD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("convertable_to_mud"), Material.class);
Tag<Material> COPPER_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("copper_ores"), Material.class);
Tag<Material> CORAL_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("coral_blocks"), Material.class);
Tag<Material> CORAL_PLANTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("coral_plants"), Material.class);
Tag<Material> CORALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("corals"), Material.class);
Tag<Material> CRIMSON_STEMS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("crimson_stems"), Material.class);
Tag<Material> CROPS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("crops"), Material.class);
Tag<Material> CRYSTAL_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("crystal_sound_blocks"), Material.class);
Tag<Material> DAMPENS_VIBRATIONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dampens_vibrations"), Material.class);
Tag<Material> DARK_OAK_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dark_oak_logs"), Material.class);
Tag<Material> DEAD_BUSH_MAY_PLACE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dead_bush_may_place_on"), Material.class);
Tag<Material> DEEPSLATE_ORE_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("deepslate_ore_replaceables"), Material.class);
Tag<Material> DIAMOND_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("diamond_ores"), Material.class);
Tag<Material> DIRT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dirt"), Material.class);
Tag<Material> DOES_NOT_BLOCK_HOPPERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("does_not_block_hoppers"), Material.class);
Tag<Material> DOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("doors"), Material.class);
Tag<Material> DRAGON_IMMUNE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dragon_immune"), Material.class);
Tag<Material> DRAGON_TRANSPARENT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dragon_transparent"), Material.class);
Tag<Material> DRIPSTONE_REPLACEABLE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dripstone_replaceable_blocks"), Material.class);
Tag<Material> EMERALD_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("emerald_ores"), Material.class);
Tag<Material> ENCHANTMENT_POWER_PROVIDER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("enchantment_power_provider"), Material.class);
Tag<Material> ENCHANTMENT_POWER_TRANSMITTER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("enchantment_power_transmitter"), Material.class);
Tag<Material> ENDERMAN_HOLDABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("enderman_holdable"), Material.class);
Tag<Material> FALL_DAMAGE_RESETTING = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fall_damage_resetting"), Material.class);
Tag<Material> FEATURES_CANNOT_REPLACE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("features_cannot_replace"), Material.class);
Tag<Material> FENCE_GATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fence_gates"), Material.class);
Tag<Material> FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fences"), Material.class);
Tag<Material> FIRE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fire"), Material.class);
Tag<Material> FLOWER_POTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("flower_pots"), Material.class);
Tag<Material> FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("flowers"), Material.class);
Tag<Material> FOXES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("foxes_spawnable_on"), Material.class);
Tag<Material> FROG_PREFER_JUMP_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("frog_prefer_jump_to"), Material.class);
Tag<Material> FROGS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("frogs_spawnable_on"), Material.class);
Tag<Material> GEODE_INVALID_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("geode_invalid_blocks"), Material.class);
Tag<Material> GOATS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("goats_spawnable_on"), Material.class);
Tag<Material> GOLD_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("gold_ores"), Material.class);
Tag<Material> GUARDED_BY_PIGLINS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("guarded_by_piglins"), Material.class);
Tag<Material> HOGLIN_REPELLENTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("hoglin_repellents"), Material.class);
Tag<Material> ICE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ice"), Material.class);
Tag<Material> IMPERMEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("impermeable"), Material.class);
Tag<Material> INCORRECT_FOR_DIAMOND_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_diamond_tool"), Material.class);
Tag<Material> INCORRECT_FOR_GOLD_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_gold_tool"), Material.class);
Tag<Material> INCORRECT_FOR_IRON_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_iron_tool"), Material.class);
Tag<Material> INCORRECT_FOR_NETHERITE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_netherite_tool"), Material.class);
Tag<Material> INCORRECT_FOR_STONE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_stone_tool"), Material.class);
Tag<Material> INCORRECT_FOR_WOODEN_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_wooden_tool"), Material.class);
Tag<Material> INFINIBURN_END = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("infiniburn_end"), Material.class);
Tag<Material> INFINIBURN_NETHER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("infiniburn_nether"), Material.class);
Tag<Material> INFINIBURN_OVERWORLD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("infiniburn_overworld"), Material.class);
Tag<Material> INSIDE_STEP_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("inside_step_sound_blocks"), Material.class);
Tag<Material> INVALID_SPAWN_INSIDE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("invalid_spawn_inside"), Material.class);
Tag<Material> IRON_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("iron_ores"), Material.class);
Tag<Material> JUNGLE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("jungle_logs"), Material.class);
Tag<Material> LAPIS_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lapis_ores"), Material.class);
Tag<Material> LAVA_POOL_STONE_CANNOT_REPLACE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lava_pool_stone_cannot_replace"), Material.class);
Tag<Material> LEAVES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("leaves"), Material.class);
Tag<Material> LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("logs"), Material.class);
Tag<Material> LOGS_THAT_BURN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("logs_that_burn"), Material.class);
Tag<Material> LUSH_GROUND_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lush_ground_replaceable"), Material.class);
Tag<Material> MAINTAINS_FARMLAND = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("maintains_farmland"), Material.class);
Tag<Material> MANGROVE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mangrove_logs"), Material.class);
Tag<Material> MANGROVE_LOGS_CAN_GROW_THROUGH = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mangrove_logs_can_grow_through"), Material.class);
Tag<Material> MANGROVE_ROOTS_CAN_GROW_THROUGH = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mangrove_roots_can_grow_through"), Material.class);
Tag<Material> MINEABLE_AXE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/axe"), Material.class);
Tag<Material> MINEABLE_HOE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/hoe"), Material.class);
Tag<Material> MINEABLE_PICKAXE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/pickaxe"), Material.class);
Tag<Material> MINEABLE_SHOVEL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/shovel"), Material.class);
Tag<Material> MOB_INTERACTABLE_DOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mob_interactable_doors"), Material.class);
Tag<Material> MOOSHROOMS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mooshrooms_spawnable_on"), Material.class);
Tag<Material> MOSS_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("moss_replaceable"), Material.class);
Tag<Material> MUSHROOM_GROW_BLOCK = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mushroom_grow_block"), Material.class);
Tag<Material> NEEDS_DIAMOND_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_diamond_tool"), Material.class);
Tag<Material> NEEDS_IRON_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_iron_tool"), Material.class);
Tag<Material> NEEDS_STONE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_stone_tool"), Material.class);
Tag<Material> NETHER_CARVER_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("nether_carver_replaceables"), Material.class);
Tag<Material> NYLIUM = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("nylium"), Material.class);
Tag<Material> OAK_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("oak_logs"), Material.class);
Tag<Material> OCCLUDES_VIBRATION_SIGNALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("occludes_vibration_signals"), Material.class);
Tag<Material> OVERWORLD_CARVER_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("overworld_carver_replaceables"), Material.class);
Tag<Material> OVERWORLD_NATURAL_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("overworld_natural_logs"), Material.class);
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
@org.jetbrains.annotations.ApiStatus.Experimental
Tag<Material> PALE_OAK_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("pale_oak_logs"), Material.class);
Tag<Material> PARROTS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("parrots_spawnable_on"), Material.class);
Tag<Material> PIGLIN_REPELLENTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("piglin_repellents"), Material.class);
Tag<Material> PLANKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("planks"), Material.class);
Tag<Material> POLAR_BEARS_SPAWNABLE_ON_ALTERNATE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("polar_bears_spawnable_on_alternate"), Material.class);
Tag<Material> PORTALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("portals"), Material.class);
Tag<Material> PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("pressure_plates"), Material.class);
Tag<Material> PREVENT_MOB_SPAWNING_INSIDE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("prevent_mob_spawning_inside"), Material.class);
Tag<Material> RABBITS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("rabbits_spawnable_on"), Material.class);
Tag<Material> RAILS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("rails"), Material.class);
Tag<Material> REDSTONE_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("redstone_ores"), Material.class);
Tag<Material> REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("replaceable"), Material.class);
Tag<Material> REPLACEABLE_BY_TREES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("replaceable_by_trees"), Material.class);
Tag<Material> SAND = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sand"), Material.class);
Tag<Material> SAPLINGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("saplings"), Material.class);
Tag<Material> SCULK_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sculk_replaceable"), Material.class);
Tag<Material> SCULK_REPLACEABLE_WORLD_GEN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sculk_replaceable_world_gen"), Material.class);
Tag<Material> SHULKER_BOXES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("shulker_boxes"), Material.class);
Tag<Material> SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("signs"), Material.class);
Tag<Material> SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("slabs"), Material.class);
Tag<Material> SMALL_DRIPLEAF_PLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_dripleaf_placeable"), Material.class);
Tag<Material> SMALL_FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_flowers"), Material.class);
Tag<Material> SMELTS_TO_GLASS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("smelts_to_glass"), Material.class);
Tag<Material> SNAPS_GOAT_HORN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snaps_goat_horn"), Material.class);
Tag<Material> SNIFFER_DIGGABLE_BLOCK = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sniffer_diggable_block"), Material.class);
Tag<Material> SNIFFER_EGG_HATCH_BOOST = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sniffer_egg_hatch_boost"), Material.class);
Tag<Material> SNOW = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow"), Material.class);
Tag<Material> SNOW_LAYER_CAN_SURVIVE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow_layer_can_survive_on"), Material.class);
Tag<Material> SNOW_LAYER_CANNOT_SURVIVE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow_layer_cannot_survive_on"), Material.class);
Tag<Material> SOUL_FIRE_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("soul_fire_base_blocks"), Material.class);
Tag<Material> SOUL_SPEED_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("soul_speed_blocks"), Material.class);
Tag<Material> SPRUCE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("spruce_logs"), Material.class);
Tag<Material> STAIRS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stairs"), Material.class);
Tag<Material> STANDING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("standing_signs"), Material.class);
Tag<Material> STONE_BRICKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_bricks"), Material.class);
Tag<Material> STONE_BUTTONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_buttons"), Material.class);
Tag<Material> STONE_ORE_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_ore_replaceables"), Material.class);
Tag<Material> STONE_PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_pressure_plates"), Material.class);
Tag<Material> STRIDER_WARM_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("strider_warm_blocks"), Material.class);
Tag<Material> SWORD_EFFICIENT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sword_efficient"), Material.class);
Tag<Material> TALL_FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("tall_flowers"), Material.class);
Tag<Material> TERRACOTTA = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("terracotta"), Material.class);
Tag<Material> TRAIL_RUINS_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("trail_ruins_replaceable"), Material.class);
Tag<Material> TRAPDOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("trapdoors"), Material.class);
Tag<Material> UNDERWATER_BONEMEALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("underwater_bonemeals"), Material.class);
Tag<Material> UNSTABLE_BOTTOM_CENTER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("unstable_bottom_center"), Material.class);
Tag<Material> VALID_SPAWN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("valid_spawn"), Material.class);
Tag<Material> VIBRATION_RESONATORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("vibration_resonators"), Material.class);
Tag<Material> WALL_CORALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_corals"), Material.class);
Tag<Material> WALL_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_hanging_signs"), Material.class);
Tag<Material> WALL_POST_OVERRIDE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_post_override"), Material.class);
Tag<Material> WALL_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_signs"), Material.class);
Tag<Material> WALLS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("walls"), Material.class);
Tag<Material> WARPED_STEMS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("warped_stems"), Material.class);
Tag<Material> WART_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wart_blocks"), Material.class);
Tag<Material> WITHER_IMMUNE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_immune"), Material.class);
Tag<Material> WITHER_SUMMON_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_summon_base_blocks"), Material.class);
Tag<Material> WOLVES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wolves_spawnable_on"), Material.class);
Tag<Material> WOODEN_BUTTONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_buttons"), Material.class);
Tag<Material> WOODEN_DOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_doors"), Material.class);
Tag<Material> WOODEN_FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_fences"), Material.class);
Tag<Material> WOODEN_PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_pressure_plates"), Material.class);
Tag<Material> WOODEN_SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_slabs"), Material.class);
Tag<Material> WOODEN_STAIRS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_stairs"), Material.class);
Tag<Material> WOODEN_TRAPDOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_trapdoors"), Material.class);
Tag<Material> WOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wool"), Material.class);
Tag<Material> WOOL_CARPETS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wool_carpets"), Material.class);
String REGISTRY_ITEMS = "items";
Tag<Material> ITEMS_ACACIA_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("acacia_logs"), Material.class);
Tag<Material> ITEMS_ANVIL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("anvil"), Material.class);
Tag<Material> ITEMS_ARMADILLO_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("armadillo_food"), Material.class);
Tag<Material> ITEMS_ARROWS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("arrows"), Material.class);
Tag<Material> ITEMS_AXES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("axes"), Material.class);
Tag<Material> ITEMS_AXOLOTL_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("axolotl_food"), Material.class);
Tag<Material> ITEMS_BAMBOO_BLOCKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bamboo_blocks"), Material.class);
Tag<Material> ITEMS_BANNERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("banners"), Material.class);
Tag<Material> ITEMS_BEACON_PAYMENT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("beacon_payment_items"), Material.class);
Tag<Material> ITEMS_BEDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("beds"), Material.class);
Tag<Material> ITEMS_BEE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bee_food"), Material.class);
Tag<Material> ITEMS_BIRCH_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("birch_logs"), Material.class);
Tag<Material> ITEMS_BOATS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("boats"), Material.class);
Tag<Material> ITEMS_BOOKSHELF_BOOKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bookshelf_books"), Material.class);
Tag<Material> ITEMS_BREAKS_DECORATED_POTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("breaks_decorated_pots"), Material.class);
Tag<Material> ITEMS_BREWING_FUEL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("brewing_fuel"), Material.class);
Tag<Material> ITEMS_BUNDLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bundles"), Material.class);
Tag<Material> ITEMS_BUTTONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("buttons"), Material.class);
Tag<Material> ITEMS_CAMEL_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("camel_food"), Material.class);
Tag<Material> ITEMS_CANDLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("candles"), Material.class);
Tag<Material> ITEMS_CAT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cat_food"), Material.class);
Tag<Material> ITEMS_CHERRY_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cherry_logs"), Material.class);
Tag<Material> ITEMS_CHEST_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chest_armor"), Material.class);
Tag<Material> ITEMS_CHEST_BOATS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chest_boats"), Material.class);
Tag<Material> ITEMS_CHICKEN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chicken_food"), Material.class);
Tag<Material> ITEMS_CLUSTER_MAX_HARVESTABLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cluster_max_harvestables"), Material.class);
Tag<Material> ITEMS_COAL_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("coal_ores"), Material.class);
Tag<Material> ITEMS_COALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("coals"), Material.class);
Tag<Material> ITEMS_COMPASSES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("compasses"), Material.class);
Tag<Material> ITEMS_COMPLETES_FIND_TREE_TUTORIAL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("completes_find_tree_tutorial"), Material.class);
Tag<Material> ITEMS_COPPER_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("copper_ores"), Material.class);
Tag<Material> ITEMS_COW_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cow_food"), Material.class);
Tag<Material> ITEMS_CREEPER_DROP_MUSIC_DISCS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("creeper_drop_music_discs"), Material.class);
Tag<Material> ITEMS_CREEPER_IGNITERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("creeper_igniters"), Material.class);
Tag<Material> ITEMS_CRIMSON_STEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("crimson_stems"), Material.class);
Tag<Material> ITEMS_DAMPENS_VIBRATIONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("dampens_vibrations"), Material.class);
Tag<Material> ITEMS_DARK_OAK_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("dark_oak_logs"), Material.class);
Tag<Material> ITEMS_DECORATED_POT_INGREDIENTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("decorated_pot_ingredients"), Material.class);
Tag<Material> ITEMS_DECORATED_POT_SHERDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("decorated_pot_sherds"), Material.class);
Tag<Material> ITEMS_DIAMOND_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("diamond_ores"), Material.class);
Tag<Material> ITEMS_DIAMOND_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("diamond_tool_materials"), Material.class);
Tag<Material> ITEMS_DIRT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("dirt"), Material.class);
Tag<Material> ITEMS_DOORS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("doors"), Material.class);
Tag<Material> ITEMS_DUPLICATES_ALLAYS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("duplicates_allays"), Material.class);
Tag<Material> ITEMS_DYEABLE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("dyeable"), Material.class);
Tag<Material> ITEMS_EMERALD_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("emerald_ores"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/armor"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_BOW = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/bow"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_CHEST_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/chest_armor"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_CROSSBOW = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/crossbow"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_DURABILITY = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/durability"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_EQUIPPABLE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/equippable"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_FIRE_ASPECT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/fire_aspect"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_FISHING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/fishing"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_FOOT_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/foot_armor"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_HEAD_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/head_armor"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_LEG_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/leg_armor"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_MACE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mace"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_MINING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_MINING_LOOT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining_loot"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_SHARP_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sharp_weapon"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_SWORD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sword"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_TRIDENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/trident"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_VANISHING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/vanishing"), Material.class);
Tag<Material> ITEMS_ENCHANTABLE_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/weapon"), Material.class);
Tag<Material> ITEMS_FENCE_GATES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fence_gates"), Material.class);
Tag<Material> ITEMS_FENCES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fences"), Material.class);
Tag<Material> ITEMS_FISHES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fishes"), Material.class);
Tag<Material> ITEMS_FLOWERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("flowers"), Material.class);
Tag<Material> ITEMS_FOOT_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("foot_armor"), Material.class);
Tag<Material> ITEMS_FOX_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fox_food"), Material.class);
Tag<Material> ITEMS_FREEZE_IMMUNE_WEARABLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("freeze_immune_wearables"), Material.class);
Tag<Material> ITEMS_FROG_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("frog_food"), Material.class);
Tag<Material> ITEMS_FURNACE_MINECART_FUEL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("furnace_minecart_fuel"), Material.class);
Tag<Material> ITEMS_GAZE_DISGUISE_EQUIPMENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gaze_disguise_equipment"), Material.class);
Tag<Material> ITEMS_GOAT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("goat_food"), Material.class);
Tag<Material> ITEMS_GOLD_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gold_ores"), Material.class);
Tag<Material> ITEMS_GOLD_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gold_tool_materials"), Material.class);
Tag<Material> ITEMS_HANGING_SIGNS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("hanging_signs"), Material.class);
Tag<Material> ITEMS_HEAD_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("head_armor"), Material.class);
Tag<Material> ITEMS_HOES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("hoes"), Material.class);
Tag<Material> ITEMS_HOGLIN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("hoglin_food"), Material.class);
Tag<Material> ITEMS_HORSE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("horse_food"), Material.class);
Tag<Material> ITEMS_HORSE_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("horse_tempt_items"), Material.class);
Tag<Material> ITEMS_IGNORED_BY_PIGLIN_BABIES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("ignored_by_piglin_babies"), Material.class);
Tag<Material> ITEMS_IRON_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("iron_ores"), Material.class);
Tag<Material> ITEMS_IRON_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("iron_tool_materials"), Material.class);
Tag<Material> ITEMS_JUNGLE_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("jungle_logs"), Material.class);
Tag<Material> ITEMS_LAPIS_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("lapis_ores"), Material.class);
Tag<Material> ITEMS_LEAVES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("leaves"), Material.class);
Tag<Material> ITEMS_LECTERN_BOOKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("lectern_books"), Material.class);
Tag<Material> ITEMS_LEG_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("leg_armor"), Material.class);
Tag<Material> ITEMS_LLAMA_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("llama_food"), Material.class);
Tag<Material> ITEMS_LLAMA_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("llama_tempt_items"), Material.class);
Tag<Material> ITEMS_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("logs"), Material.class);
Tag<Material> ITEMS_LOGS_THAT_BURN = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("logs_that_burn"), Material.class);
Tag<Material> ITEMS_MANGROVE_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("mangrove_logs"), Material.class);
Tag<Material> ITEMS_MAP_INVISIBILITY_EQUIPMENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("map_invisibility_equipment"), Material.class);
Tag<Material> ITEMS_MEAT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("meat"), Material.class);
Tag<Material> ITEMS_NETHERITE_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("netherite_tool_materials"), Material.class);
Tag<Material> ITEMS_NON_FLAMMABLE_WOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("non_flammable_wood"), Material.class);
Tag<Material> ITEMS_NOTEBLOCK_TOP_INSTRUMENTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("noteblock_top_instruments"), Material.class);
Tag<Material> ITEMS_OAK_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("oak_logs"), Material.class);
Tag<Material> ITEMS_OCELOT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("ocelot_food"), Material.class);
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
@org.jetbrains.annotations.ApiStatus.Experimental
Tag<Material> ITEMS_PALE_OAK_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pale_oak_logs"), Material.class);
Tag<Material> ITEMS_PANDA_EATS_FROM_GROUND = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("panda_eats_from_ground"), Material.class);
Tag<Material> ITEMS_PANDA_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("panda_food"), Material.class);
Tag<Material> ITEMS_PARROT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("parrot_food"), Material.class);
Tag<Material> ITEMS_PARROT_POISONOUS_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("parrot_poisonous_food"), Material.class);
Tag<Material> ITEMS_PICKAXES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pickaxes"), Material.class);
Tag<Material> ITEMS_PIG_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pig_food"), Material.class);
Tag<Material> ITEMS_PIGLIN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_food"), Material.class);
Tag<Material> ITEMS_PIGLIN_LOVED = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_loved"), Material.class);
Tag<Material> ITEMS_PIGLIN_REPELLENTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_repellents"), Material.class);
Tag<Material> ITEMS_PIGLIN_SAFE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_safe_armor"), Material.class);
Tag<Material> ITEMS_PLANKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("planks"), Material.class);
Tag<Material> ITEMS_RABBIT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("rabbit_food"), Material.class);
Tag<Material> ITEMS_RAILS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("rails"), Material.class);
Tag<Material> ITEMS_REDSTONE_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("redstone_ores"), Material.class);
Tag<Material> ITEMS_REPAIRS_CHAIN_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_chain_armor"), Material.class);
Tag<Material> ITEMS_REPAIRS_DIAMOND_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_diamond_armor"), Material.class);
Tag<Material> ITEMS_REPAIRS_GOLD_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_gold_armor"), Material.class);
Tag<Material> ITEMS_REPAIRS_IRON_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_iron_armor"), Material.class);
Tag<Material> ITEMS_REPAIRS_LEATHER_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_leather_armor"), Material.class);
Tag<Material> ITEMS_REPAIRS_NETHERITE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_netherite_armor"), Material.class);
Tag<Material> ITEMS_REPAIRS_TURTLE_HELMET = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_turtle_helmet"), Material.class);
Tag<Material> ITEMS_REPAIRS_WOLF_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_wolf_armor"), Material.class);
Tag<Material> ITEMS_SAND = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sand"), Material.class);
Tag<Material> ITEMS_SAPLINGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("saplings"), Material.class);
Tag<Material> ITEMS_SHEEP_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sheep_food"), Material.class);
Tag<Material> ITEMS_SHOVELS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("shovels"), Material.class);
Tag<Material> ITEMS_SHULKER_BOXES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("shulker_boxes"), Material.class);
Tag<Material> ITEMS_SIGNS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("signs"), Material.class);
Tag<Material> ITEMS_SKULLS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("skulls"), Material.class);
Tag<Material> ITEMS_SLABS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("slabs"), Material.class);
Tag<Material> ITEMS_SMALL_FLOWERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("small_flowers"), Material.class);
Tag<Material> ITEMS_SMELTS_TO_GLASS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("smelts_to_glass"), Material.class);
Tag<Material> ITEMS_SNIFFER_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sniffer_food"), Material.class);
Tag<Material> ITEMS_SOUL_FIRE_BASE_BLOCKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("soul_fire_base_blocks"), Material.class);
Tag<Material> ITEMS_SPRUCE_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("spruce_logs"), Material.class);
Tag<Material> ITEMS_STAIRS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stairs"), Material.class);
Tag<Material> ITEMS_STONE_BRICKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_bricks"), Material.class);
Tag<Material> ITEMS_STONE_BUTTONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_buttons"), Material.class);
Tag<Material> ITEMS_STONE_CRAFTING_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_crafting_materials"), Material.class);
Tag<Material> ITEMS_STONE_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_tool_materials"), Material.class);
Tag<Material> ITEMS_STRIDER_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("strider_food"), Material.class);
Tag<Material> ITEMS_STRIDER_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("strider_tempt_items"), Material.class);
Tag<Material> ITEMS_SWORDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("swords"), Material.class);
Tag<Material> ITEMS_TALL_FLOWERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("tall_flowers"), Material.class);
Tag<Material> ITEMS_TERRACOTTA = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("terracotta"), Material.class);
Tag<Material> ITEMS_TRAPDOORS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("trapdoors"), Material.class);
Tag<Material> ITEMS_TRIM_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("trim_materials"), Material.class);
Tag<Material> ITEMS_TRIM_TEMPLATES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("trim_templates"), Material.class);
Tag<Material> ITEMS_TRIMMABLE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("trimmable_armor"), Material.class);
Tag<Material> ITEMS_TURTLE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("turtle_food"), Material.class);
Tag<Material> ITEMS_VILLAGER_PICKS_UP = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("villager_picks_up"), Material.class);
Tag<Material> ITEMS_VILLAGER_PLANTABLE_SEEDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("villager_plantable_seeds"), Material.class);
Tag<Material> ITEMS_WALLS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("walls"), Material.class);
Tag<Material> ITEMS_WARPED_STEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("warped_stems"), Material.class);
Tag<Material> ITEMS_WART_BLOCKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wart_blocks"), Material.class);
Tag<Material> ITEMS_WOLF_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wolf_food"), Material.class);
Tag<Material> ITEMS_WOODEN_BUTTONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_buttons"), Material.class);
Tag<Material> ITEMS_WOODEN_DOORS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_doors"), Material.class);
Tag<Material> ITEMS_WOODEN_FENCES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_fences"), Material.class);
Tag<Material> ITEMS_WOODEN_PRESSURE_PLATES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_pressure_plates"), Material.class);
Tag<Material> ITEMS_WOODEN_SLABS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_slabs"), Material.class);
Tag<Material> ITEMS_WOODEN_STAIRS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_stairs"), Material.class);
Tag<Material> ITEMS_WOODEN_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_tool_materials"), Material.class);
Tag<Material> ITEMS_WOODEN_TRAPDOORS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_trapdoors"), Material.class);
Tag<Material> ITEMS_WOOL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wool"), Material.class);
Tag<Material> ITEMS_WOOL_CARPETS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wool_carpets"), Material.class);
String REGISTRY_FLUIDS = "fluids";
Tag<Fluid> FLUIDS_LAVA = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("lava"), Fluid.class);
Tag<Fluid> FLUIDS_WATER = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("water"), Fluid.class);
String REGISTRY_ENTITY_TYPES = "entity_types";
Tag<EntityType> ENTITY_TYPES_AQUATIC = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("aquatic"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_ARROWS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("arrows"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_ARTHROPOD = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("arthropod"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_AXOLOTL_ALWAYS_HOSTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("axolotl_always_hostiles"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_AXOLOTL_HUNT_TARGETS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("axolotl_hunt_targets"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_BEEHIVE_INHABITORS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("beehive_inhabitors"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_BOAT = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("boat"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_CAN_BREATHE_UNDER_WATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_breathe_under_water"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_DEFLECTS_PROJECTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("deflects_projectiles"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_DISMOUNTS_UNDERWATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("dismounts_underwater"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_FALL_DAMAGE_IMMUNE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("fall_damage_immune"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_FREEZE_HURTS_EXTRA_TYPES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("freeze_hurts_extra_types"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_FREEZE_IMMUNE_ENTITY_TYPES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("freeze_immune_entity_types"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_FROG_FOOD = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("frog_food"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_IGNORES_POISON_AND_REGEN = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("ignores_poison_and_regen"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_ILLAGER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("illager"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_ILLAGER_FRIENDS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("illager_friends"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_IMMUNE_TO_INFESTED = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("immune_to_infested"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_IMMUNE_TO_OOZING = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("immune_to_oozing"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_IMPACT_PROJECTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("impact_projectiles"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_INVERTED_HEALING_AND_HARM = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("inverted_healing_and_harm"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_NO_ANGER_FROM_WIND_CHARGE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("no_anger_from_wind_charge"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_NON_CONTROLLING_RIDER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("non_controlling_rider"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_NOT_SCARY_FOR_PUFFERFISH = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("not_scary_for_pufferfish"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_POWDER_SNOW_WALKABLE_MOBS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("powder_snow_walkable_mobs"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_RAIDERS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("raiders"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_REDIRECTABLE_PROJECTILE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("redirectable_projectile"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_SENSITIVE_TO_BANE_OF_ARTHROPODS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("sensitive_to_bane_of_arthropods"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_SENSITIVE_TO_IMPALING = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("sensitive_to_impaling"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_SENSITIVE_TO_SMITE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("sensitive_to_smite"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_SKELETONS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("skeletons"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_UNDEAD = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("undead"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_WITHER_FRIENDS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("wither_friends"), EntityType.class);
Tag<EntityType> ENTITY_TYPES_ZOMBIES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("zombies"), EntityType.class);
String REGISTRY_GAME_EVENTS = "game_events";
Tag<GameEvent> GAME_EVENT_ALLAY_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("allay_can_listen"), GameEvent.class);
Tag<GameEvent> GAME_EVENT_IGNORE_VIBRATIONS_SNEAKING = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("ignore_vibrations_sneaking"), GameEvent.class);
Tag<GameEvent> GAME_EVENT_SHRIEKER_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("shrieker_can_listen"), GameEvent.class);
Tag<GameEvent> GAME_EVENT_VIBRATIONS = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("vibrations"), GameEvent.class);
Tag<GameEvent> GAME_EVENT_WARDEN_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("warden_can_listen"), GameEvent.class);
// Paper end - Generated/Tag
/**
* @deprecated {@link #WOOL_CARPETS}.
*/
@Deprecated
Tag<Material> CARPETS = WOOL_CARPETS;
/**
* Vanilla item tag representing all piglin food.
*
* @deprecated use {@link #ITEMS_PIGLIN_FOOD}
*/
@Deprecated
Tag<Material> PIGLIN_FOOD = ITEMS_PIGLIN_FOOD;
/**
* Vanilla item tag representing all fox food.
*
* @deprecated use {@link #ITEMS_FOX_FOOD}
*/
@Deprecated
Tag<Material> FOX_FOOD = ITEMS_FOX_FOOD;
/**
* Vanilla item tag representing all furnace materials.
*
* @deprecated use {@link #ITEMS_STONE_CRAFTING_MATERIALS}
*/
@Deprecated(since = "1.16.2")
Tag<Material> ITEMS_FURNACE_MATERIALS = ITEMS_STONE_CRAFTING_MATERIALS;
/**
* Vanilla item tag representing all tools.
*
* @deprecated removed in Minecraft 1.20.5. Do not use. Will be removed at a later date. Until then,
* this constant now acts as a reference to {@link #ITEMS_BREAKS_DECORATED_POTS} which largely shares
* the same contents of the old "minecraft:tools" tag.
*/
@Deprecated(forRemoval = true)
Tag<Material> ITEMS_TOOLS = ITEMS_BREAKS_DECORATED_POTS;
/**
* Vanilla item tag representing all items which tempt axolotls.
*
* @deprecated use {@link #ITEMS_AXOLOTL_FOOD}
*/
@Deprecated
Tag<Material> AXOLOTL_TEMPT_ITEMS = ITEMS_AXOLOTL_FOOD;
/**
* Vanilla tag representing entities which deflect arrows.
* @deprecated use {@link #ENTITY_TYPES_DEFLECTS_PROJECTILES}
*/
@Deprecated
Tag<EntityType> ENTITY_TYPES_DEFLECTS_ARROWS = ENTITY_TYPES_DEFLECTS_PROJECTILES;
/**
* Returns whether or not this tag has an entry for the specified item.
*
* @param item to check
* @return if it is tagged
*/
boolean isTagged(@NotNull T item);
/**
* Gets an immutable set of all tagged items.
*
* @return set of tagged items
*/
@NotNull
Set<T> getValues();
}

View File

@ -0,0 +1,113 @@
package org.bukkit.attribute;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Translatable;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
/**
* Types of attributes which may be present on an {@link Attributable}.
*/
public interface Attribute extends OldEnum<Attribute>, Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
// Paper start - Generated/Attribute
// @GeneratedFrom 1.21.3
Attribute ARMOR = getAttribute("armor");
Attribute ARMOR_TOUGHNESS = getAttribute("armor_toughness");
Attribute ATTACK_DAMAGE = getAttribute("attack_damage");
Attribute ATTACK_KNOCKBACK = getAttribute("attack_knockback");
Attribute ATTACK_SPEED = getAttribute("attack_speed");
Attribute BLOCK_BREAK_SPEED = getAttribute("block_break_speed");
Attribute BLOCK_INTERACTION_RANGE = getAttribute("block_interaction_range");
Attribute BURNING_TIME = getAttribute("burning_time");
Attribute ENTITY_INTERACTION_RANGE = getAttribute("entity_interaction_range");
Attribute EXPLOSION_KNOCKBACK_RESISTANCE = getAttribute("explosion_knockback_resistance");
Attribute FALL_DAMAGE_MULTIPLIER = getAttribute("fall_damage_multiplier");
Attribute FLYING_SPEED = getAttribute("flying_speed");
Attribute FOLLOW_RANGE = getAttribute("follow_range");
Attribute GRAVITY = getAttribute("gravity");
Attribute JUMP_STRENGTH = getAttribute("jump_strength");
Attribute KNOCKBACK_RESISTANCE = getAttribute("knockback_resistance");
Attribute LUCK = getAttribute("luck");
Attribute MAX_ABSORPTION = getAttribute("max_absorption");
Attribute MAX_HEALTH = getAttribute("max_health");
Attribute MINING_EFFICIENCY = getAttribute("mining_efficiency");
Attribute MOVEMENT_EFFICIENCY = getAttribute("movement_efficiency");
Attribute MOVEMENT_SPEED = getAttribute("movement_speed");
Attribute OXYGEN_BONUS = getAttribute("oxygen_bonus");
Attribute SAFE_FALL_DISTANCE = getAttribute("safe_fall_distance");
Attribute SCALE = getAttribute("scale");
Attribute SNEAKING_SPEED = getAttribute("sneaking_speed");
Attribute SPAWN_REINFORCEMENTS = getAttribute("spawn_reinforcements");
Attribute STEP_HEIGHT = getAttribute("step_height");
Attribute SUBMERGED_MINING_SPEED = getAttribute("submerged_mining_speed");
Attribute SWEEPING_DAMAGE_RATIO = getAttribute("sweeping_damage_ratio");
Attribute TEMPT_RANGE = getAttribute("tempt_range");
Attribute WATER_MOVEMENT_EFFICIENCY = getAttribute("water_movement_efficiency");
// Paper end - Generated/Attribute
@NotNull
private static Attribute getAttribute(@NotNull String key) {
return Registry.ATTRIBUTE.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* @param name of the attribute.
* @return the attribute with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Attribute valueOf(@NotNull String name) {
Attribute attribute = Bukkit.getUnsafe().get(Registry.ATTRIBUTE, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(attribute != null, "No attribute found with the name %s", name);
return attribute;
}
/**
* @return an array of all known attributes.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Attribute[] values() {
return Lists.newArrayList(Registry.ATTRIBUTE).toArray(new Attribute[0]);
}
}

View File

@ -0,0 +1,208 @@
package org.bukkit.block;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.Bukkit;
import org.bukkit.FeatureFlag;
import org.bukkit.Keyed;
import org.bukkit.MinecraftExperimental;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.packs.DataPack;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* Holds all accepted Biomes in the server.
* <p>
* The Biomes listed in this interface are present in the default server
* or can be enabled via a {@link FeatureFlag}.
* There may be additional biomes present in the server, for example from a {@link DataPack}
* which can be accessed via {@link Registry#BIOME}.
*/
public interface Biome extends OldEnum<Biome>, Keyed, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
// Paper start - Generated/Biome
// @GeneratedFrom 1.21.3
Biome BADLANDS = getBiome("badlands");
Biome BAMBOO_JUNGLE = getBiome("bamboo_jungle");
Biome BASALT_DELTAS = getBiome("basalt_deltas");
Biome BEACH = getBiome("beach");
Biome BIRCH_FOREST = getBiome("birch_forest");
Biome CHERRY_GROVE = getBiome("cherry_grove");
Biome COLD_OCEAN = getBiome("cold_ocean");
Biome CRIMSON_FOREST = getBiome("crimson_forest");
Biome DARK_FOREST = getBiome("dark_forest");
Biome DEEP_COLD_OCEAN = getBiome("deep_cold_ocean");
Biome DEEP_DARK = getBiome("deep_dark");
Biome DEEP_FROZEN_OCEAN = getBiome("deep_frozen_ocean");
Biome DEEP_LUKEWARM_OCEAN = getBiome("deep_lukewarm_ocean");
Biome DEEP_OCEAN = getBiome("deep_ocean");
Biome DESERT = getBiome("desert");
Biome DRIPSTONE_CAVES = getBiome("dripstone_caves");
Biome END_BARRENS = getBiome("end_barrens");
Biome END_HIGHLANDS = getBiome("end_highlands");
Biome END_MIDLANDS = getBiome("end_midlands");
Biome ERODED_BADLANDS = getBiome("eroded_badlands");
Biome FLOWER_FOREST = getBiome("flower_forest");
Biome FOREST = getBiome("forest");
Biome FROZEN_OCEAN = getBiome("frozen_ocean");
Biome FROZEN_PEAKS = getBiome("frozen_peaks");
Biome FROZEN_RIVER = getBiome("frozen_river");
Biome GROVE = getBiome("grove");
Biome ICE_SPIKES = getBiome("ice_spikes");
Biome JAGGED_PEAKS = getBiome("jagged_peaks");
Biome JUNGLE = getBiome("jungle");
Biome LUKEWARM_OCEAN = getBiome("lukewarm_ocean");
Biome LUSH_CAVES = getBiome("lush_caves");
Biome MANGROVE_SWAMP = getBiome("mangrove_swamp");
Biome MEADOW = getBiome("meadow");
Biome MUSHROOM_FIELDS = getBiome("mushroom_fields");
Biome NETHER_WASTES = getBiome("nether_wastes");
Biome OCEAN = getBiome("ocean");
Biome OLD_GROWTH_BIRCH_FOREST = getBiome("old_growth_birch_forest");
Biome OLD_GROWTH_PINE_TAIGA = getBiome("old_growth_pine_taiga");
Biome OLD_GROWTH_SPRUCE_TAIGA = getBiome("old_growth_spruce_taiga");
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
@ApiStatus.Experimental
Biome PALE_GARDEN = getBiome("pale_garden");
Biome PLAINS = getBiome("plains");
Biome RIVER = getBiome("river");
Biome SAVANNA = getBiome("savanna");
Biome SAVANNA_PLATEAU = getBiome("savanna_plateau");
Biome SMALL_END_ISLANDS = getBiome("small_end_islands");
Biome SNOWY_BEACH = getBiome("snowy_beach");
Biome SNOWY_PLAINS = getBiome("snowy_plains");
Biome SNOWY_SLOPES = getBiome("snowy_slopes");
Biome SNOWY_TAIGA = getBiome("snowy_taiga");
Biome SOUL_SAND_VALLEY = getBiome("soul_sand_valley");
Biome SPARSE_JUNGLE = getBiome("sparse_jungle");
Biome STONY_PEAKS = getBiome("stony_peaks");
Biome STONY_SHORE = getBiome("stony_shore");
Biome SUNFLOWER_PLAINS = getBiome("sunflower_plains");
Biome SWAMP = getBiome("swamp");
Biome TAIGA = getBiome("taiga");
Biome THE_END = getBiome("the_end");
Biome THE_VOID = getBiome("the_void");
Biome WARM_OCEAN = getBiome("warm_ocean");
Biome WARPED_FOREST = getBiome("warped_forest");
Biome WINDSWEPT_FOREST = getBiome("windswept_forest");
Biome WINDSWEPT_GRAVELLY_HILLS = getBiome("windswept_gravelly_hills");
Biome WINDSWEPT_HILLS = getBiome("windswept_hills");
Biome WINDSWEPT_SAVANNA = getBiome("windswept_savanna");
Biome WOODED_BADLANDS = getBiome("wooded_badlands");
// Paper end - Generated/Biome
/**
* Represents a custom Biome
*
* @deprecated Biome is no longer an enum, custom biomes will have their own biome instance.
*/
@Deprecated(since = "1.21.3", forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
Biome CUSTOM = Bukkit.getUnsafe().getCustomBiome();
@NotNull
private static Biome getBiome(@NotNull String key) {
return Registry.BIOME.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* @param name of the biome.
* @return the biome with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21.3", forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Biome valueOf(@NotNull String name) {
if ("CUSTOM".equals(name)) {
return Biome.CUSTOM;
}
Biome biome = Bukkit.getUnsafe().get(Registry.BIOME, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(biome != null, "No biome found with the name %s", name);
return biome;
}
/**
* @return an array of all known biomes.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Biome[] values() {
return Lists.newArrayList(Registry.BIOME).toArray(new Biome[0]);
}
// Paper start
@Override
default @NotNull String translationKey() {
return "biome.minecraft." + this.getKey().getKey();
}
// Paper end
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,180 @@
package org.bukkit.block.banner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface PatternType extends OldEnum<PatternType>, Keyed {
// Paper start - Generated/PatternType
// @GeneratedFrom 1.21.3
PatternType BASE = getType("base");
PatternType BORDER = getType("border");
PatternType BRICKS = getType("bricks");
PatternType CIRCLE = getType("circle");
PatternType CREEPER = getType("creeper");
PatternType CROSS = getType("cross");
PatternType CURLY_BORDER = getType("curly_border");
PatternType DIAGONAL_LEFT = getType("diagonal_left");
PatternType DIAGONAL_RIGHT = getType("diagonal_right");
PatternType DIAGONAL_UP_LEFT = getType("diagonal_up_left");
PatternType DIAGONAL_UP_RIGHT = getType("diagonal_up_right");
PatternType FLOW = getType("flow");
PatternType FLOWER = getType("flower");
PatternType GLOBE = getType("globe");
PatternType GRADIENT = getType("gradient");
PatternType GRADIENT_UP = getType("gradient_up");
PatternType GUSTER = getType("guster");
PatternType HALF_HORIZONTAL = getType("half_horizontal");
PatternType HALF_HORIZONTAL_BOTTOM = getType("half_horizontal_bottom");
PatternType HALF_VERTICAL = getType("half_vertical");
PatternType HALF_VERTICAL_RIGHT = getType("half_vertical_right");
PatternType MOJANG = getType("mojang");
PatternType PIGLIN = getType("piglin");
PatternType RHOMBUS = getType("rhombus");
PatternType SKULL = getType("skull");
PatternType SMALL_STRIPES = getType("small_stripes");
PatternType SQUARE_BOTTOM_LEFT = getType("square_bottom_left");
PatternType SQUARE_BOTTOM_RIGHT = getType("square_bottom_right");
PatternType SQUARE_TOP_LEFT = getType("square_top_left");
PatternType SQUARE_TOP_RIGHT = getType("square_top_right");
PatternType STRAIGHT_CROSS = getType("straight_cross");
PatternType STRIPE_BOTTOM = getType("stripe_bottom");
PatternType STRIPE_CENTER = getType("stripe_center");
PatternType STRIPE_DOWNLEFT = getType("stripe_downleft");
PatternType STRIPE_DOWNRIGHT = getType("stripe_downright");
PatternType STRIPE_LEFT = getType("stripe_left");
PatternType STRIPE_MIDDLE = getType("stripe_middle");
PatternType STRIPE_RIGHT = getType("stripe_right");
PatternType STRIPE_TOP = getType("stripe_top");
PatternType TRIANGLE_BOTTOM = getType("triangle_bottom");
PatternType TRIANGLE_TOP = getType("triangle_top");
PatternType TRIANGLES_BOTTOM = getType("triangles_bottom");
PatternType TRIANGLES_TOP = getType("triangles_top");
// Paper end - Generated/PatternType
// Paper start - deprecate getKey
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#BANNER_PATTERN}. PatternTypes can exist without a key.
*/
@Deprecated(since = "1.20.5")
// Paper end - deprecate getKey
@Override
@NotNull
public NamespacedKey getKey();
/**
* Returns the identifier used to represent
* this pattern type
*
* @return the pattern's identifier
* @see #getKey
* @deprecated magic value
*/
@NotNull
@Deprecated(forRemoval = true)
public String getIdentifier();
/**
* Returns the pattern type which matches the passed
* identifier or null if no matches are found
*
* @param identifier the identifier
* @return the matched pattern type or null
* @see Registry#BANNER_PATTERN
* @deprecated magic value, use {@link Registry#get(NamespacedKey)} instead
*/
@Contract("null -> null")
@Nullable
@Deprecated(forRemoval = true)
public static PatternType getByIdentifier(@Nullable String identifier) {
if (identifier == null) {
return null;
}
for (PatternType type : Registry.BANNER_PATTERN) {
if (identifier.equals(type.getIdentifier())) {
return type;
}
}
return null;
}
@NotNull
private static PatternType getType(@NotNull String key) {
return Registry.BANNER_PATTERN.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* @param name of the pattern type.
* @return the pattern type with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static PatternType valueOf(@NotNull String name) {
PatternType type = Registry.BANNER_PATTERN.get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(type != null, "No pattern type found with the name %s", name);
return type;
}
/**
* @return an array of all known pattern types.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static PatternType[] values() {
return Lists.newArrayList(Registry.BANNER_PATTERN).toArray(new PatternType[0]);
}
}

View File

@ -0,0 +1,171 @@
package org.bukkit.damage;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Translatable;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* Represent a type of damage that an entity can receive.
* <p>
* Constants in this class include the base types provided by the vanilla
* server. Data packs are capable of registering more types of damage which may
* be obtained through the {@link Registry#DAMAGE_TYPE}.
*
* @see <a href="https://minecraft.wiki/w/Damage_type">Minecraft Wiki</a>
*/
@ApiStatus.Experimental
public interface DamageType extends Keyed, Translatable {
// Paper start - Generated/DamageType
// @GeneratedFrom 1.21.3
DamageType ARROW = getDamageType("arrow");
DamageType BAD_RESPAWN_POINT = getDamageType("bad_respawn_point");
DamageType CACTUS = getDamageType("cactus");
DamageType CAMPFIRE = getDamageType("campfire");
DamageType CRAMMING = getDamageType("cramming");
DamageType DRAGON_BREATH = getDamageType("dragon_breath");
DamageType DROWN = getDamageType("drown");
DamageType DRY_OUT = getDamageType("dry_out");
DamageType ENDER_PEARL = getDamageType("ender_pearl");
DamageType EXPLOSION = getDamageType("explosion");
DamageType FALL = getDamageType("fall");
DamageType FALLING_ANVIL = getDamageType("falling_anvil");
DamageType FALLING_BLOCK = getDamageType("falling_block");
DamageType FALLING_STALACTITE = getDamageType("falling_stalactite");
DamageType FIREBALL = getDamageType("fireball");
DamageType FIREWORKS = getDamageType("fireworks");
DamageType FLY_INTO_WALL = getDamageType("fly_into_wall");
DamageType FREEZE = getDamageType("freeze");
DamageType GENERIC = getDamageType("generic");
DamageType GENERIC_KILL = getDamageType("generic_kill");
DamageType HOT_FLOOR = getDamageType("hot_floor");
DamageType IN_FIRE = getDamageType("in_fire");
DamageType IN_WALL = getDamageType("in_wall");
DamageType INDIRECT_MAGIC = getDamageType("indirect_magic");
DamageType LAVA = getDamageType("lava");
DamageType LIGHTNING_BOLT = getDamageType("lightning_bolt");
DamageType MACE_SMASH = getDamageType("mace_smash");
DamageType MAGIC = getDamageType("magic");
DamageType MOB_ATTACK = getDamageType("mob_attack");
DamageType MOB_ATTACK_NO_AGGRO = getDamageType("mob_attack_no_aggro");
DamageType MOB_PROJECTILE = getDamageType("mob_projectile");
DamageType ON_FIRE = getDamageType("on_fire");
DamageType OUT_OF_WORLD = getDamageType("out_of_world");
DamageType OUTSIDE_BORDER = getDamageType("outside_border");
DamageType PLAYER_ATTACK = getDamageType("player_attack");
DamageType PLAYER_EXPLOSION = getDamageType("player_explosion");
DamageType SONIC_BOOM = getDamageType("sonic_boom");
DamageType SPIT = getDamageType("spit");
DamageType STALAGMITE = getDamageType("stalagmite");
DamageType STARVE = getDamageType("starve");
DamageType STING = getDamageType("sting");
DamageType SWEET_BERRY_BUSH = getDamageType("sweet_berry_bush");
DamageType THORNS = getDamageType("thorns");
DamageType THROWN = getDamageType("thrown");
DamageType TRIDENT = getDamageType("trident");
DamageType UNATTRIBUTED_FIREBALL = getDamageType("unattributed_fireball");
DamageType WIND_CHARGE = getDamageType("wind_charge");
DamageType WITHER = getDamageType("wither");
DamageType WITHER_SKULL = getDamageType("wither_skull");
// Paper end - Generated/DamageType
@NotNull
private static DamageType getDamageType(@NotNull String key) {
return Registry.DAMAGE_TYPE.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* {@inheritDoc}
* <p>
* The returned key is that of the death message sent when this damage type
* is responsible for the death of an entity.
* <p>
* <strong>Note</strong> This translation key is only used if
* {@link #getDeathMessageType()} is {@link DeathMessageType#DEFAULT}
*/
@NotNull
@Override
public String getTranslationKey();
/**
* Get the {@link DamageScaling} for this damage type.
*
* @return the damage scaling
*/
@NotNull
public DamageScaling getDamageScaling();
/**
* Get the {@link DamageEffect} for this damage type.
*
* @return the damage effect
*/
@NotNull
public DamageEffect getDamageEffect();
/**
* Get the {@link DeathMessageType} for this damage type.
*
* @return the death message type
*/
@NotNull
public DeathMessageType getDeathMessageType();
/**
* Get the amount of hunger exhaustion caused by this damage type.
*
* @return the exhaustion
*/
public float getExhaustion();
}

View File

@ -0,0 +1,198 @@
package org.bukkit.entity;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.jetbrains.annotations.NotNull;
/**
* Represents a boat entity.
*/
public interface Boat extends Vehicle, io.papermc.paper.entity.Leashable { // Paper - Leashable API
/**
* Gets the wood type of the boat.
*
* @return the wood type
* @deprecated deprecated in favor of {@link #getBoatType()}
*/
@Deprecated
@NotNull
TreeSpecies getWoodType();
/**
* Sets the wood type of the boat.
*
* @param species the new wood type
* @deprecated deprecated in favor of {@link #setBoatType(Type)}
*/
@Deprecated
void setWoodType(@NotNull TreeSpecies species);
/**
* Gets the type of the boat.
*
* @return the boat type
* @deprecated different boats types are now different entity types
*/
@Deprecated
@NotNull
Type getBoatType();
/**
* Sets the type of the boat.
*
* @param type the new type
* @deprecated different boats types are now different entity types
*/
@Deprecated
void setBoatType(@NotNull Type type);
/**
* Gets the maximum speed of a boat. The speed is unrelated to the
* velocity.
*
* @return The max speed.
* @deprecated boats are complex and many of these methods do not work correctly across multiple versions.
*/
@Deprecated
public double getMaxSpeed();
/**
* Sets the maximum speed of a boat. Must be nonnegative. Default is 0.4D.
*
* @param speed The max speed.
* @deprecated boats are complex and many of these methods do not work correctly across multiple versions.
*/
@Deprecated
public void setMaxSpeed(double speed);
/**
* Gets the deceleration rate (newSpeed = curSpeed * rate) of occupied
* boats. The default is 0.2.
*
* @return The rate of deceleration
* @deprecated boats are complex and many of these methods do not work correctly across multiple versions.
*/
@Deprecated
public double getOccupiedDeceleration();
/**
* Sets the deceleration rate (newSpeed = curSpeed * rate) of occupied
* boats. Setting this to a higher value allows for quicker acceleration.
* The default is 0.2.
*
* @param rate deceleration rate
* @deprecated boats are complex and many of these methods do not work correctly across multiple versions.
*/
@Deprecated
public void setOccupiedDeceleration(double rate);
/**
* Gets the deceleration rate (newSpeed = curSpeed * rate) of unoccupied
* boats. The default is -1. Values below 0 indicate that no additional
* deceleration is imposed.
*
* @return The rate of deceleration
* @deprecated boats are complex and many of these methods do not work correctly across multiple versions.
*/
@Deprecated
public double getUnoccupiedDeceleration();
/**
* Sets the deceleration rate (newSpeed = curSpeed * rate) of unoccupied
* boats. Setting this to a higher value allows for quicker deceleration
* of boats when a player disembarks. The default is -1. Values below 0
* indicate that no additional deceleration is imposed.
*
* @param rate deceleration rate
* @deprecated boats are complex and many of these methods do not work correctly across multiple versions.
*/
@Deprecated
public void setUnoccupiedDeceleration(double rate);
/**
* Get whether boats can work on land.
*
* @return whether boats can work on land
* @deprecated boats are complex and many of these methods do not work correctly across multiple versions.
*/
@Deprecated
public boolean getWorkOnLand();
/**
* Set whether boats can work on land.
*
* @param workOnLand whether boats can work on land
* @deprecated boats are complex and many of these methods do not work correctly across multiple versions.
*/
@Deprecated
public void setWorkOnLand(boolean workOnLand);
/**
* Gets the status of the boat.
*
* @return the status
*/
@NotNull
public Status getStatus();
/**
* Represents the type of boats.
* @deprecated different boats types are now different entity types
*/
@Deprecated
public enum Type {
OAK(Material.OAK_PLANKS),
SPRUCE(Material.SPRUCE_PLANKS),
BIRCH(Material.BIRCH_PLANKS),
JUNGLE(Material.JUNGLE_PLANKS),
ACACIA(Material.ACACIA_PLANKS),
CHERRY(Material.CHERRY_PLANKS),
DARK_OAK(Material.DARK_OAK_PLANKS),
MANGROVE(Material.MANGROVE_PLANKS),
BAMBOO(Material.BAMBOO_PLANKS),
;
private final Material materialBlock;
private Type(Material materialBlock) {
this.materialBlock = materialBlock;
}
/**
* Gets the material of the boat type.
*
* @return a material
*/
@NotNull
public Material getMaterial() {
return this.materialBlock;
}
}
/**
* Represents the status of the boat.
*/
public enum Status {
NOT_IN_WORLD, // Paper
// Paper start - Generated/BoatStatus
// @GeneratedFrom 1.21.3
IN_WATER,
UNDER_WATER,
UNDER_FLOWING_WATER,
ON_LAND,
IN_AIR;
// Paper end - Generated/BoatStatus
}
// Paper start
/**
* Gets the {@link Material} that represents this Boat type.
*
* @return the boat material.
*/
@NotNull
public Material getBoatMaterial();
// Paper end
}

View File

@ -0,0 +1,140 @@
package org.bukkit.entity;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.DyeColor;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
/**
* Meow.
*/
public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarColorable { // Paper - CollarColorable
/**
* Gets the current type of this cat.
*
* @return Type of the cat.
*/
@NotNull
public Type getCatType();
/**
* Sets the current type of this cat.
*
* @param type New type of this cat.
*/
public void setCatType(@NotNull Type type);
/**
* Get the collar color of this cat
*
* @return the color of the collar
*/
@NotNull
@Override // Paper
public DyeColor getCollarColor();
/**
* Set the collar color of this cat
*
* @param color the color to apply
*/
@Override // Paper
public void setCollarColor(@NotNull DyeColor color);
/**
* Represents the various different cat types there are.
*/
interface Type extends OldEnum<Type>, Keyed {
// Paper start - Generated/CatType
// @GeneratedFrom 1.21.3
Type ALL_BLACK = getType("all_black");
Type BLACK = getType("black");
Type BRITISH_SHORTHAIR = getType("british_shorthair");
Type CALICO = getType("calico");
Type JELLIE = getType("jellie");
Type PERSIAN = getType("persian");
Type RAGDOLL = getType("ragdoll");
Type RED = getType("red");
Type SIAMESE = getType("siamese");
Type TABBY = getType("tabby");
Type WHITE = getType("white");
// Paper end - Generated/CatType
@NotNull
private static Type getType(@NotNull String key) {
return Registry.CAT_VARIANT.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* @param name of the cat type.
* @return the cat type with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Type valueOf(@NotNull String name) {
Type type = Registry.CAT_VARIANT.get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(type != null, "No cat type found with the name %s", name);
return type;
}
/**
* @return an array of all known cat types.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Type[] values() {
return Lists.newArrayList(Registry.CAT_VARIANT).toArray(new Type[0]);
}
}
// Paper start - More cat api
/**
* Sets if the cat is lying down.
* This is visual and does not affect the behaviour of the cat.
*
* @param lyingDown whether the cat should lie down
*/
public void setLyingDown(boolean lyingDown);
/**
* Gets if the cat is lying down.
*
* @return whether the cat is lying down
*/
public boolean isLyingDown();
/**
* Sets if the cat has its head up.
* This is visual and does not affect the behaviour of the cat.
*
* @param headUp head is up
*/
public void setHeadUp(boolean headUp);
/**
* Gets if the cat has its head up.
*
* @return head is up
*/
public boolean isHeadUp();
// Paper end - More cat api
}

View File

@ -0,0 +1,382 @@
package org.bukkit.entity;
import com.google.common.base.Preconditions;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
import org.bukkit.Location;
import org.bukkit.MinecraftExperimental;
import org.bukkit.NamespacedKey;
import org.bukkit.Translatable;
import org.bukkit.World;
import org.bukkit.entity.boat.AcaciaBoat;
import org.bukkit.entity.boat.AcaciaChestBoat;
import org.bukkit.entity.boat.BambooChestRaft;
import org.bukkit.entity.boat.BambooRaft;
import org.bukkit.entity.boat.BirchBoat;
import org.bukkit.entity.boat.BirchChestBoat;
import org.bukkit.entity.boat.CherryBoat;
import org.bukkit.entity.boat.CherryChestBoat;
import org.bukkit.entity.boat.DarkOakBoat;
import org.bukkit.entity.boat.DarkOakChestBoat;
import org.bukkit.entity.boat.JungleBoat;
import org.bukkit.entity.boat.JungleChestBoat;
import org.bukkit.entity.boat.MangroveBoat;
import org.bukkit.entity.boat.MangroveChestBoat;
import org.bukkit.entity.boat.OakBoat;
import org.bukkit.entity.boat.OakChestBoat;
import org.bukkit.entity.boat.PaleOakBoat;
import org.bukkit.entity.boat.PaleOakChestBoat;
import org.bukkit.entity.boat.SpruceBoat;
import org.bukkit.entity.boat.SpruceChestBoat;
import org.bukkit.entity.minecart.CommandMinecart;
import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.entity.minecart.PoweredMinecart;
import org.bukkit.entity.minecart.RideableMinecart;
import org.bukkit.entity.minecart.SpawnerMinecart;
import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public enum EntityType implements Keyed, Translatable, net.kyori.adventure.translation.Translatable, io.papermc.paper.world.flag.FeatureDependant { // Paper - translatable
// These strings MUST match the strings in nms.EntityTypes and are case sensitive.
// Paper start - Generated/EntityType
// @GeneratedFrom 1.21.3
ACACIA_BOAT("acacia_boat", AcaciaBoat.class, -1),
ACACIA_CHEST_BOAT("acacia_chest_boat", AcaciaChestBoat.class, -1),
ALLAY("allay", Allay.class, -1),
AREA_EFFECT_CLOUD("area_effect_cloud", AreaEffectCloud.class, 3),
ARMADILLO("armadillo", Armadillo.class, -1),
ARMOR_STAND("armor_stand", ArmorStand.class, 30),
ARROW("arrow", Arrow.class, 10),
AXOLOTL("axolotl", Axolotl.class, -1),
BAMBOO_CHEST_RAFT("bamboo_chest_raft", BambooChestRaft.class, -1),
BAMBOO_RAFT("bamboo_raft", BambooRaft.class, -1),
BAT("bat", Bat.class, 65),
BEE("bee", Bee.class, -1),
BIRCH_BOAT("birch_boat", BirchBoat.class, -1),
BIRCH_CHEST_BOAT("birch_chest_boat", BirchChestBoat.class, -1),
BLAZE("blaze", Blaze.class, 61),
BLOCK_DISPLAY("block_display", BlockDisplay.class, -1),
BOGGED("bogged", Bogged.class, -1),
BREEZE("breeze", Breeze.class, -1),
BREEZE_WIND_CHARGE("breeze_wind_charge", BreezeWindCharge.class, -1),
CAMEL("camel", Camel.class, -1),
CAT("cat", Cat.class, -1),
CAVE_SPIDER("cave_spider", CaveSpider.class, 59),
CHERRY_BOAT("cherry_boat", CherryBoat.class, -1),
CHERRY_CHEST_BOAT("cherry_chest_boat", CherryChestBoat.class, -1),
CHEST_MINECART("chest_minecart", StorageMinecart.class, 43),
CHICKEN("chicken", Chicken.class, 93),
COD("cod", Cod.class, -1),
COMMAND_BLOCK_MINECART("command_block_minecart", CommandMinecart.class, 40),
COW("cow", Cow.class, 92),
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
@ApiStatus.Experimental
CREAKING("creaking", Creaking.class, -1),
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
@ApiStatus.Experimental
CREAKING_TRANSIENT("creaking_transient", CreakingTransient.class, -1, false),
CREEPER("creeper", Creeper.class, 50),
DARK_OAK_BOAT("dark_oak_boat", DarkOakBoat.class, -1),
DARK_OAK_CHEST_BOAT("dark_oak_chest_boat", DarkOakChestBoat.class, -1),
DOLPHIN("dolphin", Dolphin.class, -1),
DONKEY("donkey", Donkey.class, 31),
DRAGON_FIREBALL("dragon_fireball", DragonFireball.class, 26),
DROWNED("drowned", Drowned.class, -1),
EGG("egg", Egg.class, 7),
ELDER_GUARDIAN("elder_guardian", ElderGuardian.class, 4),
END_CRYSTAL("end_crystal", EnderCrystal.class, 200),
ENDER_DRAGON("ender_dragon", EnderDragon.class, 63),
ENDER_PEARL("ender_pearl", EnderPearl.class, 14),
ENDERMAN("enderman", Enderman.class, 58),
ENDERMITE("endermite", Endermite.class, 67),
EVOKER("evoker", Evoker.class, 34),
EVOKER_FANGS("evoker_fangs", EvokerFangs.class, 33),
EXPERIENCE_BOTTLE("experience_bottle", ThrownExpBottle.class, 17),
EXPERIENCE_ORB("experience_orb", ExperienceOrb.class, 2),
EYE_OF_ENDER("eye_of_ender", EnderSignal.class, 15),
FALLING_BLOCK("falling_block", FallingBlock.class, 21),
FIREBALL("fireball", Fireball.class, 12),
FIREWORK_ROCKET("firework_rocket", Firework.class, 22),
FISHING_BOBBER("fishing_bobber", FishHook.class, -1, false),
FOX("fox", Fox.class, -1),
FROG("frog", Frog.class, -1),
FURNACE_MINECART("furnace_minecart", PoweredMinecart.class, 44),
GHAST("ghast", Ghast.class, 56),
GIANT("giant", Giant.class, 53),
GLOW_ITEM_FRAME("glow_item_frame", GlowItemFrame.class, -1),
GLOW_SQUID("glow_squid", GlowSquid.class, -1),
GOAT("goat", Goat.class, -1),
GUARDIAN("guardian", Guardian.class, 68),
HOGLIN("hoglin", Hoglin.class, -1),
HOPPER_MINECART("hopper_minecart", HopperMinecart.class, 46),
HORSE("horse", Horse.class, 100),
HUSK("husk", Husk.class, 23),
ILLUSIONER("illusioner", Illusioner.class, 37),
INTERACTION("interaction", Interaction.class, -1),
IRON_GOLEM("iron_golem", IronGolem.class, 99),
ITEM("item", Item.class, 1),
ITEM_DISPLAY("item_display", ItemDisplay.class, -1),
ITEM_FRAME("item_frame", ItemFrame.class, 18),
JUNGLE_BOAT("jungle_boat", JungleBoat.class, -1),
JUNGLE_CHEST_BOAT("jungle_chest_boat", JungleChestBoat.class, -1),
LEASH_KNOT("leash_knot", LeashHitch.class, 8),
LIGHTNING_BOLT("lightning_bolt", LightningStrike.class, -1),
LLAMA("llama", Llama.class, 103),
LLAMA_SPIT("llama_spit", LlamaSpit.class, 104),
MAGMA_CUBE("magma_cube", MagmaCube.class, 62),
MANGROVE_BOAT("mangrove_boat", MangroveBoat.class, -1),
MANGROVE_CHEST_BOAT("mangrove_chest_boat", MangroveChestBoat.class, -1),
MARKER("marker", Marker.class, -1),
MINECART("minecart", Minecart.class, 42),
MOOSHROOM("mooshroom", MushroomCow.class, 96),
MULE("mule", Mule.class, 32),
OAK_BOAT("oak_boat", OakBoat.class, -1),
OAK_CHEST_BOAT("oak_chest_boat", OakChestBoat.class, -1),
OCELOT("ocelot", Ocelot.class, 98),
OMINOUS_ITEM_SPAWNER("ominous_item_spawner", OminousItemSpawner.class, -1),
PAINTING("painting", Painting.class, 9),
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
@ApiStatus.Experimental
PALE_OAK_BOAT("pale_oak_boat", PaleOakBoat.class, -1),
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
@ApiStatus.Experimental
PALE_OAK_CHEST_BOAT("pale_oak_chest_boat", PaleOakChestBoat.class, -1),
PANDA("panda", Panda.class, -1),
PARROT("parrot", Parrot.class, 105),
PHANTOM("phantom", Phantom.class, -1),
PIG("pig", Pig.class, 90),
PIGLIN("piglin", Piglin.class, -1),
PIGLIN_BRUTE("piglin_brute", PiglinBrute.class, -1),
PILLAGER("pillager", Pillager.class, -1),
PLAYER("player", Player.class, -1, false),
POLAR_BEAR("polar_bear", PolarBear.class, 102),
POTION("potion", ThrownPotion.class, 16),
PUFFERFISH("pufferfish", PufferFish.class, -1),
RABBIT("rabbit", Rabbit.class, 101),
RAVAGER("ravager", Ravager.class, -1),
SALMON("salmon", Salmon.class, -1),
SHEEP("sheep", Sheep.class, 91),
SHULKER("shulker", Shulker.class, 69),
SHULKER_BULLET("shulker_bullet", ShulkerBullet.class, 25),
SILVERFISH("silverfish", Silverfish.class, 60),
SKELETON("skeleton", Skeleton.class, 51),
SKELETON_HORSE("skeleton_horse", SkeletonHorse.class, 28),
SLIME("slime", Slime.class, 55),
SMALL_FIREBALL("small_fireball", SmallFireball.class, 13),
SNIFFER("sniffer", Sniffer.class, -1),
SNOW_GOLEM("snow_golem", Snowman.class, 97),
SNOWBALL("snowball", Snowball.class, 11),
SPAWNER_MINECART("spawner_minecart", SpawnerMinecart.class, 47),
SPECTRAL_ARROW("spectral_arrow", SpectralArrow.class, 24),
SPIDER("spider", Spider.class, 52),
SPRUCE_BOAT("spruce_boat", SpruceBoat.class, -1),
SPRUCE_CHEST_BOAT("spruce_chest_boat", SpruceChestBoat.class, -1),
SQUID("squid", Squid.class, 94),
STRAY("stray", Stray.class, 6),
STRIDER("strider", Strider.class, -1),
TADPOLE("tadpole", Tadpole.class, -1),
TEXT_DISPLAY("text_display", TextDisplay.class, -1),
TNT("tnt", TNTPrimed.class, 20),
TNT_MINECART("tnt_minecart", ExplosiveMinecart.class, 45),
TRADER_LLAMA("trader_llama", TraderLlama.class, -1),
TRIDENT("trident", Trident.class, -1),
TROPICAL_FISH("tropical_fish", TropicalFish.class, -1),
TURTLE("turtle", Turtle.class, -1),
VEX("vex", Vex.class, 35),
VILLAGER("villager", Villager.class, 120),
VINDICATOR("vindicator", Vindicator.class, 36),
WANDERING_TRADER("wandering_trader", WanderingTrader.class, -1),
WARDEN("warden", Warden.class, -1),
WIND_CHARGE("wind_charge", WindCharge.class, -1),
WITCH("witch", Witch.class, 66),
WITHER("wither", Wither.class, 64),
WITHER_SKELETON("wither_skeleton", WitherSkeleton.class, 5),
WITHER_SKULL("wither_skull", WitherSkull.class, 19),
WOLF("wolf", Wolf.class, 95),
ZOGLIN("zoglin", Zoglin.class, -1),
ZOMBIE("zombie", Zombie.class, 54),
ZOMBIE_HORSE("zombie_horse", ZombieHorse.class, 29),
ZOMBIE_VILLAGER("zombie_villager", ZombieVillager.class, 27),
ZOMBIFIED_PIGLIN("zombified_piglin", PigZombie.class, 57),
// Paper end - Generated/EntityType
/**
* An unknown entity without an Entity Class
*/
UNKNOWN(null, null, -1, false);
private final String name;
private final Class<? extends Entity> clazz;
private final short typeId;
private final boolean independent, living;
private final NamespacedKey key;
private static final Map<String, EntityType> NAME_MAP = new HashMap<String, EntityType>();
private static final Map<Short, EntityType> ID_MAP = new HashMap<Short, EntityType>();
static {
for (EntityType type : values()) {
if (type.name != null) {
NAME_MAP.put(type.name.toLowerCase(Locale.ROOT), type);
}
if (type.typeId > 0) {
ID_MAP.put(type.typeId, type);
}
}
}
private EntityType(/*@Nullable*/ String name, /*@Nullable*/ Class<? extends Entity> clazz, int typeId) {
this(name, clazz, typeId, true);
}
private EntityType(/*@Nullable*/ String name, /*@Nullable*/ Class<? extends Entity> clazz, int typeId, boolean independent) {
this.name = name;
this.clazz = clazz;
this.typeId = (short) typeId;
this.independent = independent;
this.living = clazz != null && LivingEntity.class.isAssignableFrom(clazz);
this.key = (name == null) ? null : NamespacedKey.minecraft(name);
}
/**
* Gets the entity type name.
*
* @return the entity type's name
* @deprecated Magic value
*/
@Deprecated
@Nullable
public String getName() {
return name;
}
@NotNull
@Override
public NamespacedKey getKey() {
Preconditions.checkArgument(key != null, "EntityType doesn't have key! Is it UNKNOWN?");
return key;
}
@Nullable
public Class<? extends Entity> getEntityClass() {
return clazz;
}
/**
* Gets the entity type id.
*
* @return the raw type id
* @deprecated Magic value
*/
@Deprecated
public short getTypeId() {
return typeId;
}
/**
* Gets an entity type from its name.
*
* @param name the entity type's name
* @return the matching entity type or null
* @apiNote Internal Use Only
*/
@org.jetbrains.annotations.ApiStatus.Internal // Paper
@Contract("null -> null")
@Nullable
public static EntityType fromName(@Nullable String name) {
if (name == null) {
return null;
}
return NAME_MAP.get(name.toLowerCase(Locale.ROOT));
}
/**
* Gets an entity from its id.
*
* @param id the raw type id
* @return the matching entity type or null
* @deprecated Magic value
*/
@Deprecated
@Nullable
public static EntityType fromId(int id) {
if (id > Short.MAX_VALUE) {
return null;
}
return ID_MAP.get((short) id);
}
/**
* Some entities cannot be spawned using {@link
* World#spawnEntity(Location, EntityType)} or {@link
* World#spawn(Location, Class)}, usually because they require additional
* information in order to spawn.
*
* @return False if the entity type cannot be spawned
*/
public boolean isSpawnable() {
return independent;
}
public boolean isAlive() {
return living;
}
@Override
@NotNull
@Deprecated(forRemoval = true) // Paper
public String getTranslationKey() {
return Bukkit.getUnsafe().getTranslationKey(this);
}
// Paper start
/**
* @throws IllegalArgumentException if the entity does not have a translation key (is probably a custom entity)
*/
@Override
public @NotNull String translationKey() {
Preconditions.checkArgument(this != UNKNOWN, "UNKNOWN entities do not have translation keys");
return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this);
}
/**
* Checks if the entity has default attributes.
*
* @return true if it has default attributes
*/
public boolean hasDefaultAttributes() {
return org.bukkit.Bukkit.getUnsafe().hasDefaultEntityAttributes(this.key);
}
/**
* Gets the default attributes for the entity.
*
* @return an unmodifiable instance of Attributable for reading default attributes.
* @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultAttributes()} first)
*/
public @NotNull org.bukkit.attribute.Attributable getDefaultAttributes() {
return org.bukkit.Bukkit.getUnsafe().getDefaultEntityAttributes(this.key);
}
// Paper end
/**
* Gets if this EntityType is enabled by feature in a world.
*
* @param world the world to check
* @return true if this EntityType can be used to spawn an Entity for this World.
*/
@Deprecated(forRemoval = true, since = "1.20") // Paper
public boolean isEnabledByFeature(@NotNull World world) {
return Bukkit.getDataPackManager().isEnabledByFeature(this, world);
}
}

View File

@ -0,0 +1,149 @@
package org.bukkit.entity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* What does the fox say?
*/
public interface Fox extends Animals, Sittable {
/**
* Gets the current type of this fox.
*
* @return Type of the fox.
*/
@NotNull
public Type getFoxType();
/**
* Sets the current type of this fox.
*
* @param type New type of this fox.
*/
public void setFoxType(@NotNull Type type);
/**
* Checks if this animal is crouching
*
* @return true if crouching
*/
boolean isCrouching();
/**
* Sets if this animal is crouching.
*
* @param crouching true if crouching
*/
void setCrouching(boolean crouching);
/**
* Sets if this animal is sleeping.
*
* @param sleeping true if sleeping
*/
void setSleeping(boolean sleeping);
/**
* Gets the first trusted player.
*
* @return the owning AnimalTamer, or null if not owned
*/
@Nullable
public AnimalTamer getFirstTrustedPlayer();
/**
* Set the first trusted player.
* <p>
* The first trusted player may only be removed after the second.
*
* @param player the AnimalTamer to be trusted
*/
public void setFirstTrustedPlayer(@Nullable AnimalTamer player);
/**
* Gets the second trusted player.
*
* @return the owning AnimalTamer, or null if not owned
*/
@Nullable
public AnimalTamer getSecondTrustedPlayer();
/**
* Set the second trusted player.
* <p>
* The second trusted player may only be added after the first.
*
* @param player the AnimalTamer to be trusted
*/
public void setSecondTrustedPlayer(@Nullable AnimalTamer player);
/**
* Gets whether the fox is faceplanting the ground
*
* @return Whether the fox is faceplanting the ground
*/
boolean isFaceplanted();
/**
* Represents the various different fox types there are.
*/
public enum Type {
// Paper start - Generated/FoxType
// @GeneratedFrom 1.21.3
RED,
SNOW;
// Paper end - Generated/FoxType
}
// Paper start - Add more fox behavior API
/**
* Sets if the fox is interested.
*
* @param interested is interested
*/
public void setInterested(boolean interested);
/**
* Gets if the fox is interested.
*
* @return fox is interested
*/
public boolean isInterested();
/**
* Sets if the fox is leaping.
*
* @param leaping is leaping
*/
public void setLeaping(boolean leaping);
/**
* Gets if the fox is leaping.
*
* @return fox is leaping
*/
public boolean isLeaping();
/**
* Sets if the fox is defending.
*
* @param defending is defending
*/
public void setDefending(boolean defending);
/**
* Gets if the fox is defending.
*
* @return fox is defending
*/
public boolean isDefending();
/**
* Sets if the fox face planted.
*
* @param faceplanted face planted
*/
public void setFaceplanted(boolean faceplanted);
// Paper end - Add more fox behavior API
}

View File

@ -0,0 +1,90 @@
package org.bukkit.entity;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* A Frog.
*/
public interface Frog extends Animals {
/**
* Gets the tongue target of this frog.
*
* @return tongue target or null if not set
*/
@Nullable
Entity getTongueTarget();
/**
* Sets the tongue target of this frog.
*
* @param target tongue target or null to clear
*/
void setTongueTarget(@Nullable Entity target);
/**
* Get the variant of this frog.
*
* @return frog variant
*/
@NotNull
Variant getVariant();
/**
* Set the variant of this frog.
*
* @param variant frog variant
*/
void setVariant(@NotNull Variant variant);
/**
* Represents the variant of a frog - ie its color.
*/
interface Variant extends OldEnum<Variant>, Keyed {
// Paper start - Generated/FrogVariant
// @GeneratedFrom 1.21.3
Variant COLD = getVariant("cold");
Variant TEMPERATE = getVariant("temperate");
Variant WARM = getVariant("warm");
// Paper end - Generated/FrogVariant
@NotNull
private static Variant getVariant(@NotNull String key) {
return Registry.FROG_VARIANT.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* @param name of the frog variant.
* @return the frog variant with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Variant valueOf(@NotNull String name) {
Variant variant = Registry.FROG_VARIANT.get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(variant != null, "No frog variant found with the name %s", name);
return variant;
}
/**
* @return an array of all known frog variants.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Variant[] values() {
return Lists.newArrayList(Registry.FROG_VARIANT).toArray(new Variant[0]);
}
}
}

View File

@ -0,0 +1,231 @@
package org.bukkit.entity;
import org.jetbrains.annotations.NotNull;
/**
* Panda entity.
*/
public interface Panda extends Animals, Sittable {
/**
* Gets this Panda's main gene.
*
* @return main gene
*/
@NotNull
Gene getMainGene();
/**
* Sets this Panda's main gene.
*
* @param gene main gene
*/
void setMainGene(@NotNull Gene gene);
/**
* Gets this Panda's hidden gene.
*
* @return hidden gene
*/
@NotNull
Gene getHiddenGene();
/**
* Sets this Panda's hidden gene.
*
* @param gene hidden gene
*/
void setHiddenGene(@NotNull Gene gene);
/**
* Gets whether the Panda is rolling
*
* @return Whether the Panda is rolling
*/
boolean isRolling();
/**
* Sets whether the Panda is rolling
*
* @param flag Whether the Panda is rolling
*/
void setRolling(boolean flag);
/**
* Gets whether the Panda is sneezing
*
* @return Whether the Panda is sneezing
*/
boolean isSneezing();
/**
* Sets whether the Panda is sneezing
*
* @param flag Whether the Panda is sneezing
*/
void setSneezing(boolean flag);
/**
* Gets whether the Panda is on its back
*
* @return Whether the Panda is on its back
*/
boolean isOnBack();
/**
* Sets whether the Panda is on its back
*
* @param flag Whether the Panda is on its back
*/
void setOnBack(boolean flag);
/**
* Gets whether the Panda is eating
*
* @return Whether the Panda is eating
*/
boolean isEating();
/**
* Sets the Panda's eating status. The panda must be holding food for this to work
*
* @param flag Whether the Panda is eating
*/
void setEating(boolean flag);
/**
* Gets whether the Panda is scared
*
* @return Whether the Panda is scared
*/
boolean isScared();
/**
* Gets how many ticks the panda will be unhappy for
*
* @return The number of ticks the panda will be unhappy for
*/
int getUnhappyTicks();
// Paper start - Panda API
/**
* Sets the sneeze progress in this animation.
* This value counts up only if {@link Panda#isSneezing()} is true
*
* @param ticks sneeze progress
*/
void setSneezeTicks(int ticks);
/**
* Gets the current sneeze progress, or how many ticks this panda will sneeze for.
*
* @return sneeze progress
*/
int getSneezeTicks();
/**
* Sets the eating ticks for this panda.
* <p>
*
* This starts counting up as long as it is greater than 0.
*
* @param ticks eating ticks
*/
void setEatingTicks(int ticks);
/**
* Gets the current eating progress, or how many ticks this panda has been eating for.
*
* @return eating progress
*/
int getEatingTicks();
/**
* Sets the number of ticks this panda will be unhappy for.
* <p>
* This value counts down.
*
* @param ticks unhappy ticks
*/
void setUnhappyTicks(int ticks);
/**
* Sets if this panda is currently on its back.
*
* @param onBack is on its back
* @deprecated use {@link #setOnBack(boolean)}
*/
@Deprecated(forRemoval = true, since = "1.19")
default void setIsOnBack(boolean onBack) {
this.setOnBack(onBack);
}
/**
* Sets if this panda is currently sitting.
*
* @param sitting is currently sitting
* @deprecated use {@link #setSitting(boolean)}
*/
@Deprecated(forRemoval = true, since = "1.19")
default void setIsSitting(boolean sitting) {
this.setSitting(sitting);
}
/**
* Sets if this panda is currently sitting.
*
* @param sitting is currently sitting
*/
@Override
void setSitting(boolean sitting);
/**
* Gets if this panda is sitting.
*
* @return is sitting
*/
@Override
boolean isSitting();
/**
* Gets this Panda's combined gene.
* <p>
* The combined gene can be modified using
* {@link #setMainGene(Gene)} or {@link #setHiddenGene(Gene)}.
*
* @return combined gene
*/
@NotNull
Gene getCombinedGene();
// Paper end - Panda API
public enum Gene {
// Paper start - Generated/PandaGene
// @GeneratedFrom 1.21.3
NORMAL(false),
LAZY(false),
WORRIED(false),
PLAYFUL(false),
BROWN(true),
WEAK(true),
AGGRESSIVE(false);
// Paper end - Generated/PandaGene
private final boolean recessive;
private Gene(boolean recessive) {
this.recessive = recessive;
}
/**
* Gets whether this gene is recessive, i.e. required in both parents to
* propagate to children.
*
* @return recessive status
*/
public boolean isRecessive() {
return recessive;
}
}
}

View File

@ -0,0 +1,37 @@
package org.bukkit.entity;
import org.jetbrains.annotations.NotNull;
/**
* Represents a salmon fish.
*/
public interface Salmon extends io.papermc.paper.entity.SchoolableFish { // Paper - Schooling Fish API
/**
* Get the variant of this salmon.
*
* @return salmon variant
*/
@NotNull
public Variant getVariant();
/**
* Set the variant of this salmon.
*
* @param variant salmon variant
*/
public void setVariant(@NotNull Variant variant);
/**
* Represents the variant of a salmon - ie its size.
*/
public enum Variant {
// Paper start - Generated/SalmonVariant
// @GeneratedFrom 1.21.3
SMALL,
MEDIUM,
LARGE;
// Paper end - Generated/SalmonVariant
}
}

View File

@ -0,0 +1,88 @@
package org.bukkit.entity;
import java.util.Collection;
import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a Sniffer.
*/
public interface Sniffer extends Animals {
/**
* Gets the locations explored by the sniffer.
*
* @return a collection of locations
*/
@NotNull
public Collection<Location> getExploredLocations();
/**
* Remove a location of the explored locations.
*
* @param location the location to remove
* @see #getExploredLocations()
*/
public void removeExploredLocation(@NotNull Location location);
/**
* Add a location to the explored locations.
* <br>
* <b>Note:</b> the location must be in the sniffer's current world for this
* method to have any effect.
*
* @param location the location to add
* @see #getExploredLocations()
*/
public void addExploredLocation(@NotNull Location location);
/**
* Get the current state of the sniffer.
*
* @return the state of the sniffer
*/
@NotNull
public Sniffer.State getState();
/**
* Set a new state for the sniffer.
* <br>
* This will also make the sniffer make the transition to the new state.
*
* @param state the new state
*/
public void setState(@NotNull Sniffer.State state);
/**
* Try to get a possible location where the sniffer can dig.
*
* @return a {@link Location} if found or null
*/
@Nullable
public Location findPossibleDigLocation();
/**
* Gets whether the sniffer can dig in the current {@link Location} below
* its head.
*
* @return {@code true} if can dig or {@code false} otherwise
*/
public boolean canDig();
/**
* Represents the current state of the Sniffer.
*/
public enum State {
// Paper start - Generated/SnifferState
// @GeneratedFrom 1.21.3
IDLING,
FEELING_HAPPY,
SCENTING,
SNIFFING,
SEARCHING,
DIGGING,
RISING;
// Paper end - Generated/SnifferState
}
}

View File

@ -0,0 +1,79 @@
package org.bukkit.entity;
import org.bukkit.DyeColor;
import org.jetbrains.annotations.NotNull;
/**
* Tropical fish.
*/
public interface TropicalFish extends io.papermc.paper.entity.SchoolableFish { // Paper - Schooling Fish API
/**
* Gets the color of the fish's pattern.
*
* @return pattern color
*/
@NotNull
DyeColor getPatternColor();
/**
* Sets the color of the fish's pattern
*
* @param color pattern color
*/
void setPatternColor(@NotNull DyeColor color);
/**
* Gets the color of the fish's body.
*
* @return pattern color
*/
@NotNull
DyeColor getBodyColor();
/**
* Sets the color of the fish's body
*
* @param color body color
*/
void setBodyColor(@NotNull DyeColor color);
/**
* Gets the fish's pattern.
*
* @return pattern
*/
@NotNull
Pattern getPattern();
/**
* Sets the fish's pattern
*
* @param pattern new pattern
*/
void setPattern(@NotNull Pattern pattern);
/**
* Enumeration of all different fish patterns. Refer to the
* <a href="https://minecraft.wiki/w/Fish">Minecraft Wiki</a>
* for pictures.
*/
public static enum Pattern {
// Paper start - Generated/TropicalFishPattern
// @GeneratedFrom 1.21.3
KOB,
SUNSTREAK,
SNOOPER,
DASHER,
BRINELY,
SPOTTY,
FLOPPER,
STRIPEY,
GLITTER,
BLOCKFISH,
BETTY,
CLAYFISH;
// Paper end - Generated/TropicalFishPattern
}
}

View File

@ -0,0 +1,396 @@
package org.bukkit.entity;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import java.util.Map; // Paper
import java.util.UUID; // Paper
import org.bukkit.Keyed;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a villager NPC
*/
public interface Villager extends AbstractVillager {
/**
* Gets the current profession of this villager.
*
* @return Current profession.
*/
@NotNull
public Profession getProfession();
/**
* Sets the new profession of this villager.
*
* @param profession New profession.
*/
public void setProfession(@NotNull Profession profession);
/**
* Gets the current type of this villager.
*
* @return Current type.
*/
@NotNull
public Type getVillagerType();
/**
* Sets the new type of this villager.
*
* @param type New type.
*/
public void setVillagerType(@NotNull Type type);
/**
* Gets the level of this villager.
*
* A villager with a level of 1 and no experience is liable to lose its
* profession.
*
* @return this villager's level
*/
public int getVillagerLevel();
/**
* Sets the level of this villager.
*
* A villager with a level of 1 and no experience is liable to lose its
* profession.
*
* This doesn't update the trades of this villager.
*
* @param level the new level
* @throws IllegalArgumentException if level not between [1, 5]
* @see #increaseLevel(int)
*/
public void setVillagerLevel(int level);
/**
* Gets the trading experience of this villager.
*
* @return trading experience
*/
public int getVillagerExperience();
/**
* Sets the trading experience of this villager.
*
* @param experience new experience
* @throws IllegalArgumentException if experience &lt; 0
*/
public void setVillagerExperience(int experience);
// Paper start
/**
* Increases the level of this villager.
* The villager will also unlock new recipes unlike the raw
* method {@link #setVillagerLevel(int)}.
* <p>
* A villager with a level of 1 and no experience is liable to lose its
* profession.
* <p>
* A master villager has a level of 5 in its profession and
* will unlock 10 trades (2 per level).
*
* @param amount The amount of level
* @return Whether trades are unlocked
* @throws IllegalArgumentException if current level plus the amount
* isn't between [1, 5] or the amount isn't positive
* @see #setVillagerLevel(int)
*/
boolean increaseLevel(int amount);
/**
* Gives to this villager some potential new trades
* based to its profession and level.
* @param amount The amount of trades to give
* @return Whether trades are added
* @throws IllegalArgumentException if the amount isn't positive
*/
boolean addTrades(int amount);
/**
* Gets the amount of times a villager has restocked their trades today
* @return The amount of trade restocks.
*/
public int getRestocksToday();
/**
* Sets the amount of times a villager has restocked their trades today
* @param restocksToday new restock count
*/
public void setRestocksToday(int restocksToday);
// Paper end
/**
* Attempts to make this villager sleep at the given location.
* <br>
* The location must be in the current world and have a bed placed at the
* location. The villager will put its head on the specified block while
* sleeping.
*
* @param location the location of the bed
* @return whether the sleep was successful
*/
public boolean sleep(@NotNull Location location);
/**
* Causes this villager to wake up if he's currently sleeping.
*
* @throws IllegalStateException if not sleeping
*/
public void wakeup();
/**
* Causes this villager to shake his head.
*/
public void shakeHead();
/**
* Convert this Villager into a ZombieVillager as if it was killed by a
* Zombie.
*
* <b>Note:</b> this will fire a EntityTransformEvent
*
* @return the converted entity {@link ZombieVillager} or null if the
* conversion its cancelled
*/
@Nullable
public ZombieVillager zombify();
/**
* Represents Villager type, usually corresponding to what biome they spawn
* in.
*/
interface Type extends OldEnum<Type>, Keyed {
// Paper start - Generated/VillagerType
// @GeneratedFrom 1.21.3
Type DESERT = getType("desert");
Type JUNGLE = getType("jungle");
Type PLAINS = getType("plains");
Type SAVANNA = getType("savanna");
Type SNOW = getType("snow");
Type SWAMP = getType("swamp");
Type TAIGA = getType("taiga");
// Paper end - Generated/VillagerType
@NotNull
private static Type getType(@NotNull String key) {
return Registry.VILLAGER_TYPE.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* @param name of the villager type.
* @return the villager type with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Type valueOf(@NotNull String name) {
Type type = Registry.VILLAGER_TYPE.get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(type != null, "No villager type found with the name %s", name);
return type;
}
/**
* @return an array of all known villager types.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Type[] values() {
return Lists.newArrayList(Registry.VILLAGER_TYPE).toArray(new Type[0]);
}
}
/**
* Represents the various different Villager professions there may be.
* Villagers have different trading options depending on their profession,
*/
interface Profession extends OldEnum<Profession>, Keyed, net.kyori.adventure.translation.Translatable {
// Paper start - Generated/VillagerProfession
// @GeneratedFrom 1.21.3
/**
* Armorer profession. Wears a black apron. Armorers primarily trade for
* iron armor, chainmail armor, and sometimes diamond armor.
*/
Profession ARMORER = getProfession("armorer");
/**
* Butcher profession. Wears a white apron. Butchers primarily trade for
* raw and cooked food.
*/
Profession BUTCHER = getProfession("butcher");
/**
* Cartographer profession. Wears a white robe. Cartographers primarily
* trade for explorer maps and some paper.
*/
Profession CARTOGRAPHER = getProfession("cartographer");
/**
* Cleric profession. Wears a purple robe. Clerics primarily trade for
* rotten flesh, gold ingot, redstone, lapis, ender pearl, glowstone,
* and bottle o' enchanting.
*/
Profession CLERIC = getProfession("cleric");
/**
* Farmer profession. Wears a brown robe. Farmers primarily trade for
* food-related items.
*/
Profession FARMER = getProfession("farmer");
/**
* Fisherman profession. Wears a brown robe. Fisherman primarily trade
* for fish, as well as possibly selling string and/or coal.
*/
Profession FISHERMAN = getProfession("fisherman");
/**
* Fletcher profession. Wears a brown robe. Fletchers primarily trade
* for string, bows, and arrows.
*/
Profession FLETCHER = getProfession("fletcher");
/**
* Leatherworker profession. Wears a white apron. Leatherworkers
* primarily trade for leather, and leather armor, as well as saddles.
*/
Profession LEATHERWORKER = getProfession("leatherworker");
/**
* Librarian profession. Wears a white robe. Librarians primarily trade
* for paper, books, and enchanted books.
*/
Profession LIBRARIAN = getProfession("librarian");
/**
* Mason profession.
*/
Profession MASON = getProfession("mason");
/**
* Nitwit profession. Wears a green apron, cannot trade. Nitwit
* villagers do not do anything. They do not have any trades by default.
*/
Profession NITWIT = getProfession("nitwit");
Profession NONE = getProfession("none");
/**
* Shepherd profession. Wears a brown robe. Shepherds primarily trade for
* wool items, and shears.
*/
Profession SHEPHERD = getProfession("shepherd");
/**
* Toolsmith profession. Wears a black apron. Tool smiths primarily
* trade for iron and diamond tools.
*/
Profession TOOLSMITH = getProfession("toolsmith");
/**
* Weaponsmith profession. Wears a black apron. Weapon smiths primarily
* trade for iron and diamond weapons, sometimes enchanted.
*/
Profession WEAPONSMITH = getProfession("weaponsmith");
// Paper end - Generated/VillagerProfession
@NotNull
private static Profession getProfession(@NotNull String key) {
return Registry.VILLAGER_PROFESSION.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* @param name of the villager profession.
* @return the villager profession with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Profession valueOf(@NotNull String name) {
Profession profession = Registry.VILLAGER_PROFESSION.get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(profession != null, "No villager profession found with the name %s", name);
return profession;
}
/**
* @return an array of all known villager professions.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Profession[] values() {
return Lists.newArrayList(Registry.VILLAGER_PROFESSION).toArray(new Profession[0]);
}
// Paper start
@Override
default @NotNull String translationKey() {
return "entity.minecraft.villager." + this.getKey().getKey();
}
// Paper end
}
// Paper start - Add villager reputation API
/**
* Get the {@link com.destroystokyo.paper.entity.villager.Reputation reputation}
* for a specific player by {@link UUID}.
*
* @param uniqueId The {@link UUID} of the player to get the reputation of.
* @return The player's copied reputation with this villager.
*/
@NotNull
public com.destroystokyo.paper.entity.villager.Reputation getReputation(@NotNull UUID uniqueId);
/**
* Get all {@link com.destroystokyo.paper.entity.villager.Reputation reputations}
* for all players mapped by their {@link UUID unique IDs}.
*
* @return All {@link com.destroystokyo.paper.entity.villager.Reputation reputations} for all players
* in a copied map.
*/
@NotNull
public Map<UUID, com.destroystokyo.paper.entity.villager.Reputation> getReputations();
/**
* Set the {@link com.destroystokyo.paper.entity.villager.Reputation reputation}
* for a specific player by {@link UUID}.
*
* @param uniqueId The {@link UUID} of the player to set the reputation of.
* @param reputation The {@link com.destroystokyo.paper.entity.villager.Reputation reputation} to set.
*/
public void setReputation(@NotNull UUID uniqueId, @NotNull com.destroystokyo.paper.entity.villager.Reputation reputation);
/**
* Set all {@link com.destroystokyo.paper.entity.villager.Reputation reputations}
* for all players mapped by their {@link UUID unique IDs}.
*
* @param reputations All {@link com.destroystokyo.paper.entity.villager.Reputation reputations}
* for all players mapped by their {@link UUID unique IDs}.
*/
public void setReputations(@NotNull Map<UUID, com.destroystokyo.paper.entity.villager.Reputation> reputations);
/**
* Clear all reputations from this villager. This removes every single
* reputation regardless of its impact and the player associated.
*/
public void clearReputations();
// Paper end
}

View File

@ -0,0 +1,122 @@
package org.bukkit.entity;
import org.bukkit.DyeColor;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.jetbrains.annotations.NotNull;
/**
* Represents a Wolf
*/
public interface Wolf extends Tameable, Sittable, io.papermc.paper.entity.CollarColorable { // Paper - CollarColorable
/**
* Checks if this wolf is angry
*
* @return Anger true if angry
*/
public boolean isAngry();
/**
* Sets the anger of this wolf.
* <p>
* An angry wolf can not be fed or tamed.
*
* @param angry true if angry
* @see #setTarget(org.bukkit.entity.LivingEntity)
*/
public void setAngry(boolean angry);
/**
* Get the collar color of this wolf
*
* @return the color of the collar
*/
@NotNull
@Override // Paper
public DyeColor getCollarColor();
/**
* Set the collar color of this wolf
*
* @param color the color to apply
*/
@Override // Paper
public void setCollarColor(@NotNull DyeColor color);
/**
* Gets whether the wolf is wet
*
* @return Whether the wolf is wet
*/
public boolean isWet();
/**
* Gets the wolf's tail angle in radians
*
* @return The angle of the wolf's tail in radians
*/
public float getTailAngle();
/**
* Gets if the wolf is interested
*
* @return Whether the wolf is interested
*/
public boolean isInterested();
/**
* Set wolf to be interested
*
* @param interested Whether the wolf is interested
*/
public void setInterested(boolean interested);
/**
* Get the variant of this wolf.
*
* @return wolf variant
*/
@NotNull
Variant getVariant();
/**
* Set the variant of this wolf.
*
* @param variant wolf variant
*/
void setVariant(@NotNull Variant variant);
/**
* Represents the variant of a wolf.
*/
interface Variant extends Keyed {
// Paper start - Generated/WolfVariant
// @GeneratedFrom 1.21.3
Variant ASHEN = getVariant("ashen");
Variant BLACK = getVariant("black");
Variant CHESTNUT = getVariant("chestnut");
Variant PALE = getVariant("pale");
Variant RUSTY = getVariant("rusty");
Variant SNOWY = getVariant("snowy");
Variant SPOTTED = getVariant("spotted");
Variant STRIPED = getVariant("striped");
Variant WOODS = getVariant("woods");
// Paper end - Generated/WolfVariant
@NotNull
private static Variant getVariant(@NotNull String key) {
return Registry.WOLF_VARIANT.getOrThrow(NamespacedKey.minecraft(key));
}
}
}

View File

@ -0,0 +1,161 @@
package org.bukkit.entity.memory;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Keyed;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a key used for accessing memory values of a
* {@link org.bukkit.entity.LivingEntity}.
*
* @param <T> the class type of the memory value
*/
public final class MemoryKey<T> implements Keyed {
private final NamespacedKey namespacedKey;
private final Class<T> tClass;
private MemoryKey(NamespacedKey namespacedKey, Class<T> tClass) {
this.namespacedKey = namespacedKey;
this.tClass = tClass;
MEMORY_KEYS.put(namespacedKey, this);
}
@NotNull
@Override
public NamespacedKey getKey() {
return namespacedKey;
}
/**
* Gets the class of values associated with this memory.
*
* @return the class of value objects
*/
@NotNull
public Class<T> getMemoryClass() {
return tClass;
}
private static final Map<NamespacedKey, MemoryKey<?>> MEMORY_KEYS = new HashMap<>();
//
// Paper start - Generated/MemoryKey
// @GeneratedFrom 1.21.3
public static final MemoryKey<Boolean> ADMIRING_DISABLED = new MemoryKey<>(NamespacedKey.minecraft("admiring_disabled"), Boolean.class);
public static final MemoryKey<Boolean> ADMIRING_ITEM = new MemoryKey<>(NamespacedKey.minecraft("admiring_item"), Boolean.class);
public static final MemoryKey<UUID> ANGRY_AT = new MemoryKey<>(NamespacedKey.minecraft("angry_at"), UUID.class);
public static final MemoryKey<Boolean> ATE_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("ate_recently"), Boolean.class);
public static final MemoryKey<Boolean> ATTACK_COOLING_DOWN = new MemoryKey<>(NamespacedKey.minecraft("attack_cooling_down"), Boolean.class);
public static final MemoryKey<Long> CANT_REACH_WALK_TARGET_SINCE = new MemoryKey<>(NamespacedKey.minecraft("cant_reach_walk_target_since"), Long.class);
public static final MemoryKey<Boolean> DANCING = new MemoryKey<>(NamespacedKey.minecraft("dancing"), Boolean.class);
public static final MemoryKey<Boolean> DANGER_DETECTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("danger_detected_recently"), Boolean.class);
public static final MemoryKey<Boolean> DISABLE_WALK_TO_ADMIRE_ITEM = new MemoryKey<>(NamespacedKey.minecraft("disable_walk_to_admire_item"), Boolean.class);
public static final MemoryKey<Integer> GAZE_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("gaze_cooldown_ticks"), Integer.class);
public static final MemoryKey<Boolean> GOLEM_DETECTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("golem_detected_recently"), Boolean.class);
public static final MemoryKey<Boolean> HAS_HUNTING_COOLDOWN = new MemoryKey<>(NamespacedKey.minecraft("has_hunting_cooldown"), Boolean.class);
public static final MemoryKey<Long> HEARD_BELL_TIME = new MemoryKey<>(NamespacedKey.minecraft("heard_bell_time"), Long.class);
public static final MemoryKey<Location> HIDING_PLACE = new MemoryKey<>(NamespacedKey.minecraft("hiding_place"), Location.class);
public static final MemoryKey<Location> HOME = new MemoryKey<>(NamespacedKey.minecraft("home"), Location.class);
public static final MemoryKey<Boolean> HUNTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("hunted_recently"), Boolean.class);
public static final MemoryKey<Boolean> IS_PANICKING = new MemoryKey<>(NamespacedKey.minecraft("is_panicking"), Boolean.class);
public static final MemoryKey<Boolean> IS_TEMPTED = new MemoryKey<>(NamespacedKey.minecraft("is_tempted"), Boolean.class);
public static final MemoryKey<Integer> ITEM_PICKUP_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("item_pickup_cooldown_ticks"), Integer.class);
public static final MemoryKey<Location> JOB_SITE = new MemoryKey<>(NamespacedKey.minecraft("job_site"), Location.class);
public static final MemoryKey<Long> LAST_SLEPT = new MemoryKey<>(NamespacedKey.minecraft("last_slept"), Long.class);
public static final MemoryKey<Long> LAST_WOKEN = new MemoryKey<>(NamespacedKey.minecraft("last_woken"), Long.class);
public static final MemoryKey<Long> LAST_WORKED_AT_POI = new MemoryKey<>(NamespacedKey.minecraft("last_worked_at_poi"), Long.class);
public static final MemoryKey<Location> LIKED_NOTEBLOCK_POSITION = new MemoryKey<>(NamespacedKey.minecraft("liked_noteblock"), Location.class);
public static final MemoryKey<Integer> LIKED_NOTEBLOCK_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("liked_noteblock_cooldown_ticks"), Integer.class);
public static final MemoryKey<UUID> LIKED_PLAYER = new MemoryKey<>(NamespacedKey.minecraft("liked_player"), UUID.class);
public static final MemoryKey<Integer> LONG_JUMP_COOLING_DOWN = new MemoryKey<>(NamespacedKey.minecraft("long_jump_cooling_down"), Integer.class);
public static final MemoryKey<Boolean> LONG_JUMP_MID_JUMP = new MemoryKey<>(NamespacedKey.minecraft("long_jump_mid_jump"), Boolean.class);
public static final MemoryKey<Location> MEETING_POINT = new MemoryKey<>(NamespacedKey.minecraft("meeting_point"), Location.class);
public static final MemoryKey<Boolean> PACIFIED = new MemoryKey<>(NamespacedKey.minecraft("pacified"), Boolean.class);
public static final MemoryKey<Integer> PLAY_DEAD_TICKS = new MemoryKey<>(NamespacedKey.minecraft("play_dead_ticks"), Integer.class);
public static final MemoryKey<Location> POTENTIAL_JOB_SITE = new MemoryKey<>(NamespacedKey.minecraft("potential_job_site"), Location.class);
public static final MemoryKey<Integer> RAM_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("ram_cooldown_ticks"), Integer.class);
public static final MemoryKey<Boolean> SNIFFER_DIGGING = new MemoryKey<>(NamespacedKey.minecraft("sniffer_digging"), Boolean.class);
public static final MemoryKey<Boolean> SNIFFER_HAPPY = new MemoryKey<>(NamespacedKey.minecraft("sniffer_happy"), Boolean.class);
public static final MemoryKey<Integer> TEMPTATION_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("temptation_cooldown_ticks"), Integer.class);
public static final MemoryKey<Integer> TIME_TRYING_TO_REACH_ADMIRE_ITEM = new MemoryKey<>(NamespacedKey.minecraft("time_trying_to_reach_admire_item"), Integer.class);
public static final MemoryKey<Boolean> UNIVERSAL_ANGER = new MemoryKey<>(NamespacedKey.minecraft("universal_anger"), Boolean.class);
public static final MemoryKey<Integer> VISIBLE_ADULT_HOGLIN_COUNT = new MemoryKey<>(NamespacedKey.minecraft("visible_adult_hoglin_count"), Integer.class);
public static final MemoryKey<Integer> VISIBLE_ADULT_PIGLIN_COUNT = new MemoryKey<>(NamespacedKey.minecraft("visible_adult_piglin_count"), Integer.class);
// Paper end - Generated/MemoryKey
/**
* @deprecated this constant uses the wrong generic type, the sniffer now stores different positions
* from possibly different worlds. Use the relevant methods in {@link org.bukkit.entity.Sniffer} directly
* for now.
*/
@Deprecated // Paper
public static final MemoryKey<Location> SNIFFER_EXPLORED_POSITIONS = new MemoryKey<>(NamespacedKey.minecraft("sniffer_explored_positions"), Location.class);
/**
* Returns a {@link MemoryKey} by a {@link NamespacedKey}.
*
* @param namespacedKey the {@link NamespacedKey} referencing a
* {@link MemoryKey}
* @return the {@link MemoryKey} or null when no {@link MemoryKey} is
* available under that key
*/
@Nullable
public static MemoryKey<?> getByKey(@NotNull NamespacedKey namespacedKey) {
return MEMORY_KEYS.get(namespacedKey);
}
/**
* Returns the set of all MemoryKeys.
*
* @return the memoryKeys
*/
@NotNull
public static Set<MemoryKey<?>> values() {
return new HashSet<>(MEMORY_KEYS.values());
}
}

View File

@ -0,0 +1,109 @@
package org.bukkit.generator.structure;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.jetbrains.annotations.NotNull;
/**
* Represent a Structure from the world.
*
* Listed structures are present in the default server. Depending on the server
* there might be additional structures present (for example structures added by
* data packs), which can be received via {@link Registry#STRUCTURE}.
*/
public abstract class Structure implements Keyed {
// Paper start - Generated/Structure
// @GeneratedFrom 1.21.3
public static final Structure ANCIENT_CITY = getStructure("ancient_city");
public static final Structure BASTION_REMNANT = getStructure("bastion_remnant");
public static final Structure BURIED_TREASURE = getStructure("buried_treasure");
public static final Structure DESERT_PYRAMID = getStructure("desert_pyramid");
public static final Structure END_CITY = getStructure("end_city");
public static final Structure FORTRESS = getStructure("fortress");
public static final Structure IGLOO = getStructure("igloo");
public static final Structure JUNGLE_PYRAMID = getStructure("jungle_pyramid");
public static final Structure MANSION = getStructure("mansion");
public static final Structure MINESHAFT = getStructure("mineshaft");
public static final Structure MINESHAFT_MESA = getStructure("mineshaft_mesa");
public static final Structure MONUMENT = getStructure("monument");
public static final Structure NETHER_FOSSIL = getStructure("nether_fossil");
public static final Structure OCEAN_RUIN_COLD = getStructure("ocean_ruin_cold");
public static final Structure OCEAN_RUIN_WARM = getStructure("ocean_ruin_warm");
public static final Structure PILLAGER_OUTPOST = getStructure("pillager_outpost");
public static final Structure RUINED_PORTAL = getStructure("ruined_portal");
public static final Structure RUINED_PORTAL_DESERT = getStructure("ruined_portal_desert");
public static final Structure RUINED_PORTAL_JUNGLE = getStructure("ruined_portal_jungle");
public static final Structure RUINED_PORTAL_MOUNTAIN = getStructure("ruined_portal_mountain");
public static final Structure RUINED_PORTAL_NETHER = getStructure("ruined_portal_nether");
public static final Structure RUINED_PORTAL_OCEAN = getStructure("ruined_portal_ocean");
public static final Structure RUINED_PORTAL_SWAMP = getStructure("ruined_portal_swamp");
public static final Structure SHIPWRECK = getStructure("shipwreck");
public static final Structure SHIPWRECK_BEACHED = getStructure("shipwreck_beached");
public static final Structure STRONGHOLD = getStructure("stronghold");
public static final Structure SWAMP_HUT = getStructure("swamp_hut");
public static final Structure TRAIL_RUINS = getStructure("trail_ruins");
public static final Structure TRIAL_CHAMBERS = getStructure("trial_chambers");
public static final Structure VILLAGE_DESERT = getStructure("village_desert");
public static final Structure VILLAGE_PLAINS = getStructure("village_plains");
public static final Structure VILLAGE_SAVANNA = getStructure("village_savanna");
public static final Structure VILLAGE_SNOWY = getStructure("village_snowy");
public static final Structure VILLAGE_TAIGA = getStructure("village_taiga");
// Paper end - Generated/Structure
@NotNull
private static Structure getStructure(@NotNull String name) {
return Registry.STRUCTURE.getOrThrow(NamespacedKey.minecraft(name));
}
/**
* Returns the type of the structure.
*
* @return the type of structure
*/
@NotNull
public abstract StructureType getStructureType();
// Paper start - deprecate getKey
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#STRUCTURE}. Structures can exist without a key.
*/
@Override
@Deprecated(since = "1.20.4")
public abstract @NotNull NamespacedKey getKey();
// Paper end - deprecate getKey
}

View File

@ -0,0 +1,57 @@
package org.bukkit.generator.structure;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.jetbrains.annotations.NotNull;
/**
* Represent a StructureType of a {@link Structure}.
*
* Listed structure types are present in the default server. Depending on the
* server there might be additional structure types present (for example
* structure types added by data packs), which can be received via
* {@link Registry#STRUCTURE_TYPE}.
*/
public abstract class StructureType implements Keyed {
// Paper start - Generated/StructureType
// @GeneratedFrom 1.21.3
public static final StructureType BURIED_TREASURE = getStructureType("buried_treasure");
public static final StructureType DESERT_PYRAMID = getStructureType("desert_pyramid");
public static final StructureType END_CITY = getStructureType("end_city");
public static final StructureType FORTRESS = getStructureType("fortress");
public static final StructureType IGLOO = getStructureType("igloo");
public static final StructureType JIGSAW = getStructureType("jigsaw");
public static final StructureType JUNGLE_TEMPLE = getStructureType("jungle_temple");
public static final StructureType MINESHAFT = getStructureType("mineshaft");
public static final StructureType NETHER_FOSSIL = getStructureType("nether_fossil");
public static final StructureType OCEAN_MONUMENT = getStructureType("ocean_monument");
public static final StructureType OCEAN_RUIN = getStructureType("ocean_ruin");
public static final StructureType RUINED_PORTAL = getStructureType("ruined_portal");
public static final StructureType SHIPWRECK = getStructureType("shipwreck");
public static final StructureType STRONGHOLD = getStructureType("stronghold");
public static final StructureType SWAMP_HUT = getStructureType("swamp_hut");
public static final StructureType WOODLAND_MANSION = getStructureType("woodland_mansion");
// Paper end - Generated/StructureType
@NotNull
private static StructureType getStructureType(@NotNull String name) {
return Registry.STRUCTURE_TYPE.getOrThrow(NamespacedKey.minecraft(name));
}
}

View File

@ -0,0 +1,31 @@
package org.bukkit.inventory;
/**
* A item's rarity determines the default color of its name. This enum is
* ordered from least rare to most rare.
*/
public enum ItemRarity {
// Paper start - Generated/ItemRarity
// @GeneratedFrom 1.21.3
COMMON(net.kyori.adventure.text.format.NamedTextColor.WHITE),
UNCOMMON(net.kyori.adventure.text.format.NamedTextColor.YELLOW),
RARE(net.kyori.adventure.text.format.NamedTextColor.AQUA),
EPIC(net.kyori.adventure.text.format.NamedTextColor.LIGHT_PURPLE);
// Paper end - Generated/ItemRarity
// Paper start - improve ItemRarity
private final net.kyori.adventure.text.format.NamedTextColor color;
ItemRarity(final net.kyori.adventure.text.format.NamedTextColor color) {
this.color = color;
}
/**
* Gets the color formatting associated with this rarity.
*
* @return the color
*/
public net.kyori.adventure.text.format.@org.jetbrains.annotations.NotNull TextColor color() {
return this.color;
}
// Paper end
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,69 @@
package org.bukkit.inventory.meta.trim;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Translatable;
import org.jetbrains.annotations.NotNull;
/**
* Represents a material that may be used in an {@link ArmorTrim}.
*/
public interface TrimMaterial extends Keyed, Translatable {
// Paper start - Generated/TrimMaterial
// @GeneratedFrom 1.21.3
TrimMaterial AMETHYST = getTrimMaterial("amethyst");
TrimMaterial COPPER = getTrimMaterial("copper");
TrimMaterial DIAMOND = getTrimMaterial("diamond");
TrimMaterial EMERALD = getTrimMaterial("emerald");
TrimMaterial GOLD = getTrimMaterial("gold");
TrimMaterial IRON = getTrimMaterial("iron");
TrimMaterial LAPIS = getTrimMaterial("lapis");
TrimMaterial NETHERITE = getTrimMaterial("netherite");
TrimMaterial QUARTZ = getTrimMaterial("quartz");
TrimMaterial REDSTONE = getTrimMaterial("redstone");
// Paper end - Generated/TrimMaterial
@NotNull
private static TrimMaterial getTrimMaterial(@NotNull String key) {
return Registry.TRIM_MATERIAL.getOrThrow(NamespacedKey.minecraft(key));
}
// Paper start - adventure
/**
* Get the description of this {@link TrimMaterial}.
*
* @return the description
*/
net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component description();
/**
* @deprecated this method assumes that {@link #description()} will
* always be a translatable component which is not guaranteed.
*/
@Override
@Deprecated(forRemoval = true)
@org.jetbrains.annotations.NotNull String getTranslationKey();
// Paper end - adventure
// Paper start - Registry#getKey
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#TRIM_MATERIAL}. TrimMaterials can exist without a key.
*/
@Deprecated(forRemoval = true, since = "1.20.4")
@Override
org.bukkit.@org.jetbrains.annotations.NotNull NamespacedKey getKey();
// Paper end - Registry#getKey
}

View File

@ -0,0 +1,85 @@
package org.bukkit.inventory.meta.trim;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Translatable;
import org.jetbrains.annotations.NotNull;
/**
* Represents a pattern that may be used in an {@link ArmorTrim}.
*/
public interface TrimPattern extends Keyed, Translatable {
// Paper start - Generated/TrimPattern
// @GeneratedFrom 1.21.3
TrimPattern BOLT = getTrimPattern("bolt");
TrimPattern COAST = getTrimPattern("coast");
TrimPattern DUNE = getTrimPattern("dune");
TrimPattern EYE = getTrimPattern("eye");
TrimPattern FLOW = getTrimPattern("flow");
TrimPattern HOST = getTrimPattern("host");
TrimPattern RAISER = getTrimPattern("raiser");
TrimPattern RIB = getTrimPattern("rib");
TrimPattern SENTRY = getTrimPattern("sentry");
TrimPattern SHAPER = getTrimPattern("shaper");
TrimPattern SILENCE = getTrimPattern("silence");
TrimPattern SNOUT = getTrimPattern("snout");
TrimPattern SPIRE = getTrimPattern("spire");
TrimPattern TIDE = getTrimPattern("tide");
TrimPattern VEX = getTrimPattern("vex");
TrimPattern WARD = getTrimPattern("ward");
TrimPattern WAYFINDER = getTrimPattern("wayfinder");
TrimPattern WILD = getTrimPattern("wild");
// Paper end - Generated/TrimPattern
@NotNull
private static TrimPattern getTrimPattern(@NotNull String key) {
return Registry.TRIM_PATTERN.getOrThrow(NamespacedKey.minecraft(key));
}
// Paper start - adventure
/**
* Get the description of this {@link TrimPattern}.
*
* @return the description
*/
net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component description();
/**
* @deprecated this method assumes that {@link #description()} will
* always be a translatable component which is not guaranteed.
*/
@Override
@Deprecated(forRemoval = true)
@org.jetbrains.annotations.NotNull String getTranslationKey();
// Paper end - adventure
// Paper start - Registry#getKey
/**
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
* and {@link io.papermc.paper.registry.RegistryKey#TRIM_PATTERN}. TrimPatterns can exist without a key.
*/
@Deprecated(forRemoval = true, since = "1.20.4")
@Override
org.bukkit.@org.jetbrains.annotations.NotNull NamespacedKey getKey();
// Paper end - Registry#getKey
}

View File

@ -0,0 +1,14 @@
package org.bukkit.inventory.recipe;
/**
* Represents categories within the cooking recipe book.
*/
public enum CookingBookCategory {
// Paper start - Generated/CookingBookCategory
// @GeneratedFrom 1.21.3
FOOD,
BLOCKS,
MISC;
// Paper end - Generated/CookingBookCategory
}

View File

@ -0,0 +1,15 @@
package org.bukkit.inventory.recipe;
/**
* Represents categories within the crafting recipe book.
*/
public enum CraftingBookCategory {
// Paper start - Generated/CraftingBookCategory
// @GeneratedFrom 1.21.3
BUILDING,
REDSTONE,
EQUIPMENT,
MISC;
// Paper end - Generated/CraftingBookCategory
}

View File

@ -0,0 +1,417 @@
package org.bukkit.map;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a cursor on a map.
*/
public final class MapCursor {
private byte x, y;
private byte direction;
private boolean visible;
private net.kyori.adventure.text.Component caption; // Paper
private Type type;
/**
* Initialize the map cursor.
*
* @param x The x coordinate, from -128 to 127.
* @param y The y coordinate, from -128 to 127.
* @param direction The facing of the cursor, from 0 to 15.
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible by default.
* @deprecated Magic value
*/
@Deprecated
public MapCursor(byte x, byte y, byte direction, byte type, boolean visible) {
this(x, y, direction, type, visible, (String) null); // Paper
}
/**
* Initialize the map cursor.
*
* @param x The x coordinate, from -128 to 127.
* @param y The y coordinate, from -128 to 127.
* @param direction The facing of the cursor, from 0 to 15.
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible by default.
*/
public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible) {
this(x, y, direction, type, visible, (String) null); // Paper
}
/**
* Initialize the map cursor.
*
* @param x The x coordinate, from -128 to 127.
* @param y The y coordinate, from -128 to 127.
* @param direction The facing of the cursor, from 0 to 15.
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible by default.
* @param caption cursor caption
* @deprecated Magic value. Use {@link #MapCursor(byte, byte, byte, Type, boolean, net.kyori.adventure.text.Component)}
*/
@Deprecated
public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, @Nullable String caption) {
this.x = x;
this.y = y;
setDirection(direction);
setRawType(type);
this.visible = visible;
this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
}
// Paper start
/**
* Initialize the map cursor.
*
* @param x The x coordinate, from -128 to 127.
* @param y The y coordinate, from -128 to 127.
* @param direction The facing of the cursor, from 0 to 15.
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible by default.
* @param caption cursor caption
* @deprecated Magic value
*/
@Deprecated
public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, net.kyori.adventure.text.@Nullable Component caption) {
this.x = x; this.y = y; this.visible = visible; this.caption = caption;
setDirection(direction);
setRawType(type);
}
/**
* Initialize the map cursor.
*
* @param x The x coordinate, from -128 to 127.
* @param y The y coordinate, from -128 to 127.
* @param direction The facing of the cursor, from 0 to 15.
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible by default.
* @param caption cursor caption
*/
public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible, net.kyori.adventure.text.@Nullable Component caption) {
this.x = x; this.y = y; this.visible = visible; this.caption = caption;
setDirection(direction);
setType(type);
}
// Paper end
/**
* Initialize the map cursor.
*
* @param x The x coordinate, from -128 to 127.
* @param y The y coordinate, from -128 to 127.
* @param direction The facing of the cursor, from 0 to 15.
* @param type The type (color/style) of the map cursor.
* @param visible Whether the cursor is visible by default.
* @param caption cursor caption
*/
public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible, @Nullable String caption) {
this.x = x;
this.y = y;
setDirection(direction);
this.type = type;
this.visible = visible;
this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
}
/**
* Get the X position of this cursor.
*
* @return The X coordinate.
*/
public byte getX() {
return x;
}
/**
* Get the Y position of this cursor.
*
* @return The Y coordinate.
*/
public byte getY() {
return y;
}
/**
* Get the direction of this cursor.
*
* @return The facing of the cursor, from 0 to 15.
*/
public byte getDirection() {
return direction;
}
/**
* Get the type of this cursor.
*
* @return The type (color/style) of the map cursor.
*/
@NotNull
public Type getType() {
return type;
}
/**
* Get the type of this cursor.
*
* @return The type (color/style) of the map cursor.
* @apiNote Internal Use Only
*/
@org.jetbrains.annotations.ApiStatus.Internal // Paper
public byte getRawType() {
return type.getValue();
}
/**
* Get the visibility status of this cursor.
*
* @return True if visible, false otherwise.
*/
public boolean isVisible() {
return visible;
}
/**
* Set the X position of this cursor.
*
* @param x The X coordinate.
*/
public void setX(byte x) {
this.x = x;
}
/**
* Set the Y position of this cursor.
*
* @param y The Y coordinate.
*/
public void setY(byte y) {
this.y = y;
}
/**
* Set the direction of this cursor.
*
* @param direction The facing of the cursor, from 0 to 15.
*/
public void setDirection(byte direction) {
Preconditions.checkArgument(direction >= 0 && direction <= 15, "direction must be between 0 and 15 but is %s", direction);
this.direction = direction;
}
/**
* Set the type of this cursor.
*
* @param type The type (color/style) of the map cursor.
*/
public void setType(@NotNull Type type) {
this.type = type;
}
/**
* Set the type of this cursor.
*
* @param type The type (color/style) of the map cursor.
* @deprecated use {@link #setType(Type)}
*/
@Deprecated(forRemoval = true, since = "1.20.2") // Paper
public void setRawType(byte type) {
Type enumType = Type.byValue(type);
Preconditions.checkArgument(enumType != null, "Unknown type by id %s", type);
this.type = enumType;
}
/**
* Set the visibility status of this cursor.
*
* @param visible True if visible.
*/
public void setVisible(boolean visible) {
this.visible = visible;
}
// Paper start
/**
* Gets the caption on this cursor.
*
* @return caption
*/
public net.kyori.adventure.text.@Nullable Component caption() {
return this.caption;
}
/**
* Sets the caption on this cursor.
*
* @param caption new caption
*/
public void caption(net.kyori.adventure.text.@Nullable Component caption) {
this.caption = caption;
}
// Paper end
/**
* Gets the caption on this cursor.
*
* @return caption
* @deprecated in favour of {@link #caption()}
*/
@Nullable
@Deprecated // Paper
public String getCaption() {
return this.caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.caption); // Paper
}
/**
* Sets the caption on this cursor.
*
* @param caption new caption
* @deprecated in favour of {@link #caption(net.kyori.adventure.text.Component)}
*/
@Deprecated // Paper
public void setCaption(@Nullable String caption) {
this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
}
/**
* Represents the standard types of map cursors. More may be made
* available by resource packs - the value is used by the client as an
* index in the file './assets/minecraft/textures/map/map_icons.png' from minecraft.jar or from a
* resource pack.
*/
public interface Type extends OldEnum<Type>, Keyed {
// Paper start - Generated/MapCursorType
// @GeneratedFrom 1.21.3
Type BANNER_BLACK = getType("banner_black");
Type BANNER_BLUE = getType("banner_blue");
Type BANNER_BROWN = getType("banner_brown");
Type BANNER_CYAN = getType("banner_cyan");
Type BANNER_GRAY = getType("banner_gray");
Type BANNER_GREEN = getType("banner_green");
Type BANNER_LIGHT_BLUE = getType("banner_light_blue");
Type BANNER_LIGHT_GRAY = getType("banner_light_gray");
Type BANNER_LIME = getType("banner_lime");
Type BANNER_MAGENTA = getType("banner_magenta");
Type BANNER_ORANGE = getType("banner_orange");
Type BANNER_PINK = getType("banner_pink");
Type BANNER_PURPLE = getType("banner_purple");
Type BANNER_RED = getType("banner_red");
Type BANNER_WHITE = getType("banner_white");
Type BANNER_YELLOW = getType("banner_yellow");
Type BLUE_MARKER = getType("blue_marker");
Type FRAME = getType("frame");
Type JUNGLE_TEMPLE = getType("jungle_temple");
Type MANSION = getType("mansion");
Type MONUMENT = getType("monument");
Type PLAYER = getType("player");
Type PLAYER_OFF_LIMITS = getType("player_off_limits");
Type PLAYER_OFF_MAP = getType("player_off_map");
Type RED_MARKER = getType("red_marker");
Type RED_X = getType("red_x");
Type SWAMP_HUT = getType("swamp_hut");
Type TARGET_POINT = getType("target_point");
Type TARGET_X = getType("target_x");
Type TRIAL_CHAMBERS = getType("trial_chambers");
Type VILLAGE_DESERT = getType("village_desert");
Type VILLAGE_PLAINS = getType("village_plains");
Type VILLAGE_SAVANNA = getType("village_savanna");
Type VILLAGE_SNOWY = getType("village_snowy");
Type VILLAGE_TAIGA = getType("village_taiga");
// Paper end - Generated/MapCursorType
@NotNull
private static Type getType(@NotNull String key) {
return Registry.MAP_DECORATION_TYPE.getOrThrow(NamespacedKey.minecraft(key));
}
/**
* Gets the internal value of the cursor.
*
* @return the value
* @apiNote Internal Use Only
*/
@org.jetbrains.annotations.ApiStatus.Internal // Paper
byte getValue();
/**
* Get a cursor by its internal value.
*
* @param value the value
* @return the matching type
* @apiNote Internal Use Only
*/
@org.jetbrains.annotations.ApiStatus.Internal // Paper
@Nullable
static Type byValue(byte value) {
for (Type t : values()) {
if (t.getValue() == value) return t;
}
return null;
}
/**
* @param name of the type.
* @return the type with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Type valueOf(@NotNull String name) {
Type type = Registry.MAP_DECORATION_TYPE.get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(type != null, "No Type found with the name %s", name);
return type;
}
/**
* @return an array of all known map cursor types.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Type[] values() {
return Lists.newArrayList(Registry.MAP_DECORATION_TYPE).toArray(new Type[0]);
}
}
}

View File

@ -0,0 +1,513 @@
package org.bukkit.map;
import com.google.common.base.Preconditions;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents the palette that map items use.
* <p>
* These fields are hee base color ranges. Each entry corresponds to four
* colors of varying shades with values entry to entry + 3.
*/
public final class MapPalette {
// Internal mechanisms
private MapPalette() {}
@NotNull
private static Color c(int r, int g, int b) {
return new Color(r, g, b);
}
@NotNull
private static Color c(int r, int g, int b, int a) {
return new Color(r, g, b, a);
}
private static double getDistance(@NotNull Color c1, @NotNull Color c2) {
// Paper start - Optimize color distance calculation by removing floating point math
int rsum = c1.getRed() + c2.getRed(); // Use sum instead of mean for no division
int r = c1.getRed() - c2.getRed();
int g = c1.getGreen() - c2.getGreen();
int b = c1.getBlue() - c2.getBlue();
// All weights are 512x their original to avoid floating point division
int weightR = 1024 + rsum;
int weightG = 2048;
int weightB = 1024 + (255*2 - rsum);
// Division by 256 here is unnecessary as this won't change the result of the sort
return weightR * r * r + weightG * g * g + weightB * b * b;
// Paper end
}
@NotNull
static final Color[] colors = {
// Paper start - Generated/MapPalette#colors
// @GeneratedFrom 1.21.3
new Color(0, 0, 0, 0),
new Color(0, 0, 0, 0),
new Color(0, 0, 0, 0),
new Color(0, 0, 0, 0),
new Color(89, 125, 39),
new Color(109, 153, 48),
new Color(127, 178, 56),
new Color(67, 94, 29),
new Color(174, 164, 115),
new Color(213, 201, 140),
new Color(247, 233, 163),
new Color(130, 123, 86),
new Color(140, 140, 140),
new Color(171, 171, 171),
new Color(199, 199, 199),
new Color(105, 105, 105),
new Color(180, 0, 0),
new Color(220, 0, 0),
new Color(255, 0, 0),
new Color(135, 0, 0),
new Color(112, 112, 180),
new Color(138, 138, 220),
new Color(160, 160, 255),
new Color(84, 84, 135),
new Color(117, 117, 117),
new Color(144, 144, 144),
new Color(167, 167, 167),
new Color(88, 88, 88),
new Color(0, 87, 0),
new Color(0, 106, 0),
new Color(0, 124, 0),
new Color(0, 65, 0),
new Color(180, 180, 180),
new Color(220, 220, 220),
new Color(255, 255, 255),
new Color(135, 135, 135),
new Color(115, 118, 129),
new Color(141, 144, 158),
new Color(164, 168, 184),
new Color(86, 88, 97),
new Color(106, 76, 54),
new Color(130, 94, 66),
new Color(151, 109, 77),
new Color(79, 57, 40),
new Color(79, 79, 79),
new Color(96, 96, 96),
new Color(112, 112, 112),
new Color(59, 59, 59),
new Color(45, 45, 180),
new Color(55, 55, 220),
new Color(64, 64, 255),
new Color(33, 33, 135),
new Color(100, 84, 50),
new Color(123, 102, 62),
new Color(143, 119, 72),
new Color(75, 63, 38),
new Color(180, 177, 172),
new Color(220, 217, 211),
new Color(255, 252, 245),
new Color(135, 133, 129),
new Color(152, 89, 36),
new Color(186, 109, 44),
new Color(216, 127, 51),
new Color(114, 67, 27),
new Color(125, 53, 152),
new Color(153, 65, 186),
new Color(178, 76, 216),
new Color(94, 40, 114),
new Color(72, 108, 152),
new Color(88, 132, 186),
new Color(102, 153, 216),
new Color(54, 81, 114),
new Color(161, 161, 36),
new Color(197, 197, 44),
new Color(229, 229, 51),
new Color(121, 121, 27),
new Color(89, 144, 17),
new Color(109, 176, 21),
new Color(127, 204, 25),
new Color(67, 108, 13),
new Color(170, 89, 116),
new Color(208, 109, 142),
new Color(242, 127, 165),
new Color(128, 67, 87),
new Color(53, 53, 53),
new Color(65, 65, 65),
new Color(76, 76, 76),
new Color(40, 40, 40),
new Color(108, 108, 108),
new Color(132, 132, 132),
new Color(153, 153, 153),
new Color(81, 81, 81),
new Color(53, 89, 108),
new Color(65, 109, 132),
new Color(76, 127, 153),
new Color(40, 67, 81),
new Color(89, 44, 125),
new Color(109, 54, 153),
new Color(127, 63, 178),
new Color(67, 33, 94),
new Color(36, 53, 125),
new Color(44, 65, 153),
new Color(51, 76, 178),
new Color(27, 40, 94),
new Color(72, 53, 36),
new Color(88, 65, 44),
new Color(102, 76, 51),
new Color(54, 40, 27),
new Color(72, 89, 36),
new Color(88, 109, 44),
new Color(102, 127, 51),
new Color(54, 67, 27),
new Color(108, 36, 36),
new Color(132, 44, 44),
new Color(153, 51, 51),
new Color(81, 27, 27),
new Color(17, 17, 17),
new Color(21, 21, 21),
new Color(25, 25, 25),
new Color(13, 13, 13),
new Color(176, 168, 54),
new Color(215, 205, 66),
new Color(250, 238, 77),
new Color(132, 126, 40),
new Color(64, 154, 150),
new Color(79, 188, 183),
new Color(92, 219, 213),
new Color(48, 115, 112),
new Color(52, 90, 180),
new Color(63, 110, 220),
new Color(74, 128, 255),
new Color(39, 67, 135),
new Color(0, 153, 40),
new Color(0, 187, 50),
new Color(0, 217, 58),
new Color(0, 114, 30),
new Color(91, 60, 34),
new Color(111, 74, 42),
new Color(129, 86, 49),
new Color(68, 45, 25),
new Color(79, 1, 0),
new Color(96, 1, 0),
new Color(112, 2, 0),
new Color(59, 1, 0),
new Color(147, 124, 113),
new Color(180, 152, 138),
new Color(209, 177, 161),
new Color(110, 93, 85),
new Color(112, 57, 25),
new Color(137, 70, 31),
new Color(159, 82, 36),
new Color(84, 43, 19),
new Color(105, 61, 76),
new Color(128, 75, 93),
new Color(149, 87, 108),
new Color(78, 46, 57),
new Color(79, 76, 97),
new Color(96, 93, 119),
new Color(112, 108, 138),
new Color(59, 57, 73),
new Color(131, 93, 25),
new Color(160, 114, 31),
new Color(186, 133, 36),
new Color(98, 70, 19),
new Color(72, 82, 37),
new Color(88, 100, 45),
new Color(103, 117, 53),
new Color(54, 61, 28),
new Color(112, 54, 55),
new Color(138, 66, 67),
new Color(160, 77, 78),
new Color(84, 40, 41),
new Color(40, 28, 24),
new Color(49, 35, 30),
new Color(57, 41, 35),
new Color(30, 21, 18),
new Color(95, 75, 69),
new Color(116, 92, 84),
new Color(135, 107, 98),
new Color(71, 56, 51),
new Color(61, 64, 64),
new Color(75, 79, 79),
new Color(87, 92, 92),
new Color(46, 48, 48),
new Color(86, 51, 62),
new Color(105, 62, 75),
new Color(122, 73, 88),
new Color(64, 38, 46),
new Color(53, 43, 64),
new Color(65, 53, 79),
new Color(76, 62, 92),
new Color(40, 32, 48),
new Color(53, 35, 24),
new Color(65, 43, 30),
new Color(76, 50, 35),
new Color(40, 26, 18),
new Color(53, 57, 29),
new Color(65, 70, 36),
new Color(76, 82, 42),
new Color(40, 43, 22),
new Color(100, 42, 32),
new Color(122, 51, 39),
new Color(142, 60, 46),
new Color(75, 31, 24),
new Color(26, 15, 11),
new Color(31, 18, 13),
new Color(37, 22, 16),
new Color(19, 11, 8),
new Color(133, 33, 34),
new Color(163, 41, 42),
new Color(189, 48, 49),
new Color(100, 25, 25),
new Color(104, 44, 68),
new Color(127, 54, 83),
new Color(148, 63, 97),
new Color(78, 33, 51),
new Color(64, 17, 20),
new Color(79, 21, 25),
new Color(92, 25, 29),
new Color(48, 13, 15),
new Color(15, 88, 94),
new Color(18, 108, 115),
new Color(22, 126, 134),
new Color(11, 66, 70),
new Color(40, 100, 98),
new Color(50, 122, 120),
new Color(58, 142, 140),
new Color(30, 75, 74),
new Color(60, 31, 43),
new Color(74, 37, 53),
new Color(86, 44, 62),
new Color(45, 23, 32),
new Color(14, 127, 93),
new Color(17, 155, 114),
new Color(20, 180, 133),
new Color(10, 95, 70),
new Color(70, 70, 70),
new Color(86, 86, 86),
new Color(100, 100, 100),
new Color(52, 52, 52),
new Color(152, 123, 103),
new Color(186, 150, 126),
new Color(216, 175, 147),
new Color(114, 92, 77),
new Color(89, 117, 105),
new Color(109, 144, 129),
new Color(127, 167, 150),
new Color(67, 88, 79),
// Paper end - Generated/MapPalette#colors
};
// Interface
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte TRANSPARENT = 0;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte LIGHT_GREEN = 4;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte LIGHT_BROWN = 8;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte GRAY_1 = 12;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte RED = 16;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte PALE_BLUE = 20;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte GRAY_2 = 24;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte DARK_GREEN = 28;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte WHITE = 32;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte LIGHT_GRAY = 36;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte BROWN = 40;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte DARK_GRAY = 44;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte BLUE = 48;
/**
* @deprecated Magic value
*/
@Deprecated
public static final byte DARK_BROWN = 52;
/**
* Resize an image to 128x128.
*
* @param image The image to resize.
* @return The resized image.
*/
@NotNull
public static BufferedImage resizeImage(@Nullable Image image) {
BufferedImage result = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = result.createGraphics();
graphics.drawImage(image, 0, 0, 128, 128, null);
graphics.dispose();
return result;
}
/**
* Convert an Image to a byte[] using the palette.
*
* @param image The image to convert.
* @return A byte[] containing the pixels of the image.
* @deprecated use color-related methods
*/
@Deprecated(forRemoval = true, since = "1.20.2") // Paper
@NotNull
public static byte[] imageToBytes(@NotNull Image image) {
BufferedImage temp = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = temp.createGraphics();
graphics.drawImage(image, 0, 0, null);
graphics.dispose();
int[] pixels = new int[temp.getWidth() * temp.getHeight()];
temp.getRGB(0, 0, temp.getWidth(), temp.getHeight(), pixels, 0, temp.getWidth());
byte[] result = new byte[temp.getWidth() * temp.getHeight()];
for (int i = 0; i < pixels.length; i++) {
result[i] = matchColor(new Color(pixels[i], true));
}
return result;
}
/**
* Get the index of the closest matching color in the palette to the given
* color.
*
* @param r The red component of the color.
* @param b The blue component of the color.
* @param g The green component of the color.
* @return The index in the palette.
* @deprecated use color-related methods
*/
@Deprecated(forRemoval = true, since = "1.20.2") // Paper
public static byte matchColor(int r, int g, int b) {
return matchColor(new Color(r, g, b));
}
/**
* Get the index of the closest matching color in the palette to the given
* color.
*
* @param color The Color to match.
* @return The index in the palette.
* @deprecated use color-related methods
*/
@Deprecated(forRemoval = true, since = "1.20.2") // Paper
public static byte matchColor(@NotNull Color color) {
if (color.getAlpha() < 128) return 0;
if (mapColorCache != null && mapColorCache.isCached()) {
return mapColorCache.matchColor(color);
}
int index = 0;
double best = -1;
for (int i = 4; i < colors.length; i++) {
double distance = getDistance(color, colors[i]);
if (distance < best || best == -1) {
best = distance;
index = i;
}
}
// Minecraft has 143 colors, some of which have negative byte representations
return (byte) (index < 128 ? index : -129 + (index - 127));
}
/**
* Get the value of the given color in the palette.
*
* @param index The index in the palette.
* @return The Color of the palette entry.
* @deprecated use color directly
*/
@Deprecated(forRemoval = true, since = "1.20.2") // Paper
@NotNull
public static Color getColor(byte index) {
// Minecraft has 143 colors, some of which have negative byte representations
return colors[index >= 0 ? index : index + 256];
}
private static MapColorCache mapColorCache;
/**
* Sets the given MapColorCache.
*
* @param mapColorCache The map color cache to set
*/
public static void setMapColorCache(@NotNull MapColorCache mapColorCache) {
Preconditions.checkState(MapPalette.mapColorCache == null, "Map color cache already set");
MapPalette.mapColorCache = mapColorCache;
}
/**
* Holds cached information for matching map colors of a given RBG color.
*/
public interface MapColorCache {
/**
* Returns true if the MapColorCache has values cached, if not it will
* return false.
* A case where it might return false is when the cache is not build jet.
*
* @return true if this MapColorCache has values cached otherwise false
*/
boolean isCached();
/**
* Get the cached index of the closest matching color in the palette to the given
* color.
*
* @param color The Color to match.
* @return The index in the palette.
* @throws IllegalStateException if {@link #isCached()} returns false
* @apiNote Internal Use Only
*/
@org.jetbrains.annotations.ApiStatus.Internal // Paper
byte matchColor(@NotNull Color color);
}
}

View File

@ -0,0 +1,171 @@
package org.bukkit.potion;
import com.google.common.base.Suppliers;
import java.util.List;
import java.util.function.Supplier;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This enum reflects and matches each potion state that can be obtained from
* the Creative mode inventory
*/
public enum PotionType implements Keyed, io.papermc.paper.world.flag.FeatureDependant { // Paper - feature flag API
// Paper start - Generated/PotionType
// @GeneratedFrom 1.21.3
AWKWARD("awkward"),
FIRE_RESISTANCE("fire_resistance"),
HARMING("harming"),
HEALING("healing"),
INFESTED("infested"),
INVISIBILITY("invisibility"),
LEAPING("leaping"),
LONG_FIRE_RESISTANCE("long_fire_resistance"),
LONG_INVISIBILITY("long_invisibility"),
LONG_LEAPING("long_leaping"),
LONG_NIGHT_VISION("long_night_vision"),
LONG_POISON("long_poison"),
LONG_REGENERATION("long_regeneration"),
LONG_SLOW_FALLING("long_slow_falling"),
LONG_SLOWNESS("long_slowness"),
LONG_STRENGTH("long_strength"),
LONG_SWIFTNESS("long_swiftness"),
LONG_TURTLE_MASTER("long_turtle_master"),
LONG_WATER_BREATHING("long_water_breathing"),
LONG_WEAKNESS("long_weakness"),
LUCK("luck"),
MUNDANE("mundane"),
NIGHT_VISION("night_vision"),
OOZING("oozing"),
POISON("poison"),
REGENERATION("regeneration"),
SLOW_FALLING("slow_falling"),
SLOWNESS("slowness"),
STRENGTH("strength"),
STRONG_HARMING("strong_harming"),
STRONG_HEALING("strong_healing"),
STRONG_LEAPING("strong_leaping"),
STRONG_POISON("strong_poison"),
STRONG_REGENERATION("strong_regeneration"),
STRONG_SLOWNESS("strong_slowness"),
STRONG_STRENGTH("strong_strength"),
STRONG_SWIFTNESS("strong_swiftness"),
STRONG_TURTLE_MASTER("strong_turtle_master"),
SWIFTNESS("swiftness"),
THICK("thick"),
TURTLE_MASTER("turtle_master"),
WATER("water"),
WATER_BREATHING("water_breathing"),
WEAKNESS("weakness"),
WEAVING("weaving"),
WIND_CHARGED("wind_charged");
// Paper end - Generated/PotionType
private final NamespacedKey key;
private final Supplier<InternalPotionData> internalPotionDataSupplier;
PotionType(String key) {
this.key = NamespacedKey.minecraft(key);
this.internalPotionDataSupplier = Suppliers.memoize(() -> Bukkit.getUnsafe().getInternalPotionData(this.key));
}
/**
* @return the potion effect type of this potion type
* @deprecated Potions can have multiple effects use {@link #getPotionEffects()}
*/
@Nullable
@Deprecated
public PotionEffectType getEffectType() {
return internalPotionDataSupplier.get().getEffectType();
}
/**
* @return a list of all effects this potion type has
*/
@NotNull
public List<PotionEffect> getPotionEffects() {
return internalPotionDataSupplier.get().getPotionEffects();
}
/**
* @return if this potion type is instant
* @deprecated PotionType can have multiple effects, some of which can be instant and others not.
* Use {@link PotionEffectType#isInstant()} in combination with {@link #getPotionEffects()} and {@link PotionEffect#getType()}
*/
@Deprecated
public boolean isInstant() {
return internalPotionDataSupplier.get().isInstant();
}
/**
* Checks if the potion type has an upgraded state.
* This refers to whether or not the potion type can be Tier 2,
* such as Potion of Fire Resistance II.
*
* @return true if the potion type can be upgraded;
*/
public boolean isUpgradeable() {
return internalPotionDataSupplier.get().isUpgradeable();
}
/**
* Checks if the potion type has an extended state.
* This refers to the extended duration potions
*
* @return true if the potion type can be extended
*/
public boolean isExtendable() {
return internalPotionDataSupplier.get().isExtendable();
}
public int getMaxLevel() {
return internalPotionDataSupplier.get().getMaxLevel();
}
/**
* @param effectType the effect to get by
* @return the matching potion type
* @deprecated Misleading
*/
@Deprecated
@Nullable
public static PotionType getByEffect(@Nullable PotionEffectType effectType) {
if (effectType == null)
return WATER;
for (PotionType type : PotionType.values()) {
if (effectType.equals(type.getEffectType()))
return type;
}
return null;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/**
* @deprecated Do not use, interface will get removed, and the plugin won't run
*/
@Deprecated
@ApiStatus.Internal
public interface InternalPotionData {
PotionEffectType getEffectType();
List<PotionEffect> getPotionEffects();
boolean isInstant();
boolean isUpgradeable();
boolean isExtendable();
int getMaxLevel();
}
}

View File

@ -0,0 +1,58 @@
package org.bukkit.scoreboard;
import net.kyori.adventure.text.format.NamedTextColor; // Paper
/**
* Locations for displaying objectives to the player
*/
public enum DisplaySlot {
// Paper start
// Paper start - Generated/DisplaySlot
// @GeneratedFrom 1.21.3
PLAYER_LIST("list"),
SIDEBAR("sidebar"),
BELOW_NAME("below_name"),
SIDEBAR_TEAM_BLACK("sidebar.team.black"),
SIDEBAR_TEAM_DARK_BLUE("sidebar.team.dark_blue"),
SIDEBAR_TEAM_DARK_GREEN("sidebar.team.dark_green"),
SIDEBAR_TEAM_DARK_AQUA("sidebar.team.dark_aqua"),
SIDEBAR_TEAM_DARK_RED("sidebar.team.dark_red"),
SIDEBAR_TEAM_DARK_PURPLE("sidebar.team.dark_purple"),
SIDEBAR_TEAM_GOLD("sidebar.team.gold"),
SIDEBAR_TEAM_GRAY("sidebar.team.gray"),
SIDEBAR_TEAM_DARK_GRAY("sidebar.team.dark_gray"),
SIDEBAR_TEAM_BLUE("sidebar.team.blue"),
SIDEBAR_TEAM_GREEN("sidebar.team.green"),
SIDEBAR_TEAM_AQUA("sidebar.team.aqua"),
SIDEBAR_TEAM_RED("sidebar.team.red"),
SIDEBAR_TEAM_LIGHT_PURPLE("sidebar.team.light_purple"),
SIDEBAR_TEAM_YELLOW("sidebar.team.yellow"),
SIDEBAR_TEAM_WHITE("sidebar.team.white");
// Paper end - Generated/DisplaySlot
public static final net.kyori.adventure.util.Index<String, DisplaySlot> NAMES = net.kyori.adventure.util.Index.create(DisplaySlot.class, DisplaySlot::getId);
private final String id;
DisplaySlot(@org.jetbrains.annotations.NotNull String id) {
this.id = id;
}
DisplaySlot(@org.jetbrains.annotations.NotNull NamedTextColor color) {
this.id = "sidebar.team." + color;
}
/**
* Get the string id of this display slot.
*
* @return the string id
*/
public @org.jetbrains.annotations.NotNull String getId() {
return id;
}
@Override
public String toString() {
return this.id;
}
// Paper end
}

View File

@ -0,0 +1,97 @@
package org.bukkit.tag;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.Tag;
import org.bukkit.damage.DamageType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
/**
* Vanilla {@link DamageType} {@link Tag tags}.
*/
@ApiStatus.Experimental
public final class DamageTypeTags {
// Paper start - Generated/DamageTypeTags
// @GeneratedFrom 1.21.3
public static final Tag<DamageType> ALWAYS_HURTS_ENDER_DRAGONS = getTag("always_hurts_ender_dragons");
public static final Tag<DamageType> ALWAYS_KILLS_ARMOR_STANDS = getTag("always_kills_armor_stands");
public static final Tag<DamageType> ALWAYS_MOST_SIGNIFICANT_FALL = getTag("always_most_significant_fall");
public static final Tag<DamageType> ALWAYS_TRIGGERS_SILVERFISH = getTag("always_triggers_silverfish");
public static final Tag<DamageType> AVOIDS_GUARDIAN_THORNS = getTag("avoids_guardian_thorns");
public static final Tag<DamageType> BURN_FROM_STEPPING = getTag("burn_from_stepping");
public static final Tag<DamageType> BURNS_ARMOR_STANDS = getTag("burns_armor_stands");
public static final Tag<DamageType> BYPASSES_ARMOR = getTag("bypasses_armor");
public static final Tag<DamageType> BYPASSES_EFFECTS = getTag("bypasses_effects");
public static final Tag<DamageType> BYPASSES_ENCHANTMENTS = getTag("bypasses_enchantments");
public static final Tag<DamageType> BYPASSES_INVULNERABILITY = getTag("bypasses_invulnerability");
public static final Tag<DamageType> BYPASSES_RESISTANCE = getTag("bypasses_resistance");
public static final Tag<DamageType> BYPASSES_SHIELD = getTag("bypasses_shield");
public static final Tag<DamageType> BYPASSES_WOLF_ARMOR = getTag("bypasses_wolf_armor");
public static final Tag<DamageType> CAN_BREAK_ARMOR_STAND = getTag("can_break_armor_stand");
public static final Tag<DamageType> DAMAGES_HELMET = getTag("damages_helmet");
public static final Tag<DamageType> IGNITES_ARMOR_STANDS = getTag("ignites_armor_stands");
public static final Tag<DamageType> IS_DROWNING = getTag("is_drowning");
public static final Tag<DamageType> IS_EXPLOSION = getTag("is_explosion");
public static final Tag<DamageType> IS_FALL = getTag("is_fall");
public static final Tag<DamageType> IS_FIRE = getTag("is_fire");
public static final Tag<DamageType> IS_FREEZING = getTag("is_freezing");
public static final Tag<DamageType> IS_LIGHTNING = getTag("is_lightning");
public static final Tag<DamageType> IS_PLAYER_ATTACK = getTag("is_player_attack");
public static final Tag<DamageType> IS_PROJECTILE = getTag("is_projectile");
public static final Tag<DamageType> IS_MACE_SMASH = getTag("mace_smash");
public static final Tag<DamageType> NO_ANGER = getTag("no_anger");
public static final Tag<DamageType> NO_IMPACT = getTag("no_impact");
public static final Tag<DamageType> NO_KNOCKBACK = getTag("no_knockback");
public static final Tag<DamageType> PANIC_CAUSES = getTag("panic_causes");
public static final Tag<DamageType> PANIC_ENVIRONMENTAL_CAUSES = getTag("panic_environmental_causes");
public static final Tag<DamageType> WITCH_RESISTANT_TO = getTag("witch_resistant_to");
public static final Tag<DamageType> WITHER_IMMUNE_TO = getTag("wither_immune_to");
// Paper end - Generated/DamageTypeTags
/**
* Internal use only.
*/
@ApiStatus.Internal
public static final String REGISTRY_DAMAGE_TYPES = "damage_types";
@Nullable
private static Tag<DamageType> getTag(String key) {
return Bukkit.getTag(REGISTRY_DAMAGE_TYPES, NamespacedKey.minecraft(key), DamageType.class);
}
private DamageTypeTags() {
}
}

View File

@ -0,0 +1,174 @@
package io.papermc.paper.registry;
import com.google.common.base.Preconditions;
import io.papermc.paper.adventure.PaperAdventure;
import io.papermc.paper.datacomponent.DataComponentType;
import io.papermc.paper.datacomponent.PaperComponentType;
import io.papermc.paper.registry.data.PaperEnchantmentRegistryEntry;
import io.papermc.paper.registry.data.PaperGameEventRegistryEntry;
import io.papermc.paper.registry.data.PaperPaintingVariantRegistryEntry;
import io.papermc.paper.registry.entry.RegistryEntry;
import io.papermc.paper.registry.tag.TagKey;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import org.bukkit.Art;
import org.bukkit.Fluid;
import org.bukkit.GameEvent;
import org.bukkit.JukeboxSong;
import org.bukkit.Keyed;
import org.bukkit.MusicInstrument;
import org.bukkit.Sound;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.Biome;
import org.bukkit.block.BlockType;
import org.bukkit.block.banner.PatternType;
import org.bukkit.craftbukkit.CraftArt;
import org.bukkit.craftbukkit.CraftFluid;
import org.bukkit.craftbukkit.CraftGameEvent;
import org.bukkit.craftbukkit.CraftJukeboxSong;
import org.bukkit.craftbukkit.CraftMusicInstrument;
import org.bukkit.craftbukkit.CraftSound;
import org.bukkit.craftbukkit.attribute.CraftAttribute;
import org.bukkit.craftbukkit.block.CraftBiome;
import org.bukkit.craftbukkit.block.CraftBlockType;
import org.bukkit.craftbukkit.block.banner.CraftPatternType;
import org.bukkit.craftbukkit.damage.CraftDamageType;
import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
import org.bukkit.craftbukkit.entity.CraftCat;
import org.bukkit.craftbukkit.entity.CraftFrog;
import org.bukkit.craftbukkit.entity.CraftVillager;
import org.bukkit.craftbukkit.entity.CraftWolf;
import org.bukkit.craftbukkit.generator.structure.CraftStructure;
import org.bukkit.craftbukkit.generator.structure.CraftStructureType;
import org.bukkit.craftbukkit.inventory.CraftItemType;
import org.bukkit.craftbukkit.inventory.CraftMenuType;
import org.bukkit.craftbukkit.inventory.trim.CraftTrimMaterial;
import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern;
import org.bukkit.craftbukkit.legacy.FieldRename;
import org.bukkit.craftbukkit.map.CraftMapCursor;
import org.bukkit.craftbukkit.potion.CraftPotionEffectType;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.damage.DamageType;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Cat;
import org.bukkit.entity.Frog;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.memory.MemoryKey;
import org.bukkit.generator.structure.Structure;
import org.bukkit.generator.structure.StructureType;
import org.bukkit.inventory.ItemType;
import org.bukkit.inventory.MenuType;
import org.bukkit.inventory.meta.trim.TrimMaterial;
import org.bukkit.inventory.meta.trim.TrimPattern;
import org.bukkit.map.MapCursor;
import org.bukkit.potion.PotionEffectType;
import org.jspecify.annotations.Nullable;
import static io.papermc.paper.registry.entry.RegistryEntry.apiOnly;
import static io.papermc.paper.registry.entry.RegistryEntry.entry;
import static io.papermc.paper.registry.entry.RegistryEntry.writable;
public final class PaperRegistries {
static final List<RegistryEntry<?, ?>> REGISTRY_ENTRIES;
private static final Map<RegistryKey<?>, RegistryEntry<?, ?>> BY_REGISTRY_KEY;
private static final Map<ResourceKey<?>, RegistryEntry<?, ?>> BY_RESOURCE_KEY;
static {
REGISTRY_ENTRIES = List.of(
// Paper start - Generated/RegistryDefinitions
// @GeneratedFrom 1.21.3
// built-in
writable(Registries.GAME_EVENT, RegistryKey.GAME_EVENT, GameEvent.class, CraftGameEvent::new, PaperGameEventRegistryEntry.PaperBuilder::new),
entry(Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, StructureType.class, CraftStructureType::new),
entry(Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, PotionEffectType.class, CraftPotionEffectType::new),
entry(Registries.BLOCK, RegistryKey.BLOCK, BlockType.class, CraftBlockType::new),
entry(Registries.ITEM, RegistryKey.ITEM, ItemType.class, CraftItemType::new),
entry(Registries.CAT_VARIANT, RegistryKey.CAT_VARIANT, Cat.Type.class, CraftCat.CraftType::new),
entry(Registries.FROG_VARIANT, RegistryKey.FROG_VARIANT, Frog.Variant.class, CraftFrog.CraftVariant::new),
entry(Registries.VILLAGER_PROFESSION, RegistryKey.VILLAGER_PROFESSION, Villager.Profession.class, CraftVillager.CraftProfession::new),
entry(Registries.VILLAGER_TYPE, RegistryKey.VILLAGER_TYPE, Villager.Type.class, CraftVillager.CraftType::new),
entry(Registries.MAP_DECORATION_TYPE, RegistryKey.MAP_DECORATION_TYPE, MapCursor.Type.class, CraftMapCursor.CraftType::new),
entry(Registries.MENU, RegistryKey.MENU, MenuType.class, CraftMenuType::new),
entry(Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, Attribute.class, CraftAttribute::new),
entry(Registries.FLUID, RegistryKey.FLUID, Fluid.class, CraftFluid::new),
entry(Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT, Sound.class, CraftSound::new),
entry(Registries.DATA_COMPONENT_TYPE, RegistryKey.DATA_COMPONENT_TYPE, DataComponentType.class, PaperComponentType::of),
// data-driven
entry(Registries.BIOME, RegistryKey.BIOME, Biome.class, CraftBiome::new).delayed(),
entry(Registries.STRUCTURE, RegistryKey.STRUCTURE, Structure.class, CraftStructure::new).delayed(),
entry(Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL, TrimMaterial.class, CraftTrimMaterial::new).delayed(),
entry(Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, TrimPattern.class, CraftTrimPattern::new).delayed(),
entry(Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, DamageType.class, CraftDamageType::new).delayed(),
entry(Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, Wolf.Variant.class, CraftWolf.CraftVariant::new).delayed(),
writable(Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, Enchantment.class, CraftEnchantment::new, PaperEnchantmentRegistryEntry.PaperBuilder::new).withSerializationUpdater(FieldRename.ENCHANTMENT_RENAME).delayed(),
entry(Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, JukeboxSong.class, CraftJukeboxSong::new).delayed(),
entry(Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, PatternType.class, CraftPatternType::new).delayed(),
writable(Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, Art.class, CraftArt::new, PaperPaintingVariantRegistryEntry.PaperBuilder::new).delayed(),
entry(Registries.INSTRUMENT, RegistryKey.INSTRUMENT, MusicInstrument.class, CraftMusicInstrument::new).delayed(),
// api-only
apiOnly(Registries.ENTITY_TYPE, RegistryKey.ENTITY_TYPE, PaperSimpleRegistry::entityType),
apiOnly(Registries.PARTICLE_TYPE, RegistryKey.PARTICLE_TYPE, PaperSimpleRegistry::particleType),
apiOnly(Registries.POTION, RegistryKey.POTION, PaperSimpleRegistry::potion),
apiOnly(Registries.MEMORY_MODULE_TYPE, RegistryKey.MEMORY_MODULE_TYPE, () -> org.bukkit.Registry.MEMORY_MODULE_TYPE)
// Paper end - Generated/RegistryDefinitions
);
final Map<RegistryKey<?>, RegistryEntry<?, ?>> byRegistryKey = new IdentityHashMap<>(REGISTRY_ENTRIES.size());
final Map<ResourceKey<?>, RegistryEntry<?, ?>> byResourceKey = new IdentityHashMap<>(REGISTRY_ENTRIES.size());
for (final RegistryEntry<?, ?> entry : REGISTRY_ENTRIES) {
Preconditions.checkState(byRegistryKey.put(entry.apiKey(), entry) == null, "Duplicate api registry key: %s", entry.apiKey());
Preconditions.checkState(byResourceKey.put(entry.mcKey(), entry) == null, "Duplicate mc registry key: %s", entry.mcKey());
}
BY_REGISTRY_KEY = Collections.unmodifiableMap(byRegistryKey);
BY_RESOURCE_KEY = Collections.unmodifiableMap(byResourceKey);
}
@SuppressWarnings("unchecked")
public static <M, T extends Keyed> @Nullable RegistryEntry<M, T> getEntry(final ResourceKey<? extends Registry<M>> resourceKey) {
return (RegistryEntry<M, T>) BY_RESOURCE_KEY.get(resourceKey);
}
@SuppressWarnings("unchecked")
public static <M, T extends Keyed> @Nullable RegistryEntry<M, T> getEntry(final RegistryKey<? super T> registryKey) {
return (RegistryEntry<M, T>) BY_REGISTRY_KEY.get(registryKey);
}
@SuppressWarnings("unchecked")
public static <M, T> RegistryKey<T> registryFromNms(final ResourceKey<? extends Registry<M>> registryResourceKey) {
return (RegistryKey<T>) Objects.requireNonNull(BY_RESOURCE_KEY.get(registryResourceKey), registryResourceKey + " doesn't have an api RegistryKey").apiKey();
}
@SuppressWarnings("unchecked")
public static <M, T> ResourceKey<? extends Registry<M>> registryToNms(final RegistryKey<T> registryKey) {
return (ResourceKey<? extends Registry<M>>) Objects.requireNonNull(BY_REGISTRY_KEY.get(registryKey), registryKey + " doesn't have an mc registry ResourceKey").mcKey();
}
public static <M, T> TypedKey<T> fromNms(final ResourceKey<M> resourceKey) {
return TypedKey.create(registryFromNms(resourceKey.registryKey()), CraftNamespacedKey.fromMinecraft(resourceKey.location()));
}
@SuppressWarnings({"unchecked", "RedundantCast"})
public static <M, T> ResourceKey<M> toNms(final TypedKey<T> typedKey) {
return ResourceKey.create((ResourceKey<? extends Registry<M>>) PaperRegistries.registryToNms(typedKey.registryKey()), PaperAdventure.asVanilla(typedKey.key()));
}
public static <M, T> TagKey<T> fromNms(final net.minecraft.tags.TagKey<M> tagKey) {
return TagKey.create(registryFromNms(tagKey.registry()), CraftNamespacedKey.fromMinecraft(tagKey.location()));
}
@SuppressWarnings({"unchecked", "RedundantCast"})
public static <M, T> net.minecraft.tags.TagKey<M> toNms(final TagKey<T> tagKey) {
return net.minecraft.tags.TagKey.create((ResourceKey<? extends Registry<M>>) registryToNms(tagKey.registryKey()), PaperAdventure.asVanilla(tagKey.key()));
}
private PaperRegistries() {
}
}

View File

@ -0,0 +1,58 @@
package io.papermc.paper.world.flag;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.world.flag.FeatureElement;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.flag.FeatureFlags;
import org.bukkit.FeatureFlag;
import org.bukkit.craftbukkit.entity.CraftEntityType;
import org.bukkit.craftbukkit.entity.CraftEntityTypes;
import org.bukkit.craftbukkit.potion.CraftPotionType;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.entity.EntityType;
import org.bukkit.potion.PotionType;
public class PaperFeatureFlagProviderImpl implements FeatureFlagProvider {
public static final BiMap<FeatureFlag, net.minecraft.world.flag.FeatureFlag> FLAGS = ImmutableBiMap.of(
// Paper start - Generated/PaperFeatureFlagProviderImpl#FLAGS
// @GeneratedFrom 1.21.3
FeatureFlag.MINECART_IMPROVEMENTS, FeatureFlags.MINECART_IMPROVEMENTS,
FeatureFlag.REDSTONE_EXPERIMENTS, FeatureFlags.REDSTONE_EXPERIMENTS,
FeatureFlag.TRADE_REBALANCE, FeatureFlags.TRADE_REBALANCE,
FeatureFlag.VANILLA, FeatureFlags.VANILLA,
FeatureFlag.WINTER_DROP, FeatureFlags.WINTER_DROP
// Paper end - Generated/PaperFeatureFlagProviderImpl#FLAGS
);
@Override
public Set<FeatureFlag> requiredFeatures(final FeatureDependant dependant) {
final FeatureFlagSet requiredFeatures = getFeatureElement(dependant).requiredFeatures();
return fromNms(requiredFeatures);
}
public static Set<FeatureFlag> fromNms(final FeatureFlagSet flagSet) {
final Set<FeatureFlag> flags = new HashSet<>();
for (final net.minecraft.world.flag.FeatureFlag nmsFlag : FeatureFlags.REGISTRY.names.values()) {
if (flagSet.contains(nmsFlag)) {
flags.add(FLAGS.inverse().get(nmsFlag));
}
}
return Collections.unmodifiableSet(flags);
}
static FeatureElement getFeatureElement(final FeatureDependant dependant) {
if (dependant instanceof final EntityType entityType) {
// TODO remove when EntityType is server-backed
return CraftEntityType.bukkitToMinecraft(entityType);
} else if (dependant instanceof final PotionType potionType) {
return CraftPotionType.bukkitToMinecraft(potionType);
} else {
throw new IllegalArgumentException(dependant + " is not a valid feature dependant");
}
}
}

View File

@ -0,0 +1,335 @@
package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.stats.ServerStatsCounter;
import net.minecraft.stats.Stats;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.Statistic.Type;
import org.bukkit.craftbukkit.block.CraftBlockType;
import org.bukkit.craftbukkit.entity.CraftEntityType;
import org.bukkit.craftbukkit.inventory.CraftItemType;
import org.bukkit.entity.EntityType;
public enum CraftStatistic {
// Paper start - Generated/CraftStatisticCustom
// @GeneratedFrom 1.21.3
ANIMALS_BRED(Stats.ANIMALS_BRED),
AVIATE_ONE_CM(Stats.AVIATE_ONE_CM),
BELL_RING(Stats.BELL_RING),
BOAT_ONE_CM(Stats.BOAT_ONE_CM),
ARMOR_CLEANED(Stats.CLEAN_ARMOR),
BANNER_CLEANED(Stats.CLEAN_BANNER),
CLEAN_SHULKER_BOX(Stats.CLEAN_SHULKER_BOX),
CLIMB_ONE_CM(Stats.CLIMB_ONE_CM),
CROUCH_ONE_CM(Stats.CROUCH_ONE_CM),
DAMAGE_ABSORBED(Stats.DAMAGE_ABSORBED),
DAMAGE_BLOCKED_BY_SHIELD(Stats.DAMAGE_BLOCKED_BY_SHIELD),
DAMAGE_DEALT(Stats.DAMAGE_DEALT),
DAMAGE_DEALT_ABSORBED(Stats.DAMAGE_DEALT_ABSORBED),
DAMAGE_DEALT_RESISTED(Stats.DAMAGE_DEALT_RESISTED),
DAMAGE_RESISTED(Stats.DAMAGE_RESISTED),
DAMAGE_TAKEN(Stats.DAMAGE_TAKEN),
DEATHS(Stats.DEATHS),
DROP_COUNT(Stats.DROP),
CAKE_SLICES_EATEN(Stats.EAT_CAKE_SLICE),
ITEM_ENCHANTED(Stats.ENCHANT_ITEM),
FALL_ONE_CM(Stats.FALL_ONE_CM),
CAULDRON_FILLED(Stats.FILL_CAULDRON),
FISH_CAUGHT(Stats.FISH_CAUGHT),
FLY_ONE_CM(Stats.FLY_ONE_CM),
HORSE_ONE_CM(Stats.HORSE_ONE_CM),
DISPENSER_INSPECTED(Stats.INSPECT_DISPENSER),
DROPPER_INSPECTED(Stats.INSPECT_DROPPER),
HOPPER_INSPECTED(Stats.INSPECT_HOPPER),
INTERACT_WITH_ANVIL(Stats.INTERACT_WITH_ANVIL),
BEACON_INTERACTION(Stats.INTERACT_WITH_BEACON),
INTERACT_WITH_BLAST_FURNACE(Stats.INTERACT_WITH_BLAST_FURNACE),
BREWINGSTAND_INTERACTION(Stats.INTERACT_WITH_BREWINGSTAND),
INTERACT_WITH_CAMPFIRE(Stats.INTERACT_WITH_CAMPFIRE),
INTERACT_WITH_CARTOGRAPHY_TABLE(Stats.INTERACT_WITH_CARTOGRAPHY_TABLE),
CRAFTING_TABLE_INTERACTION(Stats.INTERACT_WITH_CRAFTING_TABLE),
FURNACE_INTERACTION(Stats.INTERACT_WITH_FURNACE),
INTERACT_WITH_GRINDSTONE(Stats.INTERACT_WITH_GRINDSTONE),
INTERACT_WITH_LECTERN(Stats.INTERACT_WITH_LECTERN),
INTERACT_WITH_LOOM(Stats.INTERACT_WITH_LOOM),
INTERACT_WITH_SMITHING_TABLE(Stats.INTERACT_WITH_SMITHING_TABLE),
INTERACT_WITH_SMOKER(Stats.INTERACT_WITH_SMOKER),
INTERACT_WITH_STONECUTTER(Stats.INTERACT_WITH_STONECUTTER),
JUMP(Stats.JUMP),
LEAVE_GAME(Stats.LEAVE_GAME),
MINECART_ONE_CM(Stats.MINECART_ONE_CM),
MOB_KILLS(Stats.MOB_KILLS),
OPEN_BARREL(Stats.OPEN_BARREL),
CHEST_OPENED(Stats.OPEN_CHEST),
ENDERCHEST_OPENED(Stats.OPEN_ENDERCHEST),
SHULKER_BOX_OPENED(Stats.OPEN_SHULKER_BOX),
PIG_ONE_CM(Stats.PIG_ONE_CM),
NOTEBLOCK_PLAYED(Stats.PLAY_NOTEBLOCK),
RECORD_PLAYED(Stats.PLAY_RECORD),
PLAY_ONE_MINUTE(Stats.PLAY_TIME),
PLAYER_KILLS(Stats.PLAYER_KILLS),
FLOWER_POTTED(Stats.POT_FLOWER),
RAID_TRIGGER(Stats.RAID_TRIGGER),
RAID_WIN(Stats.RAID_WIN),
SLEEP_IN_BED(Stats.SLEEP_IN_BED),
SNEAK_TIME(Stats.CROUCH_TIME),
SPRINT_ONE_CM(Stats.SPRINT_ONE_CM),
STRIDER_ONE_CM(Stats.STRIDER_ONE_CM),
SWIM_ONE_CM(Stats.SWIM_ONE_CM),
TALKED_TO_VILLAGER(Stats.TALKED_TO_VILLAGER),
TARGET_HIT(Stats.TARGET_HIT),
TIME_SINCE_DEATH(Stats.TIME_SINCE_DEATH),
TIME_SINCE_REST(Stats.TIME_SINCE_REST),
TOTAL_WORLD_TIME(Stats.TOTAL_WORLD_TIME),
TRADED_WITH_VILLAGER(Stats.TRADED_WITH_VILLAGER),
TRAPPED_CHEST_TRIGGERED(Stats.TRIGGER_TRAPPED_CHEST),
NOTEBLOCK_TUNED(Stats.TUNE_NOTEBLOCK),
CAULDRON_USED(Stats.USE_CAULDRON),
WALK_ON_WATER_ONE_CM(Stats.WALK_ON_WATER_ONE_CM),
WALK_ONE_CM(Stats.WALK_ONE_CM),
WALK_UNDER_WATER_ONE_CM(Stats.WALK_UNDER_WATER_ONE_CM),
// Paper end - Generated/CraftStatisticCustom
// Paper start - Generated/CraftStatisticType
// @GeneratedFrom 1.21.3
BREAK_ITEM(ResourceLocation.withDefaultNamespace("broken")),
CRAFT_ITEM(ResourceLocation.withDefaultNamespace("crafted")),
DROP(ResourceLocation.withDefaultNamespace("dropped")),
KILL_ENTITY(ResourceLocation.withDefaultNamespace("killed")),
ENTITY_KILLED_BY(ResourceLocation.withDefaultNamespace("killed_by")),
MINE_BLOCK(ResourceLocation.withDefaultNamespace("mined")),
PICKUP(ResourceLocation.withDefaultNamespace("picked_up")),
USE_ITEM(ResourceLocation.withDefaultNamespace("used"));
// Paper end - Generated/CraftStatisticType
private final ResourceLocation minecraftKey;
private final org.bukkit.Statistic bukkit;
private static final BiMap<ResourceLocation, org.bukkit.Statistic> statistics;
static {
ImmutableBiMap.Builder<ResourceLocation, org.bukkit.Statistic> statisticBuilder = ImmutableBiMap.builder();
for (CraftStatistic statistic : CraftStatistic.values()) {
statisticBuilder.put(statistic.minecraftKey, statistic.bukkit);
}
statistics = statisticBuilder.build();
}
private CraftStatistic(ResourceLocation minecraftKey) {
this.minecraftKey = minecraftKey;
this.bukkit = org.bukkit.Statistic.valueOf(this.name());
Preconditions.checkState(this.bukkit != null, "Bukkit statistic %s does not exist", this.name());
}
public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Stat<?> statistic) {
Preconditions.checkArgument(statistic != null, "NMS Statistic cannot be null");
Registry statRegistry = statistic.getType().getRegistry();
ResourceLocation nmsKey = BuiltInRegistries.STAT_TYPE.getKey(statistic.getType());
if (statRegistry == BuiltInRegistries.CUSTOM_STAT) {
nmsKey = (ResourceLocation) statistic.getValue();
}
return statistics.get(nmsKey);
}
public static net.minecraft.stats.Stat getNMSStatistic(org.bukkit.Statistic bukkit) {
Preconditions.checkArgument(bukkit.getType() == Statistic.Type.UNTYPED, "This method only accepts untyped statistics");
net.minecraft.stats.Stat<ResourceLocation> nms = Stats.CUSTOM.get(statistics.inverse().get(bukkit));
Preconditions.checkArgument(nms != null, "NMS Statistic %s does not exist", bukkit);
return nms;
}
public static net.minecraft.stats.Stat getMaterialStatistic(org.bukkit.Statistic stat, Material material) {
try {
if (stat == Statistic.MINE_BLOCK) {
return Stats.BLOCK_MINED.get(CraftBlockType.bukkitToMinecraft(material));
}
if (stat == Statistic.CRAFT_ITEM) {
return Stats.ITEM_CRAFTED.get(CraftItemType.bukkitToMinecraft(material));
}
if (stat == Statistic.USE_ITEM) {
return Stats.ITEM_USED.get(CraftItemType.bukkitToMinecraft(material));
}
if (stat == Statistic.BREAK_ITEM) {
return Stats.ITEM_BROKEN.get(CraftItemType.bukkitToMinecraft(material));
}
if (stat == Statistic.PICKUP) {
return Stats.ITEM_PICKED_UP.get(CraftItemType.bukkitToMinecraft(material));
}
if (stat == Statistic.DROP) {
return Stats.ITEM_DROPPED.get(CraftItemType.bukkitToMinecraft(material));
}
} catch (ArrayIndexOutOfBoundsException e) {
return null;
}
return null;
}
public static net.minecraft.stats.Stat getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) {
Preconditions.checkArgument(entity != null, "EntityType cannot be null");
if (entity.getName() != null) {
net.minecraft.world.entity.EntityType<?> nmsEntity = CraftEntityType.bukkitToMinecraft(entity);
if (stat == org.bukkit.Statistic.KILL_ENTITY) {
return net.minecraft.stats.Stats.ENTITY_KILLED.get(nmsEntity);
}
if (stat == org.bukkit.Statistic.ENTITY_KILLED_BY) {
return net.minecraft.stats.Stats.ENTITY_KILLED_BY.get(nmsEntity);
}
}
return null;
}
public static EntityType getEntityTypeFromStatistic(net.minecraft.stats.Stat<net.minecraft.world.entity.EntityType<?>> statistic) {
Preconditions.checkArgument(statistic != null, "NMS Statistic cannot be null");
return CraftEntityType.minecraftToBukkit(statistic.getValue());
}
public static Material getMaterialFromStatistic(net.minecraft.stats.Stat<?> statistic) {
if (statistic.getValue() instanceof Item statisticItemValue) {
return CraftItemType.minecraftToBukkit(statisticItemValue);
}
if (statistic.getValue() instanceof Block statisticBlockValue) {
return CraftBlockType.minecraftToBukkit(statisticBlockValue);
}
return null;
}
public static void incrementStatistic(ServerStatsCounter manager, Statistic statistic, ServerPlayer player) {
incrementStatistic(manager, statistic, 1, player);
}
public static void decrementStatistic(ServerStatsCounter manager, Statistic statistic, ServerPlayer player) {
decrementStatistic(manager, statistic, 1, player);
}
public static int getStatistic(ServerStatsCounter manager, Statistic statistic) {
Preconditions.checkArgument(statistic != null, "Statistic cannot be null");
Preconditions.checkArgument(statistic.getType() == Type.UNTYPED, "Must supply additional parameter for this statistic");
return manager.getValue(CraftStatistic.getNMSStatistic(statistic));
}
public static void incrementStatistic(ServerStatsCounter manager, Statistic statistic, int amount, ServerPlayer player) {
Preconditions.checkArgument(amount > 0, "Amount must be greater than 0");
setStatistic(manager, statistic, getStatistic(manager, statistic) + amount, player);
}
public static void decrementStatistic(ServerStatsCounter manager, Statistic statistic, int amount, ServerPlayer player) {
Preconditions.checkArgument(amount > 0, "Amount must be greater than 0");
setStatistic(manager, statistic, getStatistic(manager, statistic) - amount, player);
}
public static void setStatistic(ServerStatsCounter manager, Statistic statistic, int newValue, ServerPlayer player) {
Preconditions.checkArgument(statistic != null, "Statistic cannot be null");
Preconditions.checkArgument(statistic.getType() == Type.UNTYPED, "Must supply additional parameter for this statistic");
Preconditions.checkArgument(newValue >= 0, "Value must be greater than or equal to 0");
net.minecraft.stats.Stat nmsStatistic = CraftStatistic.getNMSStatistic(statistic);
manager.setValue(null, nmsStatistic, newValue);
// Update scoreboards
if (player != null) {
player.level().getCraftServer().getScoreboardManager().forAllObjectives(nmsStatistic, player, score -> {
score.set(newValue);
});
}
}
public static void incrementStatistic(ServerStatsCounter manager, Statistic statistic, Material material, ServerPlayer player) {
incrementStatistic(manager, statistic, material, 1, player);
}
public static void decrementStatistic(ServerStatsCounter manager, Statistic statistic, Material material, ServerPlayer player) {
decrementStatistic(manager, statistic, material, 1, player);
}
public static int getStatistic(ServerStatsCounter manager, Statistic statistic, Material material) {
Preconditions.checkArgument(statistic != null, "Statistic cannot be null");
Preconditions.checkArgument(material != null, "Material cannot be null");
Preconditions.checkArgument(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
net.minecraft.stats.Stat nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
Preconditions.checkArgument(nmsStatistic != null, "The supplied Material %s does not have a corresponding statistic", material);
return manager.getValue(nmsStatistic);
}
public static void incrementStatistic(ServerStatsCounter manager, Statistic statistic, Material material, int amount, ServerPlayer player) {
Preconditions.checkArgument(amount > 0, "Amount must be greater than 0");
setStatistic(manager, statistic, material, getStatistic(manager, statistic, material) + amount, player);
}
public static void decrementStatistic(ServerStatsCounter manager, Statistic statistic, Material material, int amount, ServerPlayer player) {
Preconditions.checkArgument(amount > 0, "Amount must be greater than 0");
setStatistic(manager, statistic, material, getStatistic(manager, statistic, material) - amount, player);
}
public static void setStatistic(ServerStatsCounter manager, Statistic statistic, Material material, int newValue, ServerPlayer player) {
Preconditions.checkArgument(statistic != null, "Statistic cannot be null");
Preconditions.checkArgument(material != null, "Material cannot be null");
Preconditions.checkArgument(newValue >= 0, "Value must be greater than or equal to 0");
Preconditions.checkArgument(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
net.minecraft.stats.Stat nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
Preconditions.checkArgument(nmsStatistic != null, "The supplied Material %s does not have a corresponding statistic", material);
manager.setValue(null, nmsStatistic, newValue);
// Update scoreboards
if (player != null) {
player.level().getCraftServer().getScoreboardManager().forAllObjectives(nmsStatistic, player, score -> {
score.set(newValue);
});
}
}
public static void incrementStatistic(ServerStatsCounter manager, Statistic statistic, EntityType entityType, ServerPlayer player) {
incrementStatistic(manager, statistic, entityType, 1, player);
}
public static void decrementStatistic(ServerStatsCounter manager, Statistic statistic, EntityType entityType, ServerPlayer player) {
decrementStatistic(manager, statistic, entityType, 1, player);
}
public static int getStatistic(ServerStatsCounter manager, Statistic statistic, EntityType entityType) {
Preconditions.checkArgument(statistic != null, "Statistic cannot be null");
Preconditions.checkArgument(entityType != null, "EntityType cannot be null");
Preconditions.checkArgument(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
net.minecraft.stats.Stat nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
Preconditions.checkArgument(nmsStatistic != null, "The supplied EntityType %s does not have a corresponding statistic", entityType);
return manager.getValue(nmsStatistic);
}
public static void incrementStatistic(ServerStatsCounter manager, Statistic statistic, EntityType entityType, int amount, ServerPlayer player) {
Preconditions.checkArgument(amount > 0, "Amount must be greater than 0");
setStatistic(manager, statistic, entityType, getStatistic(manager, statistic, entityType) + amount, player);
}
public static void decrementStatistic(ServerStatsCounter manager, Statistic statistic, EntityType entityType, int amount, ServerPlayer player) {
Preconditions.checkArgument(amount > 0, "Amount must be greater than 0");
setStatistic(manager, statistic, entityType, getStatistic(manager, statistic, entityType) - amount, player);
}
public static void setStatistic(ServerStatsCounter manager, Statistic statistic, EntityType entityType, int newValue, ServerPlayer player) {
Preconditions.checkArgument(statistic != null, "Statistic cannot be null");
Preconditions.checkArgument(entityType != null, "EntityType cannot be null");
Preconditions.checkArgument(newValue >= 0, "Value must be greater than or equal to 0");
Preconditions.checkArgument(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
net.minecraft.stats.Stat nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
Preconditions.checkArgument(nmsStatistic != null, "The supplied EntityType %s does not have a corresponding statistic", entityType);
manager.setValue(null, nmsStatistic, newValue);
// Update scoreboards
if (player != null) {
player.level().getCraftServer().getScoreboardManager().forAllObjectives(nmsStatistic, player, score -> {
score.set(newValue);
});
}
}
}

View File

@ -0,0 +1,336 @@
package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.entity.BannerBlockEntity;
import net.minecraft.world.level.block.entity.BarrelBlockEntity;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
import net.minecraft.world.level.block.entity.BedBlockEntity;
import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
import net.minecraft.world.level.block.entity.BellBlockEntity;
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType; // Paper
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
import net.minecraft.world.level.block.entity.BrushableBlockEntity;
import net.minecraft.world.level.block.entity.CalibratedSculkSensorBlockEntity;
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import net.minecraft.world.level.block.entity.CommandBlockEntity;
import net.minecraft.world.level.block.entity.ComparatorBlockEntity;
import net.minecraft.world.level.block.entity.ConduitBlockEntity;
import net.minecraft.world.level.block.entity.CrafterBlockEntity;
import net.minecraft.world.level.block.entity.CreakingHeartBlockEntity;
import net.minecraft.world.level.block.entity.DaylightDetectorBlockEntity;
import net.minecraft.world.level.block.entity.DecoratedPotBlockEntity;
import net.minecraft.world.level.block.entity.DispenserBlockEntity;
import net.minecraft.world.level.block.entity.DropperBlockEntity;
import net.minecraft.world.level.block.entity.EnchantingTableBlockEntity;
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
import net.minecraft.world.level.block.entity.HangingSignBlockEntity;
import net.minecraft.world.level.block.entity.HopperBlockEntity;
import net.minecraft.world.level.block.entity.JigsawBlockEntity;
import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
import net.minecraft.world.level.block.entity.LecternBlockEntity;
import net.minecraft.world.level.block.entity.SculkCatalystBlockEntity;
import net.minecraft.world.level.block.entity.SculkSensorBlockEntity;
import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity;
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import net.minecraft.world.level.block.entity.SmokerBlockEntity;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.entity.StructureBlockEntity;
import net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity;
import net.minecraft.world.level.block.entity.TheEndPortalBlockEntity;
import net.minecraft.world.level.block.entity.TrappedChestBlockEntity;
import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity;
import net.minecraft.world.level.block.entity.vault.VaultBlockEntity;
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftWorld;
public final class CraftBlockStates {
private abstract static class BlockStateFactory<B extends CraftBlockState> {
public final Class<B> blockStateType;
public BlockStateFactory(Class<B> blockStateType) {
this.blockStateType = blockStateType;
}
// The given world can be null for unplaced BlockStates.
// If the world is not null and the given block data is a tile entity, the given tile entity is expected to not be null.
// Otherwise, the given tile entity may or may not be null.
// If the given tile entity is not null, its position and block data are expected to match the given block position and block data.
// In some situations, such as during chunk generation, the tile entity's world may be null, even if the given world is not null.
// If the tile entity's world is not null, it is expected to match the given world.
public abstract B createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity);
}
private static class BlockEntityStateFactory<T extends BlockEntity, B extends CraftBlockEntityState<T>> extends BlockStateFactory<B> {
private final BiFunction<World, T, B> blockStateConstructor;
private final BlockEntityType<? extends T> tileEntityConstructor; // Paper
protected BlockEntityStateFactory(Class<B> blockStateType, BiFunction<World, T, B> blockStateConstructor, BlockEntityType<? extends T> tileEntityConstructor) { // Paper
super(blockStateType);
this.blockStateConstructor = blockStateConstructor;
this.tileEntityConstructor = tileEntityConstructor;
}
@Override
public final B createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
if (world != null) {
Preconditions.checkState(tileEntity != null, "Tile is null, asynchronous access? %s", CraftBlock.at(((CraftWorld) world).getHandle(), blockPosition));
} else if (tileEntity == null) {
tileEntity = this.createTileEntity(blockPosition, blockData);
}
return this.createBlockState(world, (T) tileEntity);
}
private T createTileEntity(BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData) {
return this.tileEntityConstructor.create(blockPosition, blockData); // Paper
}
private B createBlockState(World world, T tileEntity) {
return this.blockStateConstructor.apply(world, tileEntity);
}
}
private static final Map<Material, BlockStateFactory<?>> FACTORIES = new HashMap<>();
private static final BlockStateFactory<?> DEFAULT_FACTORY = new BlockStateFactory<CraftBlockState>(CraftBlockState.class) {
@Override
public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
// Paper - revert upstream's revert of the block state changes. Block entities that have already had the block type set to AIR are still valid, upstream decided to ignore them
Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftBlockType.minecraftToBukkit(blockData.getBlock()));
return new CraftBlockState(world, blockPosition, blockData);
}
};
// Paper start
private static final Map<BlockEntityType<?>, BlockStateFactory<?>> FACTORIES_BY_BLOCK_ENTITY_TYPE = new HashMap<>();
private static void register(BlockEntityType<?> type, BlockStateFactory<?> factory) {
FACTORIES_BY_BLOCK_ENTITY_TYPE.put(type, factory);
}
// Paper end
static {
// Paper start - Generated/CraftBlockEntityStates
// @GeneratedFrom 1.21.3
register(BlockEntityType.BANNER, CraftBanner.class, CraftBanner::new);
register(BlockEntityType.BARREL, CraftBarrel.class, CraftBarrel::new);
register(BlockEntityType.BEACON, CraftBeacon.class, CraftBeacon::new);
register(BlockEntityType.BED, CraftBed.class, CraftBed::new);
register(BlockEntityType.BEEHIVE, CraftBeehive.class, CraftBeehive::new);
register(BlockEntityType.BELL, CraftBell.class, CraftBell::new);
register(BlockEntityType.BLAST_FURNACE, CraftBlastFurnace.class, CraftBlastFurnace::new);
register(BlockEntityType.BREWING_STAND, CraftBrewingStand.class, CraftBrewingStand::new);
register(BlockEntityType.BRUSHABLE_BLOCK, CraftBrushableBlock.class, CraftBrushableBlock::new);
register(BlockEntityType.CALIBRATED_SCULK_SENSOR, CraftCalibratedSculkSensor.class, CraftCalibratedSculkSensor::new);
register(BlockEntityType.CAMPFIRE, CraftCampfire.class, CraftCampfire::new);
register(BlockEntityType.CHEST, CraftChest.class, CraftChest::new);
register(BlockEntityType.CHISELED_BOOKSHELF, CraftChiseledBookshelf.class, CraftChiseledBookshelf::new);
register(BlockEntityType.COMMAND_BLOCK, CraftCommandBlock.class, CraftCommandBlock::new);
register(BlockEntityType.COMPARATOR, CraftComparator.class, CraftComparator::new);
register(BlockEntityType.CONDUIT, CraftConduit.class, CraftConduit::new);
register(BlockEntityType.CRAFTER, CraftCrafter.class, CraftCrafter::new);
register(BlockEntityType.CREAKING_HEART, CraftCreakingHeart.class, CraftCreakingHeart::new);
register(BlockEntityType.DAYLIGHT_DETECTOR, CraftDaylightDetector.class, CraftDaylightDetector::new);
register(BlockEntityType.DECORATED_POT, CraftDecoratedPot.class, CraftDecoratedPot::new);
register(BlockEntityType.DISPENSER, CraftDispenser.class, CraftDispenser::new);
register(BlockEntityType.DROPPER, CraftDropper.class, CraftDropper::new);
register(BlockEntityType.ENCHANTING_TABLE, CraftEnchantingTable.class, CraftEnchantingTable::new);
register(BlockEntityType.END_GATEWAY, CraftEndGateway.class, CraftEndGateway::new);
register(BlockEntityType.END_PORTAL, CraftEndPortal.class, CraftEndPortal::new);
register(BlockEntityType.ENDER_CHEST, CraftEnderChest.class, CraftEnderChest::new);
register(BlockEntityType.FURNACE, CraftFurnaceFurnace.class, CraftFurnaceFurnace::new);
register(BlockEntityType.HANGING_SIGN, CraftHangingSign.class, CraftHangingSign::new);
register(BlockEntityType.HOPPER, CraftHopper.class, CraftHopper::new);
register(BlockEntityType.JIGSAW, CraftJigsaw.class, CraftJigsaw::new);
register(BlockEntityType.JUKEBOX, CraftJukebox.class, CraftJukebox::new);
register(BlockEntityType.LECTERN, CraftLectern.class, CraftLectern::new);
register(BlockEntityType.MOB_SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new);
register(BlockEntityType.PISTON, CraftMovingPiston.class, CraftMovingPiston::new);
register(BlockEntityType.SCULK_CATALYST, CraftSculkCatalyst.class, CraftSculkCatalyst::new);
register(BlockEntityType.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new);
register(BlockEntityType.SCULK_SHRIEKER, CraftSculkShrieker.class, CraftSculkShrieker::new);
register(BlockEntityType.SHULKER_BOX, CraftShulkerBox.class, CraftShulkerBox::new);
register(BlockEntityType.SIGN, CraftSign.class, CraftSign::new);
register(BlockEntityType.SKULL, CraftSkull.class, CraftSkull::new);
register(BlockEntityType.SMOKER, CraftSmoker.class, CraftSmoker::new);
register(BlockEntityType.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new);
register(BlockEntityType.TRAPPED_CHEST, CraftChest.class, CraftChest::new);
register(BlockEntityType.TRIAL_SPAWNER, CraftTrialSpawner.class, CraftTrialSpawner::new);
register(BlockEntityType.VAULT, CraftVault.class, CraftVault::new);
// Paper end - Generated/CraftBlockEntityStates
}
private static void register(Material blockType, BlockStateFactory<?> factory) {
CraftBlockStates.FACTORIES.put(blockType, factory);
}
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
net.minecraft.world.level.block.entity.BlockEntityType<? extends T> blockEntityType, // Paper
Class<B> blockStateType,
BiFunction<World, T, B> blockStateConstructor // Paper
) {
// Paper start
BlockStateFactory<B> factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, blockEntityType); // Paper
for (net.minecraft.world.level.block.Block block : blockEntityType.validBlocks) {
CraftBlockStates.register(CraftBlockType.minecraftToBukkit(block), factory);
}
CraftBlockStates.register(blockEntityType, factory);
// Paper end
}
private static BlockStateFactory<?> getFactory(Material material) {
return CraftBlockStates.FACTORIES.getOrDefault(material, CraftBlockStates.DEFAULT_FACTORY);
}
// Paper start
private static BlockStateFactory<?> getFactory(Material material, BlockEntityType<?> type) {
if (type != null) {
return CraftBlockStates.FACTORIES_BY_BLOCK_ENTITY_TYPE.getOrDefault(type, getFactory(material));
} else {
return getFactory(material);
}
}
// Paper end
public static Class<? extends CraftBlockState> getBlockStateType(Material material) {
Preconditions.checkNotNull(material, "material is null");
return CraftBlockStates.getFactory(material).blockStateType;
}
public static BlockEntity createNewTileEntity(Material material) {
BlockStateFactory<?> factory = CraftBlockStates.getFactory(material);
if (factory instanceof BlockEntityStateFactory) {
return ((BlockEntityStateFactory<?, ?>) factory).createTileEntity(BlockPos.ZERO, CraftBlockType.bukkitToMinecraft(material).defaultBlockState());
}
return null;
}
// Paper start
public static Class<? extends CraftBlockState> getBlockStateType(BlockEntityType<?> blockEntityType) {
Preconditions.checkNotNull(blockEntityType, "blockEntityType is null");
return CraftBlockStates.getFactory(null, blockEntityType).blockStateType;
}
// Paper end
public static BlockState getBlockState(Block block) {
// Paper start
return CraftBlockStates.getBlockState(block, true);
}
public static BlockState getBlockState(Block block, boolean useSnapshot) {
// Paper end
Preconditions.checkNotNull(block, "block is null");
CraftBlock craftBlock = (CraftBlock) block;
CraftWorld world = (CraftWorld) block.getWorld();
BlockPos blockPosition = craftBlock.getPosition();
net.minecraft.world.level.block.state.BlockState blockData = craftBlock.getNMS();
BlockEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition);
// Paper start - block state snapshots
boolean prev = CraftBlockEntityState.DISABLE_SNAPSHOT;
CraftBlockEntityState.DISABLE_SNAPSHOT = !useSnapshot;
try {
// Paper end
CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockPosition, blockData, tileEntity);
blockState.setWorldHandle(craftBlock.getHandle()); // Inject the block's generator access
return blockState;
// Paper start
} finally {
CraftBlockEntityState.DISABLE_SNAPSHOT = prev;
}
// Paper end
}
@Deprecated
public static BlockState getBlockState(BlockPos blockPosition, Material material, @Nullable CompoundTag blockEntityTag) {
return CraftBlockStates.getBlockState(MinecraftServer.getDefaultRegistryAccess(), blockPosition, material, blockEntityTag);
}
public static BlockState getBlockState(LevelReader world, BlockPos blockPosition, Material material, @Nullable CompoundTag blockEntityTag) {
return CraftBlockStates.getBlockState(world.registryAccess(), blockPosition, material, blockEntityTag);
}
public static BlockState getBlockState(RegistryAccess registry, BlockPos blockPosition, Material material, @Nullable CompoundTag blockEntityTag) {
Preconditions.checkNotNull(material, "material is null");
net.minecraft.world.level.block.state.BlockState blockData = CraftBlockType.bukkitToMinecraft(material).defaultBlockState();
return CraftBlockStates.getBlockState(registry, blockPosition, blockData, blockEntityTag);
}
@Deprecated
public static BlockState getBlockState(net.minecraft.world.level.block.state.BlockState blockData, @Nullable CompoundTag blockEntityTag) {
return CraftBlockStates.getBlockState(MinecraftServer.getDefaultRegistryAccess(), BlockPos.ZERO, blockData, blockEntityTag);
}
public static BlockState getBlockState(LevelReader world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, @Nullable CompoundTag blockEntityTag) {
return CraftBlockStates.getBlockState(world.registryAccess(), blockPosition, blockData, blockEntityTag);
}
public static BlockState getBlockState(RegistryAccess registry, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, @Nullable CompoundTag blockEntityTag) {
Preconditions.checkNotNull(blockPosition, "blockPosition is null");
Preconditions.checkNotNull(blockData, "blockData is null");
BlockEntity tileEntity = (blockEntityTag == null) ? null : BlockEntity.loadStatic(blockPosition, blockData, blockEntityTag, registry);
return CraftBlockStates.getBlockState(null, blockPosition, blockData, tileEntity);
}
// See BlockStateFactory#createBlockState(World, BlockPosition, IBlockData, TileEntity)
public static CraftBlockState getBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
Material material = CraftBlockType.minecraftToBukkit(blockData.getBlock());
BlockStateFactory<?> factory;
// For some types of TileEntity blocks (eg. moving pistons), Minecraft may in some situations (eg. when using Block#setType or the
// setBlock command) not create a corresponding TileEntity in the world. We return a normal BlockState in this case.
if (world != null && tileEntity == null && CraftBlockStates.isTileEntityOptional(material)) {
factory = CraftBlockStates.DEFAULT_FACTORY;
} else {
factory = CraftBlockStates.getFactory(material, tileEntity != null ? tileEntity.getType() : null); // Paper
}
return factory.createBlockState(world, blockPosition, blockData, tileEntity);
}
public static boolean isTileEntityOptional(Material material) {
return material == Material.MOVING_PISTON;
}
// This ignores tile entity data.
public static CraftBlockState getBlockState(LevelAccessor world, BlockPos pos) {
return new CraftBlockState(CraftBlock.at(world, pos));
}
// This ignores tile entity data.
public static CraftBlockState getBlockState(LevelAccessor world, BlockPos pos, int flag) {
return new CraftBlockState(CraftBlock.at(world, pos), flag);
}
// Paper start
@Nullable
public static BlockEntityType<?> getBlockEntityType(final Material material) {
final BlockStateFactory<?> factory = org.bukkit.craftbukkit.block.CraftBlockStates.FACTORIES.get(material);
return factory instanceof final BlockEntityStateFactory<?,?> blockEntityStateFactory ? blockEntityStateFactory.tileEntityConstructor : null;
}
// Paper end
private CraftBlockStates() {
}
}

View File

@ -0,0 +1,790 @@
package org.bukkit.craftbukkit.block.data;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.commands.arguments.blocks.BlockStateParser;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.Property;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SoundGroup;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.BlockSupport;
import org.bukkit.block.BlockType;
import org.bukkit.block.PistonMoveReaction;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.structure.Mirror;
import org.bukkit.block.structure.StructureRotation;
import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.CraftSoundGroup;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.block.CraftBlockStates;
import org.bukkit.craftbukkit.block.CraftBlockSupport;
import org.bukkit.craftbukkit.block.CraftBlockType;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.inventory.CraftItemType;
import org.bukkit.craftbukkit.util.CraftLocation;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class CraftBlockData implements BlockData {
private net.minecraft.world.level.block.state.BlockState state;
private Map<Property<?>, Comparable<?>> parsedStates;
protected CraftBlockData() {
throw new AssertionError("Template Constructor");
}
protected CraftBlockData(net.minecraft.world.level.block.state.BlockState state) {
this.state = state;
}
@Override
public Material getMaterial() {
return this.state.getBukkitMaterial(); // Paper - optimise getType calls
}
public net.minecraft.world.level.block.state.BlockState getState() {
return this.state;
}
/**
* Get a given BlockStateEnum's value as its Bukkit counterpart.
*
* @param nms the NMS state to convert
* @param bukkit the Bukkit class
* @param <B> the type
* @return the matching Bukkit type
*/
protected <B extends Enum<B>> B get(EnumProperty<?> nms, Class<B> bukkit) {
return CraftBlockData.toBukkit(this.state.getValue(nms), bukkit);
}
/**
* Convert all values from the given BlockStateEnum to their appropriate
* Bukkit counterpart.
*
* @param nms the NMS state to get values from
* @param bukkit the bukkit class to convert the values to
* @param <B> the bukkit class type
* @return an immutable Set of values in their appropriate Bukkit type
*/
@SuppressWarnings("unchecked")
protected <B extends Enum<B>> Set<B> getValues(EnumProperty<?> nms, Class<B> bukkit) {
ImmutableSet.Builder<B> values = ImmutableSet.builder();
for (Enum<?> e : nms.getPossibleValues()) {
values.add(CraftBlockData.toBukkit(e, bukkit));
}
return values.build();
}
/**
* Set a given {@link EnumProperty} with the matching enum from Bukkit.
*
* @param nms the NMS BlockStateEnum to set
* @param bukkit the matching Bukkit Enum
* @param <B> the Bukkit type
* @param <N> the NMS type
*/
protected <B extends Enum<B>, N extends Enum<N> & StringRepresentable> void set(EnumProperty<N> nms, Enum<B> bukkit) {
this.parsedStates = null;
this.state = this.state.setValue(nms, CraftBlockData.toNMS(bukkit, nms.getValueClass()));
}
@Override
public BlockData merge(BlockData data) {
CraftBlockData craft = (CraftBlockData) data;
Preconditions.checkArgument(craft.parsedStates != null, "Data not created via string parsing");
Preconditions.checkArgument(this.state.getBlock() == craft.state.getBlock(), "States have different types (got %s, expected %s)", data, this);
CraftBlockData clone = (CraftBlockData) this.clone();
clone.parsedStates = null;
for (Property parsed : craft.parsedStates.keySet()) {
clone.state = clone.state.setValue(parsed, craft.state.getValue(parsed));
}
return clone;
}
@Override
public boolean matches(BlockData data) {
if (data == null) {
return false;
}
if (!(data instanceof CraftBlockData)) {
return false;
}
CraftBlockData craft = (CraftBlockData) data;
if (this.state.getBlock() != craft.state.getBlock()) {
return false;
}
// Fastpath an exact match
boolean exactMatch = this.equals(data);
// If that failed, do a merge and check
if (!exactMatch && craft.parsedStates != null) {
return this.merge(data).equals(this);
}
return exactMatch;
}
private static final Map<Class<? extends Enum<?>>, Enum<?>[]> ENUM_VALUES = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - cache block data strings; make thread safe
/**
* Convert an NMS Enum (usually a BlockStateEnum) to its appropriate Bukkit
* enum from the given class.
*
* @throws IllegalStateException if the Enum could not be converted
*/
@SuppressWarnings("unchecked")
private static <B extends Enum<B>> B toBukkit(Enum<?> nms, Class<B> bukkit) {
if (nms instanceof Direction) {
return (B) CraftBlock.notchToBlockFace((Direction) nms);
}
return (B) CraftBlockData.ENUM_VALUES.computeIfAbsent(bukkit, Class::getEnumConstants)[nms.ordinal()];
}
/**
* Convert a given Bukkit enum to its matching NMS enum type.
*
* @param bukkit the Bukkit enum to convert
* @param nms the NMS class
* @return the matching NMS type
* @throws IllegalStateException if the Enum could not be converted
*/
@SuppressWarnings("unchecked")
public static <N extends Enum<N> & StringRepresentable> N toNMS(Enum<?> bukkit, Class<N> nms) {
if (bukkit instanceof BlockFace) {
return (N) CraftBlock.blockFaceToNotch((BlockFace) bukkit);
}
return (N) CraftBlockData.ENUM_VALUES.computeIfAbsent(nms, Class::getEnumConstants)[bukkit.ordinal()];
}
/**
* Get the current value of a given state.
*
* @param ibs the state to check
* @param <T> the type
* @return the current value of the given state
*/
protected <T extends Comparable<T>> T get(Property<T> ibs) {
// Straight integer or boolean getter
return this.state.getValue(ibs);
}
/**
* Set the specified state's value.
*
* @param ibs the state to set
* @param v the new value
* @param <T> the state's type
* @param <V> the value's type. Must match the state's type.
*/
public <T extends Comparable<T>, V extends T> void set(Property<T> ibs, V v) {
// Straight integer or boolean setter
this.parsedStates = null;
this.state = this.state.setValue(ibs, v);
}
@Override
public String getAsString() {
return this.toString(this.state.getValues());
}
@Override
public String getAsString(boolean hideUnspecified) {
return (hideUnspecified && this.parsedStates != null) ? this.toString(this.parsedStates) : this.getAsString();
}
@Override
public BlockData clone() {
try {
return (BlockData) super.clone();
} catch (CloneNotSupportedException ex) {
throw new AssertionError("Clone not supported", ex);
}
}
@Override
public String toString() {
return "CraftBlockData{" + this.getAsString() + "}";
}
// Mimicked from BlockDataAbstract#toString()
public String toString(Map<Property<?>, Comparable<?>> states) {
StringBuilder stateString = new StringBuilder(BuiltInRegistries.BLOCK.getKey(this.state.getBlock()).toString());
if (!states.isEmpty()) {
stateString.append('[');
stateString.append(states.entrySet().stream().map(StateHolder.PROPERTY_ENTRY_TO_STRING_FUNCTION).collect(Collectors.joining(",")));
stateString.append(']');
}
return stateString.toString();
}
public Map<String, String> toStates() {
Map<String, String> compound = new HashMap<>();
for (Map.Entry<Property<?>, Comparable<?>> entry : this.state.getValues().entrySet()) {
Property iblockstate = (Property) entry.getKey();
compound.put(iblockstate.getName(), iblockstate.getName(entry.getValue()));
}
return compound;
}
@Override
public boolean equals(Object obj) {
return obj instanceof CraftBlockData && this.state.equals(((CraftBlockData) obj).state);
}
@Override
public int hashCode() {
return this.state.hashCode();
}
protected static BooleanProperty getBoolean(String name) {
throw new AssertionError("Template Method");
}
protected static BooleanProperty getBoolean(String name, boolean optional) {
throw new AssertionError("Template Method");
}
protected static EnumProperty<?> getEnum(String name) {
throw new AssertionError("Template Method");
}
protected static IntegerProperty getInteger(String name) {
throw new AssertionError("Template Method");
}
protected static BooleanProperty getBoolean(Class<? extends Block> block, String name) {
return (BooleanProperty) CraftBlockData.getState(block, name, false);
}
protected static BooleanProperty getBoolean(Class<? extends Block> block, String name, boolean optional) {
return (BooleanProperty) CraftBlockData.getState(block, name, optional);
}
protected static EnumProperty<?> getEnum(Class<? extends Block> block, String name) {
return (EnumProperty<?>) CraftBlockData.getState(block, name, false);
}
protected static IntegerProperty getInteger(Class<? extends Block> block, String name) {
return (IntegerProperty) CraftBlockData.getState(block, name, false);
}
/**
* Get a specified {@link Property} from a given block's class with a
* given name
*
* @param block the class to retrieve the state from
* @param name the name of the state to retrieve
* @param optional if the state can be null
* @return the specified state or null
* @throws IllegalStateException if the state is null and {@code optional}
* is false.
*/
private static Property<?> getState(Class<? extends Block> block, String name, boolean optional) {
Property<?> state = null;
for (Block instance : BuiltInRegistries.BLOCK) {
if (instance.getClass() == block) {
if (state == null) {
state = instance.getStateDefinition().getProperty(name);
} else {
Property<?> newState = instance.getStateDefinition().getProperty(name);
Preconditions.checkState(state == newState, "State mistmatch %s,%s", state, newState);
}
}
}
Preconditions.checkState(optional || state != null, "Null state for %s,%s", block, name);
return state;
}
/**
* Get the minimum value allowed by the BlockStateInteger.
*
* @param state the state to check
* @return the minimum value allowed
*/
protected static int getMin(IntegerProperty state) {
return state.min;
}
/**
* Get the maximum value allowed by the BlockStateInteger.
*
* @param state the state to check
* @return the maximum value allowed
*/
protected static int getMax(IntegerProperty state) {
return state.max;
}
public static final BlockFace[] ROTATION_CYCLE = {
BlockFace.SOUTH, BlockFace.SOUTH_SOUTH_WEST, BlockFace.SOUTH_WEST, BlockFace.WEST_SOUTH_WEST,
BlockFace.WEST, BlockFace.WEST_NORTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_NORTH_WEST,
BlockFace.NORTH, BlockFace.NORTH_NORTH_EAST, BlockFace.NORTH_EAST, BlockFace.EAST_NORTH_EAST,
BlockFace.EAST, BlockFace.EAST_SOUTH_EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH_SOUTH_EAST
};
//
private static final Map<Class<? extends Block>, Function<net.minecraft.world.level.block.state.BlockState, CraftBlockData>> MAP = new HashMap<>();
static {
//<editor-fold desc="CraftBlockData Registration" defaultstate="collapsed">
// Paper start - Generated/CraftBlockData#MAP
// @GeneratedFrom 1.21.3
register(net.minecraft.world.level.block.AmethystClusterBlock.class, org.bukkit.craftbukkit.block.impl.CraftAmethystCluster::new);
register(net.minecraft.world.level.block.AnvilBlock.class, org.bukkit.craftbukkit.block.impl.CraftAnvil::new);
register(net.minecraft.world.level.block.AttachedStemBlock.class, org.bukkit.craftbukkit.block.impl.CraftAttachedStem::new);
register(net.minecraft.world.level.block.BambooStalkBlock.class, org.bukkit.craftbukkit.block.impl.CraftBambooStalk::new);
register(net.minecraft.world.level.block.BannerBlock.class, org.bukkit.craftbukkit.block.impl.CraftBanner::new);
register(net.minecraft.world.level.block.BarrelBlock.class, org.bukkit.craftbukkit.block.impl.CraftBarrel::new);
register(net.minecraft.world.level.block.BarrierBlock.class, org.bukkit.craftbukkit.block.impl.CraftBarrier::new);
register(net.minecraft.world.level.block.BaseCoralFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftBaseCoralFan::new);
register(net.minecraft.world.level.block.BaseCoralPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftBaseCoralPlant::new);
register(net.minecraft.world.level.block.BaseCoralWallFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftBaseCoralWallFan::new);
register(net.minecraft.world.level.block.BedBlock.class, org.bukkit.craftbukkit.block.impl.CraftBed::new);
register(net.minecraft.world.level.block.BeehiveBlock.class, org.bukkit.craftbukkit.block.impl.CraftBeehive::new);
register(net.minecraft.world.level.block.BeetrootBlock.class, org.bukkit.craftbukkit.block.impl.CraftBeetroot::new);
register(net.minecraft.world.level.block.BellBlock.class, org.bukkit.craftbukkit.block.impl.CraftBell::new);
register(net.minecraft.world.level.block.BigDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleaf::new);
register(net.minecraft.world.level.block.BigDripleafStemBlock.class, org.bukkit.craftbukkit.block.impl.CraftBigDripleafStem::new);
register(net.minecraft.world.level.block.BlastFurnaceBlock.class, org.bukkit.craftbukkit.block.impl.CraftBlastFurnace::new);
register(net.minecraft.world.level.block.BrewingStandBlock.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand::new);
register(net.minecraft.world.level.block.BrushableBlock.class, org.bukkit.craftbukkit.block.impl.CraftBrushable::new);
register(net.minecraft.world.level.block.BubbleColumnBlock.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn::new);
register(net.minecraft.world.level.block.ButtonBlock.class, org.bukkit.craftbukkit.block.impl.CraftButton::new);
register(net.minecraft.world.level.block.CactusBlock.class, org.bukkit.craftbukkit.block.impl.CraftCactus::new);
register(net.minecraft.world.level.block.CakeBlock.class, org.bukkit.craftbukkit.block.impl.CraftCake::new);
register(net.minecraft.world.level.block.CalibratedSculkSensorBlock.class, org.bukkit.craftbukkit.block.impl.CraftCalibratedSculkSensor::new);
register(net.minecraft.world.level.block.CampfireBlock.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new);
register(net.minecraft.world.level.block.CandleBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandle::new);
register(net.minecraft.world.level.block.CandleCakeBlock.class, org.bukkit.craftbukkit.block.impl.CraftCandleCake::new);
register(net.minecraft.world.level.block.CarrotBlock.class, org.bukkit.craftbukkit.block.impl.CraftCarrot::new);
register(net.minecraft.world.level.block.CarvedPumpkinBlock.class, org.bukkit.craftbukkit.block.impl.CraftCarvedPumpkin::new);
register(net.minecraft.world.level.block.CaveVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVines::new);
register(net.minecraft.world.level.block.CaveVinesPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCaveVinesPlant::new);
register(net.minecraft.world.level.block.CeilingHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftCeilingHangingSign::new);
register(net.minecraft.world.level.block.ChainBlock.class, org.bukkit.craftbukkit.block.impl.CraftChain::new);
register(net.minecraft.world.level.block.CherryLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftCherryLeaves::new);
register(net.minecraft.world.level.block.ChestBlock.class, org.bukkit.craftbukkit.block.impl.CraftChest::new);
register(net.minecraft.world.level.block.ChiseledBookShelfBlock.class, org.bukkit.craftbukkit.block.impl.CraftChiseledBookShelf::new);
register(net.minecraft.world.level.block.ChorusFlowerBlock.class, org.bukkit.craftbukkit.block.impl.CraftChorusFlower::new);
register(net.minecraft.world.level.block.ChorusPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftChorusPlant::new);
register(net.minecraft.world.level.block.CocoaBlock.class, org.bukkit.craftbukkit.block.impl.CraftCocoa::new);
register(net.minecraft.world.level.block.CommandBlock.class, org.bukkit.craftbukkit.block.impl.CraftCommandBlock::new);
register(net.minecraft.world.level.block.ComparatorBlock.class, org.bukkit.craftbukkit.block.impl.CraftComparator::new);
register(net.minecraft.world.level.block.ComposterBlock.class, org.bukkit.craftbukkit.block.impl.CraftComposter::new);
register(net.minecraft.world.level.block.ConduitBlock.class, org.bukkit.craftbukkit.block.impl.CraftConduit::new);
register(net.minecraft.world.level.block.CopperBulbBlock.class, org.bukkit.craftbukkit.block.impl.CraftCopperBulb::new);
register(net.minecraft.world.level.block.CoralFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralFan::new);
register(net.minecraft.world.level.block.CoralPlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralPlant::new);
register(net.minecraft.world.level.block.CoralWallFanBlock.class, org.bukkit.craftbukkit.block.impl.CraftCoralWallFan::new);
register(net.minecraft.world.level.block.CrafterBlock.class, org.bukkit.craftbukkit.block.impl.CraftCrafter::new);
register(net.minecraft.world.level.block.CreakingHeartBlock.class, org.bukkit.craftbukkit.block.impl.CraftCreakingHeart::new);
register(net.minecraft.world.level.block.CropBlock.class, org.bukkit.craftbukkit.block.impl.CraftCrop::new);
register(net.minecraft.world.level.block.DaylightDetectorBlock.class, org.bukkit.craftbukkit.block.impl.CraftDaylightDetector::new);
register(net.minecraft.world.level.block.DecoratedPotBlock.class, org.bukkit.craftbukkit.block.impl.CraftDecoratedPot::new);
register(net.minecraft.world.level.block.DetectorRailBlock.class, org.bukkit.craftbukkit.block.impl.CraftDetectorRail::new);
register(net.minecraft.world.level.block.DispenserBlock.class, org.bukkit.craftbukkit.block.impl.CraftDispenser::new);
register(net.minecraft.world.level.block.DoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftDoor::new);
register(net.minecraft.world.level.block.DoublePlantBlock.class, org.bukkit.craftbukkit.block.impl.CraftDoublePlant::new);
register(net.minecraft.world.level.block.DropperBlock.class, org.bukkit.craftbukkit.block.impl.CraftDropper::new);
register(net.minecraft.world.level.block.EndPortalFrameBlock.class, org.bukkit.craftbukkit.block.impl.CraftEndPortalFrame::new);
register(net.minecraft.world.level.block.EndRodBlock.class, org.bukkit.craftbukkit.block.impl.CraftEndRod::new);
register(net.minecraft.world.level.block.EnderChestBlock.class, org.bukkit.craftbukkit.block.impl.CraftEnderChest::new);
register(net.minecraft.world.level.block.FarmBlock.class, org.bukkit.craftbukkit.block.impl.CraftFarm::new);
register(net.minecraft.world.level.block.FenceBlock.class, org.bukkit.craftbukkit.block.impl.CraftFence::new);
register(net.minecraft.world.level.block.FenceGateBlock.class, org.bukkit.craftbukkit.block.impl.CraftFenceGate::new);
register(net.minecraft.world.level.block.FireBlock.class, org.bukkit.craftbukkit.block.impl.CraftFire::new);
register(net.minecraft.world.level.block.FrostedIceBlock.class, org.bukkit.craftbukkit.block.impl.CraftFrostedIce::new);
register(net.minecraft.world.level.block.FurnaceBlock.class, org.bukkit.craftbukkit.block.impl.CraftFurnace::new);
register(net.minecraft.world.level.block.GlazedTerracottaBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlazedTerracotta::new);
register(net.minecraft.world.level.block.GlowLichenBlock.class, org.bukkit.craftbukkit.block.impl.CraftGlowLichen::new);
register(net.minecraft.world.level.block.GrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftGrass::new);
register(net.minecraft.world.level.block.GrindstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftGrindstone::new);
register(net.minecraft.world.level.block.HangingMossBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingMoss::new);
register(net.minecraft.world.level.block.HangingRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftHangingRoots::new);
register(net.minecraft.world.level.block.HayBlock.class, org.bukkit.craftbukkit.block.impl.CraftHay::new);
register(net.minecraft.world.level.block.HeavyCoreBlock.class, org.bukkit.craftbukkit.block.impl.CraftHeavyCore::new);
register(net.minecraft.world.level.block.HopperBlock.class, org.bukkit.craftbukkit.block.impl.CraftHopper::new);
register(net.minecraft.world.level.block.HugeMushroomBlock.class, org.bukkit.craftbukkit.block.impl.CraftHugeMushroom::new);
register(net.minecraft.world.level.block.InfestedRotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftInfestedRotatedPillar::new);
register(net.minecraft.world.level.block.IronBarsBlock.class, org.bukkit.craftbukkit.block.impl.CraftIronBars::new);
register(net.minecraft.world.level.block.JigsawBlock.class, org.bukkit.craftbukkit.block.impl.CraftJigsaw::new);
register(net.minecraft.world.level.block.JukeboxBlock.class, org.bukkit.craftbukkit.block.impl.CraftJukebox::new);
register(net.minecraft.world.level.block.KelpBlock.class, org.bukkit.craftbukkit.block.impl.CraftKelp::new);
register(net.minecraft.world.level.block.LadderBlock.class, org.bukkit.craftbukkit.block.impl.CraftLadder::new);
register(net.minecraft.world.level.block.LanternBlock.class, org.bukkit.craftbukkit.block.impl.CraftLantern::new);
register(net.minecraft.world.level.block.LayeredCauldronBlock.class, org.bukkit.craftbukkit.block.impl.CraftLayeredCauldron::new);
register(net.minecraft.world.level.block.LeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftLeaves::new);
register(net.minecraft.world.level.block.LecternBlock.class, org.bukkit.craftbukkit.block.impl.CraftLectern::new);
register(net.minecraft.world.level.block.LeverBlock.class, org.bukkit.craftbukkit.block.impl.CraftLever::new);
register(net.minecraft.world.level.block.LightBlock.class, org.bukkit.craftbukkit.block.impl.CraftLight::new);
register(net.minecraft.world.level.block.LightningRodBlock.class, org.bukkit.craftbukkit.block.impl.CraftLightningRod::new);
register(net.minecraft.world.level.block.LiquidBlock.class, org.bukkit.craftbukkit.block.impl.CraftLiquid::new);
register(net.minecraft.world.level.block.LoomBlock.class, org.bukkit.craftbukkit.block.impl.CraftLoom::new);
register(net.minecraft.world.level.block.MangroveLeavesBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveLeaves::new);
register(net.minecraft.world.level.block.MangrovePropaguleBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangrovePropagule::new);
register(net.minecraft.world.level.block.MangroveRootsBlock.class, org.bukkit.craftbukkit.block.impl.CraftMangroveRoots::new);
register(net.minecraft.world.level.block.MossyCarpetBlock.class, org.bukkit.craftbukkit.block.impl.CraftMossyCarpet::new);
register(net.minecraft.world.level.block.MyceliumBlock.class, org.bukkit.craftbukkit.block.impl.CraftMycelium::new);
register(net.minecraft.world.level.block.NetherPortalBlock.class, org.bukkit.craftbukkit.block.impl.CraftNetherPortal::new);
register(net.minecraft.world.level.block.NetherWartBlock.class, org.bukkit.craftbukkit.block.impl.CraftNetherWart::new);
register(net.minecraft.world.level.block.NoteBlock.class, org.bukkit.craftbukkit.block.impl.CraftNoteBlock::new);
register(net.minecraft.world.level.block.ObserverBlock.class, org.bukkit.craftbukkit.block.impl.CraftObserver::new);
register(net.minecraft.world.level.block.PiglinWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftPiglinWallSkull::new);
register(net.minecraft.world.level.block.PinkPetalsBlock.class, org.bukkit.craftbukkit.block.impl.CraftPinkPetals::new);
register(net.minecraft.world.level.block.PitcherCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftPitcherCrop::new);
register(net.minecraft.world.level.block.PlayerHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftPlayerHead::new);
register(net.minecraft.world.level.block.PlayerWallHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftPlayerWallHead::new);
register(net.minecraft.world.level.block.PointedDripstoneBlock.class, org.bukkit.craftbukkit.block.impl.CraftPointedDripstone::new);
register(net.minecraft.world.level.block.PotatoBlock.class, org.bukkit.craftbukkit.block.impl.CraftPotato::new);
register(net.minecraft.world.level.block.PoweredRailBlock.class, org.bukkit.craftbukkit.block.impl.CraftPoweredRail::new);
register(net.minecraft.world.level.block.PressurePlateBlock.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlate::new);
register(net.minecraft.world.level.block.RailBlock.class, org.bukkit.craftbukkit.block.impl.CraftRail::new);
register(net.minecraft.world.level.block.RedStoneOreBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedStoneOre::new);
register(net.minecraft.world.level.block.RedStoneWireBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedStoneWire::new);
register(net.minecraft.world.level.block.RedstoneLampBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneLamp::new);
register(net.minecraft.world.level.block.RedstoneTorchBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorch::new);
register(net.minecraft.world.level.block.RedstoneWallTorchBlock.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneWallTorch::new);
register(net.minecraft.world.level.block.RepeaterBlock.class, org.bukkit.craftbukkit.block.impl.CraftRepeater::new);
register(net.minecraft.world.level.block.RespawnAnchorBlock.class, org.bukkit.craftbukkit.block.impl.CraftRespawnAnchor::new);
register(net.minecraft.world.level.block.RotatedPillarBlock.class, org.bukkit.craftbukkit.block.impl.CraftRotatedPillar::new);
register(net.minecraft.world.level.block.SaplingBlock.class, org.bukkit.craftbukkit.block.impl.CraftSapling::new);
register(net.minecraft.world.level.block.ScaffoldingBlock.class, org.bukkit.craftbukkit.block.impl.CraftScaffolding::new);
register(net.minecraft.world.level.block.SculkCatalystBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkCatalyst::new);
register(net.minecraft.world.level.block.SculkSensorBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkSensor::new);
register(net.minecraft.world.level.block.SculkShriekerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkShrieker::new);
register(net.minecraft.world.level.block.SculkVeinBlock.class, org.bukkit.craftbukkit.block.impl.CraftSculkVein::new);
register(net.minecraft.world.level.block.SeaPickleBlock.class, org.bukkit.craftbukkit.block.impl.CraftSeaPickle::new);
register(net.minecraft.world.level.block.ShulkerBoxBlock.class, org.bukkit.craftbukkit.block.impl.CraftShulkerBox::new);
register(net.minecraft.world.level.block.SkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftSkull::new);
register(net.minecraft.world.level.block.SlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftSlab::new);
register(net.minecraft.world.level.block.SmallDripleafBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmallDripleaf::new);
register(net.minecraft.world.level.block.SmokerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSmoker::new);
register(net.minecraft.world.level.block.SnifferEggBlock.class, org.bukkit.craftbukkit.block.impl.CraftSnifferEgg::new);
register(net.minecraft.world.level.block.SnowLayerBlock.class, org.bukkit.craftbukkit.block.impl.CraftSnowLayer::new);
register(net.minecraft.world.level.block.SnowyDirtBlock.class, org.bukkit.craftbukkit.block.impl.CraftSnowyDirt::new);
register(net.minecraft.world.level.block.StainedGlassPaneBlock.class, org.bukkit.craftbukkit.block.impl.CraftStainedGlassPane::new);
register(net.minecraft.world.level.block.StairBlock.class, org.bukkit.craftbukkit.block.impl.CraftStair::new);
register(net.minecraft.world.level.block.StandingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftStandingSign::new);
register(net.minecraft.world.level.block.StemBlock.class, org.bukkit.craftbukkit.block.impl.CraftStem::new);
register(net.minecraft.world.level.block.StonecutterBlock.class, org.bukkit.craftbukkit.block.impl.CraftStonecutter::new);
register(net.minecraft.world.level.block.StructureBlock.class, org.bukkit.craftbukkit.block.impl.CraftStructureBlock::new);
register(net.minecraft.world.level.block.SugarCaneBlock.class, org.bukkit.craftbukkit.block.impl.CraftSugarCane::new);
register(net.minecraft.world.level.block.SweetBerryBushBlock.class, org.bukkit.craftbukkit.block.impl.CraftSweetBerryBush::new);
register(net.minecraft.world.level.block.TallFlowerBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallFlower::new);
register(net.minecraft.world.level.block.TallSeagrassBlock.class, org.bukkit.craftbukkit.block.impl.CraftTallSeagrass::new);
register(net.minecraft.world.level.block.TargetBlock.class, org.bukkit.craftbukkit.block.impl.CraftTarget::new);
register(net.minecraft.world.level.block.TntBlock.class, org.bukkit.craftbukkit.block.impl.CraftTnt::new);
register(net.minecraft.world.level.block.TorchflowerCropBlock.class, org.bukkit.craftbukkit.block.impl.CraftTorchflowerCrop::new);
register(net.minecraft.world.level.block.TrapDoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftTrapDoor::new);
register(net.minecraft.world.level.block.TrappedChestBlock.class, org.bukkit.craftbukkit.block.impl.CraftTrappedChest::new);
register(net.minecraft.world.level.block.TrialSpawnerBlock.class, org.bukkit.craftbukkit.block.impl.CraftTrialSpawner::new);
register(net.minecraft.world.level.block.TripWireBlock.class, org.bukkit.craftbukkit.block.impl.CraftTripWire::new);
register(net.minecraft.world.level.block.TripWireHookBlock.class, org.bukkit.craftbukkit.block.impl.CraftTripWireHook::new);
register(net.minecraft.world.level.block.TurtleEggBlock.class, org.bukkit.craftbukkit.block.impl.CraftTurtleEgg::new);
register(net.minecraft.world.level.block.TwistingVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftTwistingVines::new);
register(net.minecraft.world.level.block.VaultBlock.class, org.bukkit.craftbukkit.block.impl.CraftVault::new);
register(net.minecraft.world.level.block.VineBlock.class, org.bukkit.craftbukkit.block.impl.CraftVine::new);
register(net.minecraft.world.level.block.WallBannerBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallBanner::new);
register(net.minecraft.world.level.block.WallBlock.class, org.bukkit.craftbukkit.block.impl.CraftWall::new);
register(net.minecraft.world.level.block.WallHangingSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallHangingSign::new);
register(net.minecraft.world.level.block.WallSignBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallSign::new);
register(net.minecraft.world.level.block.WallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallSkull::new);
register(net.minecraft.world.level.block.WallTorchBlock.class, org.bukkit.craftbukkit.block.impl.CraftWallTorch::new);
register(net.minecraft.world.level.block.WaterloggedTransparentBlock.class, org.bukkit.craftbukkit.block.impl.CraftWaterloggedTransparent::new);
register(net.minecraft.world.level.block.WeatheringCopperBulbBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperBulb::new);
register(net.minecraft.world.level.block.WeatheringCopperDoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperDoor::new);
register(net.minecraft.world.level.block.WeatheringCopperGrateBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperGrate::new);
register(net.minecraft.world.level.block.WeatheringCopperSlabBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperSlab::new);
register(net.minecraft.world.level.block.WeatheringCopperStairBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperStair::new);
register(net.minecraft.world.level.block.WeatheringCopperTrapDoorBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeatheringCopperTrapDoor::new);
register(net.minecraft.world.level.block.WeepingVinesBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeepingVines::new);
register(net.minecraft.world.level.block.WeightedPressurePlateBlock.class, org.bukkit.craftbukkit.block.impl.CraftWeightedPressurePlate::new);
register(net.minecraft.world.level.block.WitherSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull::new);
register(net.minecraft.world.level.block.WitherWallSkullBlock.class, org.bukkit.craftbukkit.block.impl.CraftWitherWallSkull::new);
register(net.minecraft.world.level.block.piston.MovingPistonBlock.class, org.bukkit.craftbukkit.block.impl.CraftMovingPiston::new);
register(net.minecraft.world.level.block.piston.PistonBaseBlock.class, org.bukkit.craftbukkit.block.impl.CraftPistonBase::new);
register(net.minecraft.world.level.block.piston.PistonHeadBlock.class, org.bukkit.craftbukkit.block.impl.CraftPistonHead::new);
// Paper end - Generated/CraftBlockData#MAP
//</editor-fold>
}
private static void register(Class<? extends Block> nms, Function<net.minecraft.world.level.block.state.BlockState, CraftBlockData> bukkit) {
Preconditions.checkState(CraftBlockData.MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit);
}
// Paper start - cache block data strings
private static Map<String, CraftBlockData> stringDataCache = new java.util.concurrent.ConcurrentHashMap<>();
static {
// cache all of the default states at startup, will not cache ones with the custom states inside of the
// brackets in a different order, though
reloadCache();
}
public static void reloadCache() {
stringDataCache.clear();
Block.BLOCK_STATE_REGISTRY.forEach(blockData -> stringDataCache.put(blockData.toString(), blockData.createCraftBlockData()));
}
// Paper end - cache block data strings
public static CraftBlockData newData(BlockType blockType, String data) {
// Paper start - cache block data strings
if (blockType != null) {
Block block = CraftBlockType.bukkitToMinecraftNew(blockType);
if (block != null) {
net.minecraft.resources.ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block);
data = data == null ? key.toString() : key + data;
}
}
CraftBlockData cached = stringDataCache.computeIfAbsent(data, s -> createNewData(null, s));
return (CraftBlockData) cached.clone();
}
private static CraftBlockData createNewData(BlockType blockType, String data) {
// Paper end - cache block data strings
net.minecraft.world.level.block.state.BlockState blockData;
Block block = blockType == null ? null : ((CraftBlockType<?>) blockType).getHandle();
Map<Property<?>, Comparable<?>> parsed = null;
// Data provided, use it
if (data != null) {
try {
// Material provided, force that material in
if (block != null) {
data = BuiltInRegistries.BLOCK.getKey(block) + data;
}
StringReader reader = new StringReader(data);
BlockStateParser.BlockResult arg = BlockStateParser.parseForBlock(CraftRegistry.getMinecraftRegistry(Registries.BLOCK), reader, false);
Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data: " + data);
blockData = arg.blockState();
parsed = arg.properties();
} catch (CommandSyntaxException ex) {
throw new IllegalArgumentException("Could not parse data: " + data, ex);
}
} else {
blockData = block.defaultBlockState();
}
CraftBlockData craft = CraftBlockData.fromData(blockData);
craft.parsedStates = parsed;
return craft;
}
// Paper start - optimize creating BlockData to not need a map lookup
static {
// Initialize cached data for all IBlockData instances after registration
Block.BLOCK_STATE_REGISTRY.iterator().forEachRemaining(net.minecraft.world.level.block.state.BlockState::createCraftBlockData);
}
public static CraftBlockData fromData(net.minecraft.world.level.block.state.BlockState data) {
return data.createCraftBlockData();
}
public static CraftBlockData createData(net.minecraft.world.level.block.state.BlockState data) {
// Paper end
return CraftBlockData.MAP.getOrDefault(data.getBlock().getClass(), CraftBlockData::new).apply(data);
}
@Override
public SoundGroup getSoundGroup() {
return CraftSoundGroup.getSoundGroup(this.state.getSoundType());
}
@Override
public int getLightEmission() {
return this.state.getLightEmission();
}
@Override
public boolean isOccluding() {
return this.state.canOcclude();
}
@Override
public boolean requiresCorrectToolForDrops() {
return this.state.requiresCorrectToolForDrops();
}
@Override
public boolean isPreferredTool(ItemStack tool) {
Preconditions.checkArgument(tool != null, "tool must not be null");
net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(tool);
return CraftBlockData.isPreferredTool(this.state, nms);
}
public static boolean isPreferredTool(net.minecraft.world.level.block.state.BlockState iblockdata, net.minecraft.world.item.ItemStack nmsItem) {
return !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata);
}
@Override
public PistonMoveReaction getPistonMoveReaction() {
return PistonMoveReaction.getById(this.state.getPistonPushReaction().ordinal());
}
@Override
public boolean isSupported(org.bukkit.block.Block block) {
Preconditions.checkArgument(block != null, "block must not be null");
CraftBlock craftBlock = (CraftBlock) block;
return this.state.canSurvive(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition());
}
@Override
public boolean isSupported(Location location) {
Preconditions.checkArgument(location != null, "location must not be null");
CraftWorld world = (CraftWorld) location.getWorld();
Preconditions.checkArgument(world != null, "location must not have a null world");
BlockPos position = CraftLocation.toBlockPosition(location);
return this.state.canSurvive(world.getHandle(), position);
}
@Override
public boolean isFaceSturdy(BlockFace face, BlockSupport support) {
Preconditions.checkArgument(face != null, "face must not be null");
Preconditions.checkArgument(support != null, "support must not be null");
return this.state.isFaceSturdy(EmptyBlockGetter.INSTANCE, BlockPos.ZERO, CraftBlock.blockFaceToNotch(face), CraftBlockSupport.toNMS(support));
}
// Paper start
@Override
public org.bukkit.util.VoxelShape getCollisionShape(Location location) {
Preconditions.checkArgument(location != null, "location must not be null");
CraftWorld world = (CraftWorld) location.getWorld();
Preconditions.checkArgument(world != null, "location must not have a null world");
BlockPos position = CraftLocation.toBlockPosition(location);
net.minecraft.world.phys.shapes.VoxelShape shape = this.state.getCollisionShape(world.getHandle(), position);
return new org.bukkit.craftbukkit.util.CraftVoxelShape(shape);
}
// Paper end
@Override
public Color getMapColor() {
return Color.fromRGB(this.state.getMapColor(null, null).col);
}
@Override
public Material getPlacementMaterial() {
return CraftItemType.minecraftToBukkit(this.state.getBlock().asItem());
}
@Override
public void rotate(StructureRotation rotation) {
this.state = this.state.rotate(Rotation.valueOf(rotation.name()));
}
@Override
public void mirror(Mirror mirror) {
this.state = this.state.mirror(net.minecraft.world.level.block.Mirror.valueOf(mirror.name()));
}
@Override
public void copyTo(BlockData blockData) {
CraftBlockData other = (CraftBlockData) blockData;
net.minecraft.world.level.block.state.BlockState nms = other.state;
for (Property<?> property : this.state.getBlock().getStateDefinition().getProperties()) {
if (nms.hasProperty(property)) {
nms = this.copyProperty(this.state, nms, property);
}
}
other.state = nms;
}
private <T extends Comparable<T>> net.minecraft.world.level.block.state.BlockState copyProperty(net.minecraft.world.level.block.state.BlockState source, net.minecraft.world.level.block.state.BlockState target, Property<T> property) {
return target.setValue(property, source.getValue(property));
}
@NotNull
@Override
public BlockState createBlockState() {
return CraftBlockStates.getBlockState(this.state, null);
}
// Paper start - destroy speed API
@Override
public float getDestroySpeed(final ItemStack itemStack, final boolean considerEnchants) {
net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.unwrap(itemStack);
float speed = nmsItemStack.getDestroySpeed(this.state);
if (speed > 1.0F && considerEnchants) {
final net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute = net.minecraft.world.entity.ai.attributes.Attributes.MINING_EFFICIENCY;
// Logic sourced from AttributeInstance#calculateValue
final double initialBaseValue = attribute.value().getDefaultValue();
final org.apache.commons.lang3.mutable.MutableDouble modifiedBaseValue = new org.apache.commons.lang3.mutable.MutableDouble(initialBaseValue);
final org.apache.commons.lang3.mutable.MutableDouble baseValMul = new org.apache.commons.lang3.mutable.MutableDouble(1);
final org.apache.commons.lang3.mutable.MutableDouble totalValMul = new org.apache.commons.lang3.mutable.MutableDouble(1);
net.minecraft.world.item.enchantment.EnchantmentHelper.forEachModifier(
nmsItemStack, net.minecraft.world.entity.EquipmentSlot.MAINHAND, (attributeHolder, attributeModifier) -> {
switch (attributeModifier.operation()) {
case ADD_VALUE -> modifiedBaseValue.add(attributeModifier.amount());
case ADD_MULTIPLIED_BASE -> baseValMul.add(attributeModifier.amount());
case ADD_MULTIPLIED_TOTAL -> totalValMul.setValue(totalValMul.doubleValue() * (1D + attributeModifier.amount()));
}
}
);
final double actualModifier = modifiedBaseValue.doubleValue() * baseValMul.doubleValue() * totalValMul.doubleValue();
speed += (float) attribute.value().sanitizeValue(actualModifier);
}
return speed;
}
// Paper end - destroy speed API
// Paper start - Block tick API
@Override
public boolean isRandomlyTicked() {
return this.state.isRandomlyTicking();
}
// Paper end - Block tick API
}

View File

@ -0,0 +1,51 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.AmethystClusterBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.AmethystCluster;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
@GeneratedFrom("1.21.3")
public class CraftAmethystCluster extends CraftBlockData implements AmethystCluster {
private static final EnumProperty<Direction> FACING = AmethystClusterBlock.FACING;
private static final BooleanProperty WATERLOGGED = AmethystClusterBlock.WATERLOGGED;
public CraftAmethystCluster(BlockState state) {
super(state);
}
@Override
public BlockFace getFacing() {
return this.get(FACING, BlockFace.class);
}
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!");
this.set(FACING, blockFace);
}
@Override
public Set<BlockFace> getFaces() {
return this.getValues(FACING, BlockFace.class);
}
@Override
public boolean isWaterlogged() {
return this.get(WATERLOGGED);
}
@Override
public void setWaterlogged(final boolean waterlogged) {
this.set(WATERLOGGED, waterlogged);
}
}

View File

@ -0,0 +1,38 @@
package org.bukkit.craftbukkit.block.impl;
import com.google.common.base.Preconditions;
import io.papermc.paper.generated.GeneratedFrom;
import java.util.Set;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.AnvilBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Directional;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
@GeneratedFrom("1.21.3")
public class CraftAnvil extends CraftBlockData implements Directional {
private static final EnumProperty<Direction> FACING = AnvilBlock.FACING;
public CraftAnvil(BlockState state) {
super(state);
}
@Override
public BlockFace getFacing() {
return this.get(FACING, BlockFace.class);
}
@Override
public void setFacing(final BlockFace blockFace) {
Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!");
Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!");
this.set(FACING, blockFace);
}
@Override
public Set<BlockFace> getFaces() {
return this.getValues(FACING, BlockFace.class);
}
}

Some files were not shown because too many files have changed in this diff Show More