All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minestom.server.instance.block.banner.BannerPattern Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
package net.minestom.server.instance.block.banner;

import net.minestom.server.network.NetworkBuffer;
import net.minestom.server.registry.DynamicRegistry;
import net.minestom.server.registry.ProtocolObject;
import net.minestom.server.registry.Registries;
import net.minestom.server.registry.Registry;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.utils.nbt.BinaryTagSerializer;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public sealed interface BannerPattern extends ProtocolObject, BannerPatterns permits BannerPatternImpl {
    @NotNull NetworkBuffer.Type> NETWORK_TYPE = NetworkBuffer.RegistryKey(Registries::bannerPattern);
    @NotNull BinaryTagSerializer> NBT_TYPE = BinaryTagSerializer.registryKey(Registries::bannerPattern);

    static @NotNull BannerPattern create(
            @NotNull NamespaceID assetId,
            @NotNull String translationKey
    ) {
        return new BannerPatternImpl(assetId, translationKey, null);
    }

    static @NotNull Builder builder() {
        return new Builder();
    }

    /**
     * 

Creates a new registry for banner patterns, loading the vanilla banner patterns.

* * @see net.minestom.server.MinecraftServer to get an existing instance of the registry */ @ApiStatus.Internal static @NotNull DynamicRegistry createDefaultRegistry() { return DynamicRegistry.create( "minecraft:banner_pattern", BannerPatternImpl.REGISTRY_NBT_TYPE, Registry.Resource.BANNER_PATTERNS, (namespace, props) -> new BannerPatternImpl(Registry.bannerPattern(namespace, props)) ); } @NotNull NamespaceID assetId(); @NotNull String translationKey(); @Nullable Registry.BannerPatternEntry registry(); final class Builder { private NamespaceID assetId; private String translationKey; private Builder() { } @Contract(value = "_ -> this", pure = true) public @NotNull Builder assetId(@NotNull NamespaceID assetId) { this.assetId = assetId; return this; } @Contract(value = "_ -> this", pure = true) public @NotNull Builder translationKey(@NotNull String translationKey) { this.translationKey = translationKey; return this; } @Contract(pure = true) public @NotNull BannerPattern build() { return new BannerPatternImpl(assetId, translationKey, null); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy