Search in sources :

Example 56 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project RoseStacker by Rosewood-Development.

the class NBTStackedEntityDataStorage method stripAttributeUuids.

private void stripAttributeUuids(NBTTagCompound compoundTag) {
    NBTTagList attributes = compoundTag.getList("Attributes", 10);
    for (int i = 0; i < attributes.size(); i++) {
        NBTTagCompound attribute = attributes.getCompound(i);
        attribute.remove("UUID");
        NBTTagList modifiers = attribute.getList("Modifiers", 10);
        for (int j = 0; j < modifiers.size(); j++) {
            NBTTagCompound modifier = modifiers.getCompound(j);
            if (modifier.getString("Name").equals("Random spawn bonus")) {
                modifiers.remove(j);
                j--;
            } else {
                modifier.remove("UUID");
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.server.v1_16_R2.NBTTagList) NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound)

Example 57 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project RoseStacker by Rosewood-Development.

the class NBTStackedEntityDataStorage method fillAttributeUuids.

private void fillAttributeUuids(NBTTagCompound compoundTag) {
    NBTTagList attributes = compoundTag.getList("Attributes", 10);
    for (int i = 0; i < attributes.size(); i++) {
        NBTTagCompound attribute = attributes.getCompound(i);
        attribute.a("UUID", UUID.randomUUID());
        NBTTagList modifiers = attribute.getList("Modifiers", 10);
        for (int j = 0; j < modifiers.size(); j++) {
            NBTTagCompound modifier = modifiers.getCompound(j);
            modifier.a("UUID", UUID.randomUUID());
        }
        if (modifiers.size() == 0)
            attribute.remove("Modifiers");
    }
}
Also used : NBTTagList(net.minecraft.server.v1_16_R2.NBTTagList) NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound)

Example 58 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method getPlayerSkull.

@Override
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack itemStack, String texture) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound nbtTagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    NBTTagCompound skullOwner = nbtTagCompound.hasKey("SkullOwner") ? nbtTagCompound.getCompound("SkullOwner") : new NBTTagCompound();
    NBTTagCompound properties = new NBTTagCompound();
    NBTTagList textures = new NBTTagList();
    NBTTagCompound signature = new NBTTagCompound();
    signature.setString("Value", texture);
    textures.add(signature);
    properties.set("textures", textures);
    skullOwner.set("Properties", properties);
    skullOwner.setString("Id", UUID.randomUUID().toString());
    nbtTagCompound.set("SkullOwner", skullOwner);
    nmsItem.setTag(nbtTagCompound);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : NBTTagList(net.minecraft.server.v1_8_R3.NBTTagList) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)

Example 59 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_7_R4 method getPlayerSkull.

@Override
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack itemStack, String texture) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound nbtTagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    NBTTagCompound skullOwner = nbtTagCompound.hasKey("SkullOwner") ? nbtTagCompound.getCompound("SkullOwner") : new NBTTagCompound();
    NBTTagCompound properties = new NBTTagCompound();
    NBTTagList textures = new NBTTagList();
    NBTTagCompound signature = new NBTTagCompound();
    signature.setString("Value", texture);
    textures.add(signature);
    properties.set("textures", textures);
    skullOwner.set("Properties", properties);
    skullOwner.setString("Id", UUID.randomUUID().toString());
    nbtTagCompound.set("SkullOwner", skullOwner);
    nmsItem.setTag(nbtTagCompound);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : NBTTagList(net.minecraft.server.v1_7_R4.NBTTagList) NBTTagCompound(net.minecraft.server.v1_7_R4.NBTTagCompound) ItemStack(net.minecraft.server.v1_7_R4.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack)

Example 60 with NBTTagList

use of net.minecraft.server.v1_16_R2.NBTTagList in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method deserialize.

private InventoryHolder deserialize(NBTTagCompound tagCompound) {
    InventoryHolder inventory = new InventoryHolder(tagCompound.getInt("Size"), "Chest");
    NBTTagList itemsList = tagCompound.getList("Items", 10);
    for (int i = 0; i < itemsList.size(); i++) {
        NBTTagCompound nbtTagCompound = itemsList.get(i);
        inventory.setItem(nbtTagCompound.getByte("Slot"), CraftItemStack.asBukkitCopy(new ItemStack(nbtTagCompound)));
    }
    return inventory;
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack) InventoryHolder(com.bgsoftware.wildchests.objects.inventory.InventoryHolder)

Aggregations

NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)27 ItemStack (org.bukkit.inventory.ItemStack)23 ArrayList (java.util.ArrayList)22 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)22 ItemMeta (org.bukkit.inventory.meta.ItemMeta)22 Map (java.util.Map)21 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)20 ListTag (com.wasteofplastic.org.jnbt.ListTag)20 StringTag (com.wasteofplastic.org.jnbt.StringTag)20 Tag (com.wasteofplastic.org.jnbt.Tag)20 TagCompound (de.keyle.knbt.TagCompound)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 NBTTagString (net.minecraft.server.v1_12_R1.NBTTagString)9 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)8 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)6 NBTTagList (net.minecraft.server.v1_8_R3.NBTTagList)6 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)5 NBTTagList (net.minecraft.server.v1_16_R3.NBTTagList)5 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)5 NBTTagList (net.minecraft.server.v1_9_R2.NBTTagList)5