Search in sources :

Example 66 with ItemStack

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

the class CustomInventoryCrafting method splitStack.

@Override
public ItemStack splitStack(int i, int j) {
    ItemStack itemstack = ContainerUtil.a(items, i, j);
    if (!itemstack.isEmpty()) {
        for (Container container : containers) {
            container.a(this);
        }
    }
    // Update the armorstand grid
    display.update();
    return itemstack;
}
Also used : Container(net.minecraft.server.v1_16_R1.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_16_R1.ContainerManager_v1_16_R1.SelfContainer) ItemStack(net.minecraft.server.v1_16_R1.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack)

Example 67 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_R1.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack)

Example 68 with ItemStack

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

the class CustomContainerWorkbench method b.

/**
 * This might be for when the inventory closes?
 */
@Override
public void b(EntityHuman entity) {
    super.b(entity);
    // Make sure the craft inventory stops watching this container
    craftInventory.removeContainer(this);
    if (craftInventory.transaction.isEmpty() && PublicCrafters.getInstance().isDropItem()) {
        if (!world.isClientSide) {
            for (int i = 0; i < 9; i++) {
                ItemStack itemstack = craftInventory.splitWithoutUpdate(i);
                if (itemstack != null) {
                    entity.drop(itemstack, false);
                }
            }
            setCraftResult();
            craftInventory.update();
        }
    }
}
Also used : ItemStack(net.minecraft.server.v1_10_R1.ItemStack)

Example 69 with ItemStack

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

the class CustomInventoryCrafting method splitStack.

@Override
public ItemStack splitStack(int i, int j) {
    if (items[i] != null) {
        if (items[i].count <= j) {
            ItemStack itemstack = this.items[i];
            items[i] = null;
            for (Container container : containers) {
                container.a(this);
            }
            display.update();
            return itemstack;
        }
        ItemStack itemstack = items[i].cloneAndSubtract(j);
        if (this.items[i].count == 0) {
            this.items[i] = null;
        }
        for (Container container : containers) {
            container.a(this);
        }
        display.update();
        return itemstack;
    }
    for (Container container : containers) {
        container.a(this);
    }
    display.update();
    return null;
}
Also used : SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_10_R1.ContainerManager_v1_10_R1.SelfContainer) Container(net.minecraft.server.v1_10_R1.Container) CraftItemStack(org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_10_R1.ItemStack)

Example 70 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 : CraftItemStack(org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_10_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