Search in sources :

Example 61 with ItemStack

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

the class CustomInventoryCrafting method remove.

@Override
public void remove() {
    display.stop();
    for (ItemStack item : items) {
        org.bukkit.inventory.ItemStack is = CraftItemStack.asBukkitCopy(item);
        if (is.getType() != Material.AIR) {
            bloc.getWorld().dropItem(bloc.clone().add(.5, .9, .5), is);
        }
    }
    items.clear();
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_14_R1.ItemStack)

Example 62 with ItemStack

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

the class ContainerManager_v1_16_R2 method load.

@Override
public void load(Location location, List<ItemStack> items) {
    // Is 0 really ok as an id?!?
    CustomInventoryCrafting crafting = new CustomInventoryCrafting(location, this, new SelfContainer(0), 3, 3);
    InventoryCraftResult result = new InventoryCraftResult();
    crafting.resultInventory = result;
    crafting.setItems(items);
    benches.put(location, crafting);
}
Also used : InventoryCraftResult(net.minecraft.server.v1_16_R2.InventoryCraftResult)

Example 63 with ItemStack

use of net.minecraft.server.v1_16_R2.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_R2.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_16_R2.ContainerManager_v1_16_R2.SelfContainer) CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R2.ItemStack)

Example 64 with ItemStack

use of net.minecraft.server.v1_16_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) CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R2.ItemStack)

Example 65 with ItemStack

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

the class CustomInventoryCrafting method setItem.

@Override
public void setItem(int index, ItemStack item) {
    // Instead of updating one container, update all the containers
    // That are looking at the table, basically the viewers
    items.set(index, item);
    for (Container container : containers) {
        container.a(this);
    }
    // Update the armorstand grid
    display.update();
}
Also used : Container(net.minecraft.server.v1_16_R2.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_16_R2.ContainerManager_v1_16_R2.SelfContainer)

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 ItemStack (net.minecraft.server.v1_11_R1.ItemStack)13 CraftItemStack (org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack)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 (net.minecraft.server.v1_10_R1.ItemStack)10 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)10 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)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 ItemStack (net.minecraft.server.v1_15_R1.ItemStack)9