Search in sources :

Example 36 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 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_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)

Example 37 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method setTag.

@Override
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    tagCompound.set(key, new NBTTagString(value));
    nmsItem.setTag(tagCompound);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 38 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method getTag.

@Override
public long getTag(org.bukkit.inventory.ItemStack itemStack, String key, long def) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    if (!tagCompound.hasKeyOfType(key, 4))
        return def;
    return tagCompound.getLong(key);
}
Also used : 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)

Example 39 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method getTag.

@Override
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    if (!tagCompound.hasKeyOfType(key, 8))
        return def;
    return tagCompound.getString(key);
}
Also used : 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 40 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method setTag.

@Override
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, long value) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    tagCompound.set(key, new NBTTagLong(value));
    nmsItem.setTag(tagCompound);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : 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) NBTTagLong(net.minecraft.server.v1_8_R3.NBTTagLong)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)49 net.minecraft.server.v1_16_R3 (net.minecraft.server.v1_16_R3)28 InvocationTargetException (java.lang.reflect.InvocationTargetException)27 ItemStack (net.minecraft.server.v1_8_R3.ItemStack)27 ItemStack (net.minecraft.server.v1_12_R1.ItemStack)25 Pair (com.mojang.datafixers.util.Pair)22 ItemStack (net.minecraft.server.v1_16_R3.ItemStack)20 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)20 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)20 MyPetApi (de.Keyle.MyPet.MyPetApi)18 EntitySize (de.Keyle.MyPet.api.entity.EntitySize)18 MyPet (de.Keyle.MyPet.api.entity.MyPet)18 IconMenuItem (de.Keyle.MyPet.api.gui.IconMenuItem)18 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)18 Bukkit (org.bukkit.Bukkit)18 Util (de.Keyle.MyPet.api.Util)17 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)17 Arrays (java.util.Arrays)17 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)17 ENTITY_LIVING_broadcastItemBreak (de.Keyle.MyPet.compat.v1_16_R3.CompatManager.ENTITY_LIVING_broadcastItemBreak)15