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

net.minestom.server.item.component.PotDecorations Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
package net.minestom.server.item.component;

import net.minestom.server.item.Material;
import net.minestom.server.network.NetworkBuffer;
import net.minestom.server.utils.nbt.BinaryTagSerializer;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public record PotDecorations(
        @NotNull Material back,
        @NotNull Material left,
        @NotNull Material right,
        @NotNull Material front
) {
    public static final @NotNull Material DEFAULT_ITEM = Material.BRICK;
    public static final PotDecorations EMPTY = new PotDecorations(DEFAULT_ITEM, DEFAULT_ITEM, DEFAULT_ITEM, DEFAULT_ITEM);

    public static final NetworkBuffer.Type NETWORK_TYPE = Material.NETWORK_TYPE.list(4).transform(PotDecorations::new, PotDecorations::asList);
    public static BinaryTagSerializer NBT_TYPE = Material.NBT_TYPE.list().map(PotDecorations::new, PotDecorations::asList);

    public PotDecorations(@NotNull List list) {
        this(getOrAir(list, 0), getOrAir(list, 1), getOrAir(list, 2), getOrAir(list, 3));
    }

    public PotDecorations(@NotNull Material material) {
        this(material, material, material, material);
    }

    public @NotNull List asList() {
        return List.of(back, left, right, front);
    }

    private static @NotNull Material getOrAir(@NotNull List list, int index) {
        return index < list.size() ? list.get(index) : Material.BRICK;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy