Search in sources :

Example 21 with NBTTagCompound

use of net.minecraft.server.v1_16_R3.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_16_R3.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_16_R3.NBTTagCompound in project solinia3-core by mixxit.

the class ItemStackUtils method IsDisplayItem.

public static boolean IsDisplayItem(ItemStack itemStack) {
    // Also check nbttag
    if (itemStack == null)
        return false;
    boolean isDisplayItem = itemStack.getItemMeta().getDisplayName().startsWith("Display Item: ");
    if (isDisplayItem)
        return isDisplayItem;
    // Classic method
    net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
    String isMerchant = compound.getString("merchant");
    return Boolean.parseBoolean(isMerchant);
}
Also used : NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound)

Example 24 with NBTTagCompound

use of net.minecraft.server.v1_16_R3.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 25 with NBTTagCompound

use of net.minecraft.server.v1_16_R3.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)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)47 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 Map (java.util.Map)30 ItemMeta (org.bukkit.inventory.meta.ItemMeta)29 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)27 ArrayList (java.util.ArrayList)24 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)14 NBTTagCompound (net.minecraft.server.v1_9_R2.NBTTagCompound)13 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)12 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)12 TagCompound (de.keyle.knbt.TagCompound)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 PreparedStatement (java.sql.PreparedStatement)8 HashMap (java.util.HashMap)8 NBTTagCompound (net.minecraft.server.v1_8_R1.NBTTagCompound)8 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)8 NBTTagCompound (net.minecraft.server.v1_9_R1.NBTTagCompound)8