public Attributes(ItemStack stack) { // Create a CraftItemStack (under the hood) this.stack = NbtFactory.getCraftItemStack(stack); // Load NBT NbtCompound nbt = NbtFactory.fromItemTag(this.stack); this.attributes = nbt.getList("AttributeModifiers", true); }
public void setUUID(@Nonnull UUID id) { Preconditions.checkNotNull("id", "id cannot be NULL."); data.put("UUIDLeast", id.getLeastSignificantBits()); data.put("UUIDMost", id.getMostSignificantBits()); }
public void setName(@Nonnull String name) { Preconditions.checkNotNull(name, "name cannot be NULL."); data.put("Name", name); }
public UUID getUUID() { return new UUID(data.getLong("UUIDMost", null), data.getLong("UUIDLeast", null)); }
public void setAttributeType(@Nonnull AttributeType type) { Preconditions.checkNotNull(type, "type cannot be NULL."); data.put("AttributeName", type.getMinecraftId()); }
public String getName() { return data.getString("Name", null); }
public AttributeType getAttributeType() { return AttributeType.fromId(data.getString("AttributeName", null)); }
public void setOperation(@Nonnull Operation operation) { Preconditions.checkNotNull(operation, "operation cannot be NULL."); data.put("Operation", operation.getId()); }
public Operation getOperation() { return Operation.fromId(data.getInteger("Operation", 0)); }
public void setAmount(double amount) { data.put("Amount", amount); }
public double getAmount() { return data.getDouble("Amount", 0.0); }