Search in sources :

Example 1 with CompoundTag_v1_8_R3

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));
}
Also used : EntityAttribute(net.aufdemrand.denizen.nms.enums.EntityAttribute) CompoundTag_v1_8_R3(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) EntityAttributeModifier(net.aufdemrand.denizen.nms.util.EntityAttributeModifier) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with CompoundTag_v1_8_R3

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);
}
Also used : NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) CompoundTag_v1_8_R3(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3)

Example 3 with CompoundTag_v1_8_R3

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;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory) CompoundTag_v1_8_R3(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3) CraftInventory(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory) Inventory(org.bukkit.inventory.Inventory)

Example 4 with CompoundTag_v1_8_R3

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();
    }
}
Also used : CompoundTag_v1_8_R3(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3) CraftInventoryPlayer(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryPlayer)

Aggregations

CompoundTag_v1_8_R3 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3)4 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1 EntityAttribute (net.aufdemrand.denizen.nms.enums.EntityAttribute)1 EntityAttributeModifier (net.aufdemrand.denizen.nms.util.EntityAttributeModifier)1 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)1 CraftInventory (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory)1 CraftInventoryPlayer (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryPlayer)1 Inventory (org.bukkit.inventory.Inventory)1