Search in sources :

Example 21 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project acidisland by tastybento.

the class NMSHandler method isPotion.

/* (non-Javadoc)
     * @see com.wasteofplastic.askyblock.nms.NMSAbstraction#isPotion(org.bukkit.inventory.ItemStack)
     */
@Override
public boolean isPotion(ItemStack item) {
    // Bukkit.getLogger().info("DEBUG:item = " + item);
    if (item.getType().equals(Material.POTION)) {
        net.minecraft.server.v1_10_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
        NBTTagCompound tag = stack.getTag();
        /*
            for (String list : tag.c()) {
                Bukkit.getLogger().info("DEBUG: list = " + list);
            }*/
        if (tag != null && (!tag.getString("Potion").equalsIgnoreCase("minecraft:water") || tag.getString("Potion").isEmpty())) {
            return true;
        }
    }
    return false;
}
Also used : NBTTagCompound(net.minecraft.server.v1_10_R1.NBTTagCompound)

Example 22 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project acidisland by tastybento.

the class NMSHandler method isPotion.

/* (non-Javadoc)
     * @see com.wasteofplastic.askyblock.nms.NMSAbstraction#isPotion(org.bukkit.inventory.ItemStack)
     */
@Override
public boolean isPotion(ItemStack item) {
    // Bukkit.getLogger().info("DEBUG:item = " + item);
    if (item.getType().equals(Material.POTION)) {
        net.minecraft.server.v1_12_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
        NBTTagCompound tag = stack.getTag();
        /*
            for (String list : tag.c()) {
                Bukkit.getLogger().info("DEBUG: list = " + list);
            }*/
        if (tag != null && (!tag.getString("Potion").equalsIgnoreCase("minecraft:water") || tag.getString("Potion").isEmpty())) {
            return true;
        }
    }
    return false;
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound)

Example 23 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project MyPet by xXKeyleXx.

the class ItemStackComparator method compareTagData.

public static boolean compareTagData(ItemStack i1, ItemStack i2) {
    if (i1 == null || i2 == null) {
        return false;
    }
    if (i1.hasItemMeta() && i2.hasItemMeta()) {
        NBTTagCompound tag1 = CraftItemStack.asNMSCopy(i1).getTag();
        NBTTagCompound tag2 = CraftItemStack.asNMSCopy(i2).getTag();
        if (tag1 != null) {
            if (tag1.equals(tag2)) {
                return true;
            } else {
                i1 = CraftItemStack.asBukkitCopy(CraftItemStack.asNMSCopy(i1));
                tag1 = CraftItemStack.asNMSCopy(i1).getTag();
                return tag1.equals(tag2);
            }
        }
        return false;
    }
    return i1.hasItemMeta() == i2.hasItemMeta();
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R1.NBTTagCompound)

Example 24 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project MyPet by xXKeyleXx.

the class ConfigItem method load.

public void load(MaterialHolder material, String data) {
    MinecraftKey key = new MinecraftKey(material.getLegacyName().getName());
    Item item = Item.REGISTRY.get(key);
    if (item == null) {
        return;
    }
    net.minecraft.server.v1_8_R3.ItemStack is = new net.minecraft.server.v1_8_R3.ItemStack(item, 1, material.getLegacyName().getData());
    if (data != null) {
        NBTTagCompound tag = null;
        String nbtString = data.trim();
        if (nbtString.startsWith("{") && nbtString.endsWith("}")) {
            try {
                tag = MojangsonParser.parse(nbtString);
            } catch (Exception e) {
                MyPetApi.getLogger().warning("Error" + ChatColor.RESET + " in config: " + ChatColor.UNDERLINE + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
                MyPetApi.getLogger().warning(item.getName() + " " + nbtString);
            }
            if (tag != null) {
                is.setTag(tag);
            }
        }
    }
    this.item = CraftItemStack.asCraftMirror(is);
}
Also used : Item(net.minecraft.server.v1_8_R3.Item) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) MinecraftKey(net.minecraft.server.v1_8_R3.MinecraftKey) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

Example 25 with NBTTagCompound

use of net.minecraft.server.v1_13_R2.NBTTagCompound in project MyPet by xXKeyleXx.

the class ItemStackComparator method compareTagData.

public static boolean compareTagData(ItemStack i1, ItemStack i2) {
    if (i1 == null || i2 == null) {
        return false;
    }
    if (i1.hasItemMeta() && i2.hasItemMeta()) {
        NBTTagCompound tag1 = CraftItemStack.asNMSCopy(i1).getTag();
        NBTTagCompound tag2 = CraftItemStack.asNMSCopy(i2).getTag();
        if (tag1 != null) {
            if (tag1.equals(tag2)) {
                return true;
            } else {
                i1 = CraftItemStack.asBukkitCopy(CraftItemStack.asNMSCopy(i1));
                tag1 = CraftItemStack.asNMSCopy(i1).getTag();
                return tag1.equals(tag2);
            }
        }
        return false;
    }
    return i1.hasItemMeta() == i2.hasItemMeta();
}
Also used : NBTTagCompound(net.minecraft.server.v1_9_R2.NBTTagCompound)

Aggregations

NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)69 ItemStack (org.bukkit.inventory.ItemStack)60 Map (java.util.Map)41 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)39 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)38 ArrayList (java.util.ArrayList)37 ItemMeta (org.bukkit.inventory.meta.ItemMeta)35 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)33 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)30 ListTag (com.wasteofplastic.org.jnbt.ListTag)30 StringTag (com.wasteofplastic.org.jnbt.StringTag)30 Tag (com.wasteofplastic.org.jnbt.Tag)30 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)24 Nullable (javax.annotation.Nullable)21 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)21 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)20 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)20 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)20 NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)19 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)18