Search in sources :

Example 11 with NBTTagCompound

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

the class ItemStackComparator method compareTagData.

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

Example 12 with NBTTagCompound

use of net.minecraft.server.v1_16_R1.NBTTagCompound in project Essentials by EssentialsX.

the class v1_8_R2SpawnerProvider method getEntityType.

@Override
public EntityType getEntityType(ItemStack is) {
    net.minecraft.server.v1_8_R2.ItemStack itemStack;
    CraftItemStack craftStack = CraftItemStack.asCraftCopy(is);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("BlockEntityTag")) {
        throw new IllegalArgumentException();
    }
    String name = tag.getCompound("BlockEntityTag").getString("EntityId");
    return EntityType.fromName(name);
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_8_R2.NBTTagCompound)

Example 13 with NBTTagCompound

use of net.minecraft.server.v1_16_R1.NBTTagCompound in project Ublisk by Derkades.

the class Item method setNBTValue.

public Item setNBTValue(String key, NBTBase value) {
    NBTTagCompound nbt = this.getNBT();
    nbt.set(key, value);
    return this.setNBT(nbt);
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound)

Example 14 with NBTTagCompound

use of net.minecraft.server.v1_16_R1.NBTTagCompound in project Ublisk by Derkades.

the class Item method getNBT.

public NBTTagCompound getNBT() {
    net.minecraft.server.v1_12_R1.ItemStack nms = CraftItemStack.asNMSCopy(item);
    NBTTagCompound compound = nms.getTag();
    if (compound == null) {
        return new NBTTagCompound();
    } else {
        return compound;
    }
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound)

Example 15 with NBTTagCompound

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

the class PlatformHelper method entityToTag.

@Override
public TagCompound entityToTag(Entity bukkitEntity) {
    net.minecraft.server.v1_16_R1.Entity entity = ((CraftEntity) bukkitEntity).getHandle();
    NBTTagCompound vanillaNBT = new NBTTagCompound();
    if (entity instanceof EntityLiving) {
        ((EntityLiving) entity).saveData(vanillaNBT);
    } else {
        Method b = ReflectionUtil.getMethod(entity.getClass(), "b", NBTTagCompound.class);
        try {
            b.invoke(entity, vanillaNBT);
        } catch (IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }
    return (TagCompound) ItemStackNBTConverter.vanillaCompoundToCompound(vanillaNBT);
}
Also used : net.minecraft.server.v1_16_R1(net.minecraft.server.v1_16_R1) CraftEntity(org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity) Method(java.lang.reflect.Method) TagCompound(de.keyle.knbt.TagCompound) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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 NBTTagCompound (net.minecraft.server.v1_9_R1.NBTTagCompound)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