Search in sources :

Example 41 with ItemStack

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

the class NMSAdapter_v1_7_R4 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_7_R4.NBTTagCompound) ItemStack(net.minecraft.server.v1_7_R4.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack)

Example 42 with ItemStack

use of net.minecraft.server.v1_16_R1.ItemStack in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method dropItemAsPlayer.

@Override
public void dropItemAsPlayer(HumanEntity humanEntity, org.bukkit.inventory.ItemStack bukkitItem) {
    EntityHuman entityHuman = ((CraftHumanEntity) humanEntity).getHandle();
    ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
    entityHuman.drop(itemStack, false);
}
Also used : EntityHuman(net.minecraft.server.v1_16_R3.EntityHuman) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Example 43 with ItemStack

use of net.minecraft.server.v1_16_R1.ItemStack in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method getChestName.

@Override
public String getChestName(org.bukkit.inventory.ItemStack itemStack) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.getTag();
    return tagCompound == null || !tagCompound.hasKey("chest-name") ? null : tagCompound.getString("chest-name");
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Example 44 with ItemStack

use of net.minecraft.server.v1_16_R1.ItemStack in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method setItemTag.

private org.bukkit.inventory.ItemStack setItemTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
    tagCompound.setString(key, value);
    return CraftItemStack.asCraftMirror(nmsItem);
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Example 45 with ItemStack

use of net.minecraft.server.v1_16_R1.ItemStack in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_16_R3 method createDesignItem.

@Override
public void createDesignItem(com.bgsoftware.wildchests.objects.inventory.CraftWildInventory craftWildInventory, org.bukkit.inventory.ItemStack itemStack) {
    ItemStack designItem = CraftItemStack.asNMSCopy(itemStack == null || itemStack.getType() == Material.AIR ? new org.bukkit.inventory.ItemStack(Material.BLACK_STAINED_GLASS_PANE) : itemStack.clone());
    designItem.setCount(1);
    designItem.a("DesignItem", NBTTagByte.a(true));
    WildInventory inventory = ((CraftWildInventory) craftWildInventory).getInventory();
    inventory.setItem(0, designItem, false);
    inventory.setItem(1, designItem, false);
    inventory.setItem(3, designItem, false);
    inventory.setItem(4, designItem, false);
}
Also used : WildItemStack(com.bgsoftware.wildchests.objects.inventory.WildItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)

Aggregations

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