Search in sources :

Example 46 with ItemStack

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

the class NMSAdapter_v1_8_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_8_R3.EntityHuman) CraftHumanEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)

Example 47 with ItemStack

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

the class NMSAdapter_v1_8_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_8_R3.NBTTagCompound) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)

Example 48 with ItemStack

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

the class NMSAdapter_v1_12_R1 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_12_R1.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 49 with ItemStack

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

the class NMSAdapter_v1_12_R1 method deserialzeItem.

@Override
public org.bukkit.inventory.ItemStack deserialzeItem(String serialized) {
    if (serialized.isEmpty())
        return new org.bukkit.inventory.ItemStack(Material.AIR);
    byte[] buff;
    if (serialized.toCharArray()[0] == '*') {
        buff = Base64.getDecoder().decode(serialized.substring(1));
    } else {
        buff = new BigInteger(serialized, 32).toByteArray();
    }
    ByteArrayInputStream inputStream = new ByteArrayInputStream(buff);
    try {
        NBTTagCompound nbtTagCompoundRoot = NBTCompressedStreamTools.a(new DataInputStream(inputStream));
        ItemStack nmsItem = new ItemStack(nbtTagCompoundRoot);
        return CraftItemStack.asBukkitCopy(nmsItem);
    } catch (Exception ex) {
        return null;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) BigInteger(java.math.BigInteger) DataInputStream(java.io.DataInputStream) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 50 with ItemStack

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

the class NMSAdapter_v1_12_R1 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_12_R1.EntityHuman) CraftHumanEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftHumanEntity) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

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