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

net.minestom.server.item.enchant.AttributeEffect Maven / Gradle / Ivy

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

import net.minestom.server.entity.attribute.Attribute;
import net.minestom.server.entity.attribute.AttributeOperation;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.utils.nbt.BinaryTagSerializer;
import org.jetbrains.annotations.NotNull;

public record AttributeEffect(
        @NotNull NamespaceID id,
        @NotNull Attribute attribute,
        @NotNull LevelBasedValue amount,
        @NotNull AttributeOperation operation
) implements Enchantment.Effect, LocationEffect {

    public static final BinaryTagSerializer NBT_TYPE = BinaryTagSerializer.object(
            "id", BinaryTagSerializer.STRING.map(NamespaceID::from, NamespaceID::asString), AttributeEffect::id,
            "attribute", Attribute.NBT_TYPE, AttributeEffect::attribute,
            "amount", LevelBasedValue.NBT_TYPE, AttributeEffect::amount,
            "operation", AttributeOperation.NBT_TYPE, AttributeEffect::operation,
            AttributeEffect::new
    );

    @Override
    public @NotNull BinaryTagSerializer nbtType() {
        return NBT_TYPE;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy