mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 11:07:53 +01:00
Make ItemAttribute record
This commit is contained in:
parent
6aaf5aa0ce
commit
dd27edee50
@ -125,12 +125,12 @@ public abstract class ItemMetaBuilder implements TagWritable {
|
||||
handleCollection(attributes, "AttributeModifiers", () -> NBT.List(NBTType.TAG_Compound,
|
||||
attributes.stream()
|
||||
.map(itemAttribute -> NBT.Compound(Map.of(
|
||||
"UUID", NBT.IntArray(Utils.uuidToIntArray(itemAttribute.getUuid())),
|
||||
"Amount", NBT.Double(itemAttribute.getValue()),
|
||||
"Slot", NBT.String(itemAttribute.getSlot().name().toLowerCase()),
|
||||
"AttributeName", NBT.String(itemAttribute.getAttribute().key()),
|
||||
"Operation", NBT.Int(itemAttribute.getOperation().getId()),
|
||||
"Name", NBT.String(itemAttribute.getInternalName()))))
|
||||
"UUID", NBT.IntArray(Utils.uuidToIntArray(itemAttribute.uuid())),
|
||||
"Amount", NBT.Double(itemAttribute.amount()),
|
||||
"Slot", NBT.String(itemAttribute.slot().name().toLowerCase()),
|
||||
"AttributeName", NBT.String(itemAttribute.attribute().key()),
|
||||
"Operation", NBT.Int(itemAttribute.operation().getId()),
|
||||
"Name", NBT.String(itemAttribute.name()))))
|
||||
.toList()
|
||||
));
|
||||
return this;
|
||||
|
@ -2,48 +2,13 @@ package net.minestom.server.item.attribute;
|
||||
|
||||
import net.minestom.server.attribute.Attribute;
|
||||
import net.minestom.server.attribute.AttributeOperation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemAttribute {
|
||||
|
||||
private final UUID uuid;
|
||||
private final String internalName;
|
||||
private final Attribute attribute;
|
||||
private final AttributeOperation operation;
|
||||
private final double value;
|
||||
private final AttributeSlot slot;
|
||||
|
||||
public ItemAttribute(UUID uuid, String internalName, Attribute attribute, AttributeOperation operation, double value, AttributeSlot slot) {
|
||||
this.uuid = uuid;
|
||||
this.internalName = internalName;
|
||||
this.attribute = attribute;
|
||||
this.operation = operation;
|
||||
this.value = value;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getInternalName() {
|
||||
return internalName;
|
||||
}
|
||||
|
||||
public Attribute getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public AttributeOperation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public AttributeSlot getSlot() {
|
||||
return slot;
|
||||
}
|
||||
public record ItemAttribute(@NotNull UUID uuid,
|
||||
@NotNull String name,
|
||||
@NotNull Attribute attribute,
|
||||
@NotNull AttributeOperation operation, double amount,
|
||||
@NotNull AttributeSlot slot) {
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user