示例#1
0
  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);
  }
示例#2
0
 public void setUUID(@Nonnull UUID id) {
   Preconditions.checkNotNull("id", "id cannot be NULL.");
   data.put("UUIDLeast", id.getLeastSignificantBits());
   data.put("UUIDMost", id.getMostSignificantBits());
 }
示例#3
0
 public void setName(@Nonnull String name) {
   Preconditions.checkNotNull(name, "name cannot be NULL.");
   data.put("Name", name);
 }
示例#4
0
 public UUID getUUID() {
   return new UUID(data.getLong("UUIDMost", null), data.getLong("UUIDLeast", null));
 }
示例#5
0
 public void setAttributeType(@Nonnull AttributeType type) {
   Preconditions.checkNotNull(type, "type cannot be NULL.");
   data.put("AttributeName", type.getMinecraftId());
 }
示例#6
0
 public String getName() {
   return data.getString("Name", null);
 }
示例#7
0
 public AttributeType getAttributeType() {
   return AttributeType.fromId(data.getString("AttributeName", null));
 }
示例#8
0
 public void setOperation(@Nonnull Operation operation) {
   Preconditions.checkNotNull(operation, "operation cannot be NULL.");
   data.put("Operation", operation.getId());
 }
示例#9
0
 public Operation getOperation() {
   return Operation.fromId(data.getInteger("Operation", 0));
 }
示例#10
0
 public void setAmount(double amount) {
   data.put("Amount", amount);
 }
示例#11
0
 public double getAmount() {
   return data.getDouble("Amount", 0.0);
 }