Search in sources :

Example 1 with CompoundTag_v1_11_R1

use of net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1 in project Denizen-For-Bukkit by DenizenScript.

the class ImprovedOfflinePlayer_v1_11_R1 method setInventory.

@Override
public void setInventory(org.bukkit.inventory.PlayerInventory inventory) {
    CraftInventoryPlayer inv = (CraftInventoryPlayer) inventory;
    NBTTagCompound nbtTagCompound = ((CompoundTag_v1_11_R1) compound).toNMSTag();
    nbtTagCompound.set("Inventory", inv.getInventory().a(new NBTTagList()));
    this.compound = CompoundTag_v1_11_R1.fromNMSTag(nbtTagCompound);
    if (this.autosave) {
        savePlayerData();
    }
}
Also used : CraftInventoryPlayer(org.bukkit.craftbukkit.v1_11_R1.inventory.CraftInventoryPlayer) CompoundTag_v1_11_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1)

Example 2 with CompoundTag_v1_11_R1

use of net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1 in project Denizen-For-Bukkit by DenizenScript.

the class ImprovedOfflinePlayer_v1_11_R1 method getEnderChest.

@Override
public Inventory getEnderChest() {
    if (offlineEnderChests.containsKey(getUniqueId())) {
        return offlineEnderChests.get(getUniqueId());
    }
    InventoryEnderChest endchest = new InventoryEnderChest(null);
    endchest.a(((CompoundTag_v1_11_R1) this.compound).toNMSTag().getList("EnderItems", 10));
    org.bukkit.inventory.Inventory inv = new CraftInventory(endchest);
    offlineEnderChests.put(getUniqueId(), inv);
    return inv;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_11_R1.inventory.CraftInventory) CompoundTag_v1_11_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1) Inventory(org.bukkit.inventory.Inventory)

Example 3 with CompoundTag_v1_11_R1

use of net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1 in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelper_v1_11_R1 method addNbtData.

@Override
public ItemStack addNbtData(ItemStack itemStack, String key, Tag value) {
    net.minecraft.server.v1_11_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
    CompoundTag compound = CompoundTag_v1_11_R1.fromNMSTag(tag).createBuilder().put(key, value).build();
    nmsItemStack.setTag(((CompoundTag_v1_11_R1) compound).toNMSTag());
    return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Also used : CompoundTag_v1_11_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1) NBTTagCompound(net.minecraft.server.v1_11_R1.NBTTagCompound)

Example 4 with CompoundTag_v1_11_R1

use of net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1 in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelper_v1_11_R1 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_11_R1(compound));
        }
    }
    return addNbtData(itemStack, "AttributeModifiers", new ListTag(CompoundTag.class, modifierList));
}
Also used : EntityAttribute(net.aufdemrand.denizen.nms.enums.EntityAttribute) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CompoundTag_v1_11_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1) 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)

Aggregations

CompoundTag_v1_11_R1 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1)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_11_R1.NBTTagCompound)1 CraftInventory (org.bukkit.craftbukkit.v1_11_R1.inventory.CraftInventory)1 CraftInventoryPlayer (org.bukkit.craftbukkit.v1_11_R1.inventory.CraftInventoryPlayer)1 Inventory (org.bukkit.inventory.Inventory)1