use of net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3 in project Denizen-For-Bukkit by DenizenScript.
the class ItemHelper_v1_8_R3 method setAttributeModifiers.
@Override
public ItemStack setAttributeModifiers(ItemStack itemStack, Map<EntityAttribute, List<EntityAttributeModifier>> modifiers) {
List<Tag> modifierList = new ArrayList<Tag>(getNbtData(itemStack).getList("AttributeModifiers"));
for (Map.Entry<EntityAttribute, List<EntityAttributeModifier>> entry : modifiers.entrySet()) {
EntityAttribute attribute = entry.getKey();
for (EntityAttributeModifier modifier : entry.getValue()) {
Map<String, Tag> compound = new HashMap<String, Tag>();
compound.put("AttributeName", new StringTag(attribute.getName()));
UUID uuid = modifier.getUniqueId();
compound.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
compound.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
compound.put("Name", new StringTag(modifier.getName()));
compound.put("Operation", new IntTag(modifier.getOperation().ordinal()));
compound.put("Amount", new DoubleTag(modifier.getAmount()));
modifierList.add(new CompoundTag_v1_8_R3(compound));
}
}
return addNbtData(itemStack, "AttributeModifiers", new ListTag(CompoundTag.class, modifierList));
}
use of net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3 in project Denizen-For-Bukkit by DenizenScript.
the class ItemHelper_v1_8_R3 method addNbtData.
@Override
public ItemStack addNbtData(ItemStack itemStack, String key, Tag value) {
net.minecraft.server.v1_8_R3.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
CompoundTag compound = CompoundTag_v1_8_R3.fromNMSTag(tag).createBuilder().put(key, value).build();
nmsItemStack.setTag(((CompoundTag_v1_8_R3) compound).toNMSTag());
return CraftItemStack.asBukkitCopy(nmsItemStack);
}
use of net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3 in project Denizen-For-Bukkit by DenizenScript.
the class ImprovedOfflinePlayer_v1_8_R3 method getEnderChest.
@Override
public Inventory getEnderChest() {
if (offlineEnderChests.containsKey(getUniqueId())) {
return offlineEnderChests.get(getUniqueId());
}
InventoryEnderChest endchest = new InventoryEnderChest();
endchest.a(((CompoundTag_v1_8_R3) this.compound).toNMSTag().getList("EnderItems", 10));
Inventory inv = new CraftInventory(endchest);
offlineEnderChests.put(getUniqueId(), inv);
return inv;
}
use of net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3 in project Denizen-For-Bukkit by DenizenScript.
the class ImprovedOfflinePlayer_v1_8_R3 method setInventory.
@Override
public void setInventory(org.bukkit.inventory.PlayerInventory inventory) {
CraftInventoryPlayer inv = (CraftInventoryPlayer) inventory;
NBTTagCompound nbtTagCompound = ((CompoundTag_v1_8_R3) compound).toNMSTag();
nbtTagCompound.set("Inventory", inv.getInventory().a(new NBTTagList()));
this.compound = CompoundTag_v1_8_R3.fromNMSTag(nbtTagCompound);
if (this.autosave) {
savePlayerData();
}
}
Aggregations