Search in sources :

Example 16 with Container

use of net.minecraft.server.v1_13_R2.Container 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 17 with Container

use of net.minecraft.server.v1_13_R2.Container 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 18 with Container

use of net.minecraft.server.v1_13_R2.Container in project PublicCrafters by BananaPuncher714.

the class CustomTileEntityContainerWorkbench method createMenu.

/**
 * This is an ITileEntityContainer method that returns a new container for whatever tile entity
 */
@Override
public Container createMenu(int id, PlayerInventory inv, EntityHuman ent) {
    CustomInventoryCrafting crafting = manager.benches.get(bloc);
    if (crafting == null) {
        crafting = new CustomInventoryCrafting(bloc, manager, new SelfContainer(id), 3, 3);
        manager.put(bloc, crafting);
    }
    IInventory inventory = crafting.resultInventory;
    InventoryCraftResult result;
    if (inventory instanceof InventoryCraftResult || inventory == null) {
        result = new InventoryCraftResult();
        crafting.resultInventory = result;
    } else {
        result = (InventoryCraftResult) inventory;
    }
    Container container = new CustomContainerWorkbench(id, ent.getBukkitEntity(), bloc, crafting, result);
    crafting.addContainer(container);
    return container;
}
Also used : IInventory(net.minecraft.server.v1_14_R1.IInventory) ITileEntityContainer(net.minecraft.server.v1_14_R1.ITileEntityContainer) Container(net.minecraft.server.v1_14_R1.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_14_R1.ContainerManager_v1_14_R1.SelfContainer) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_14_R1.ContainerManager_v1_14_R1.SelfContainer) InventoryCraftResult(net.minecraft.server.v1_14_R1.InventoryCraftResult)

Example 19 with Container

use of net.minecraft.server.v1_13_R2.Container in project PublicCrafters by BananaPuncher714.

the class CustomTileEntityContainerWorkbench method createMenu.

/**
 * This is an ITileEntityContainer method that returns a new container for whatever tile entity
 */
@Override
public Container createMenu(int id, PlayerInventory inv, EntityHuman ent) {
    CustomInventoryCrafting crafting = manager.benches.get(bloc);
    if (crafting == null) {
        crafting = new CustomInventoryCrafting(bloc, manager, new SelfContainer(id), 3, 3);
        manager.put(bloc, crafting);
    }
    IInventory inventory = crafting.resultInventory;
    InventoryCraftResult result;
    if (inventory instanceof InventoryCraftResult || inventory == null) {
        result = new InventoryCraftResult();
        crafting.resultInventory = result;
    } else {
        result = (InventoryCraftResult) inventory;
    }
    Container container = new CustomContainerWorkbench(id, ent.getBukkitEntity(), bloc, crafting, result);
    crafting.addContainer(container);
    return container;
}
Also used : IInventory(net.minecraft.server.v1_16_R1.IInventory) ITileEntityContainer(net.minecraft.server.v1_16_R1.ITileEntityContainer) Container(net.minecraft.server.v1_16_R1.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_16_R1.ContainerManager_v1_16_R1.SelfContainer) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_16_R1.ContainerManager_v1_16_R1.SelfContainer) InventoryCraftResult(net.minecraft.server.v1_16_R1.InventoryCraftResult)

Example 20 with Container

use of net.minecraft.server.v1_13_R2.Container 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)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)46 Container (net.minecraft.server.v1_12_R1.Container)9 Container (net.minecraft.server.v1_16_R3.Container)9 Container (org.flyte.api.v1.Container)9 FailedNbt (com.ruinscraft.panilla.api.exception.FailedNbt)8 INbtTagCompound (com.ruinscraft.panilla.api.nbt.INbtTagCompound)8 Container (net.minecraft.server.v1_11_R1.Container)8 Container (net.minecraft.server.v1_14_R1.Container)8 Container (net.minecraft.server.v1_15_R1.Container)8 Container (net.minecraft.server.v1_16_R1.Container)8 Container (net.minecraft.server.v1_16_R2.Container)8 Container (net.minecraft.server.v1_8_R3.Container)8 Test (org.junit.Test)8 Container (net.minecraft.server.v1_13_R1.Container)7 Container (net.minecraft.server.v1_13_R2.Container)6 Container (net.minecraft.server.v1_10_R1.Container)5 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)5 Tasks (flyteidl.core.Tasks)4 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_11_R1.ContainerManager_v1_11_R1.SelfContainer)4 HashMap (java.util.HashMap)4