Search in sources :

Example 71 with ItemStack

use of net.minecraft.server.v1_8_R2.ItemStack in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method setDefaults.

private void setDefaults() {
    try {
        // Set items
        Field field = InventoryCrafting.class.getDeclaredField("items");
        field.setAccessible(true);
        items = (List<ItemStack>) field.get(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)

Example 72 with ItemStack

use of net.minecraft.server.v1_8_R2.ItemStack in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method remove.

@Override
public void remove() {
    display.stop();
    for (int i = 0; i < items.length; i++) {
        ItemStack item = items[i];
        items[i] = CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(Material.AIR));
        org.bukkit.inventory.ItemStack is = CraftItemStack.asBukkitCopy(item);
        if (is.getType() != Material.AIR) {
            bloc.getWorld().dropItem(bloc.clone().add(.5, .9, .5), is);
        }
    }
}
Also used : ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)

Example 73 with ItemStack

use of net.minecraft.server.v1_8_R2.ItemStack in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method b.

/**
 * The shift clicking method
 */
@Override
public ItemStack b(EntityHuman entityhuman, int i) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.c.get(i);
    if ((slot != null) && (slot.hasItem())) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.cloneItemStack();
        if (i == 0) {
            itemstack1.getItem().b(itemstack1, world, entityhuman);
            if (!a(itemstack1, 10, 46, true)) {
                return null;
            }
            slot.a(itemstack1, itemstack);
        } else if ((i >= 10) && (i < 37)) {
            if (!a(itemstack1, 37, 46, false)) {
                return null;
            }
        } else if ((i >= 37) && (i < 46)) {
            if (!a(itemstack1, 10, 37, false)) {
                return null;
            }
        } else if (!a(itemstack1, 10, 46, false)) {
            return null;
        }
        slot.f();
        if (itemstack1.count == itemstack.count) {
            return null;
        }
        slot.a(entityhuman, itemstack1);
        if (i == 0) {
            entityhuman.drop(itemstack1, false);
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.server.v1_9_R2.Slot) PacketPlayOutSetSlot(net.minecraft.server.v1_9_R2.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_9_R2.ItemStack)

Example 74 with ItemStack

use of net.minecraft.server.v1_8_R2.ItemStack in project MechanicsMain by WeaponMechanics.

the class NonNullList_1_13_R2 method set.

@Override
public ItemStack set(int index, ItemStack newItem) {
    ItemStack oldItem = get(index);
    Item item = (Item) ReflectionUtil.invokeField(itemField, newItem);
    if (newItem.getCount() == 0 && item != null) {
        newItem.setCount(1);
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
        newItem.setCount(0);
    } else if (!ItemStack.matches(oldItem, newItem)) {
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
    }
    return super.set(index, newItem);
}
Also used : Item(net.minecraft.server.v1_13_R2.Item) ItemStack(net.minecraft.server.v1_13_R2.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack)

Example 75 with ItemStack

use of net.minecraft.server.v1_8_R2.ItemStack in project MechanicsMain by WeaponMechanics.

the class NonNullList_1_16_R3 method set.

@Override
public ItemStack set(int index, ItemStack newItem) {
    ItemStack oldItem = get(index);
    Item item = (Item) ReflectionUtil.invokeField(itemField, newItem);
    if (newItem.getCount() == 0 && item != null) {
        newItem.setCount(1);
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
        newItem.setCount(0);
    } else if (!ItemStack.matches(oldItem, newItem)) {
        consumer.accept(CraftItemStack.asBukkitCopy(oldItem), CraftItemStack.asBukkitCopy(newItem), index);
    }
    return super.set(index, newItem);
}
Also used : Item(net.minecraft.server.v1_16_R3.Item) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)

Aggregations

ItemStack (net.minecraft.server.v1_12_R1.ItemStack)28 ItemStack (net.minecraft.server.v1_8_R3.ItemStack)27 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)21 ItemStack (net.minecraft.server.v1_16_R3.ItemStack)20 IconMenuItem (de.Keyle.MyPet.api.gui.IconMenuItem)18 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)17 CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)16 CraftItemStack (org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack)14 ItemStack (net.minecraft.server.v1_11_R1.ItemStack)13 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)12 ItemStack (net.minecraft.server.v1_7_R4.ItemStack)12 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)11 ItemStack (org.bukkit.inventory.ItemStack)11 ItemStack (net.minecraft.server.v1_10_R1.ItemStack)10 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)10 Location (org.bukkit.Location)10 TagCompound (de.keyle.knbt.TagCompound)9 Field (java.lang.reflect.Field)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 ItemStack (net.minecraft.server.v1_13_R2.ItemStack)9