Search in sources :

Example 76 with ItemStack

use of net.minecraft.server.v1_16_R1.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 77 with ItemStack

use of net.minecraft.server.v1_16_R1.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 78 with ItemStack

use of net.minecraft.server.v1_16_R1.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 79 with ItemStack

use of net.minecraft.server.v1_16_R1.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 80 with ItemStack

use of net.minecraft.server.v1_16_R1.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

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