Search in sources :

Example 1 with Container

use of net.minecraft.world.inventory.Container 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 : SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_17_1.ContainerManager_v1_17_1.SelfContainer) Container(net.minecraft.world.inventory.Container)

Example 2 with Container

use of net.minecraft.world.inventory.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 : SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_17_1.ContainerManager_v1_17_1.SelfContainer) Container(net.minecraft.world.inventory.Container) ItemStack(net.minecraft.world.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack)

Example 3 with Container

use of net.minecraft.world.inventory.Container 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 : SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_17_R1.ContainerManager_v1_17_R1.SelfContainer) Container(net.minecraft.world.inventory.Container)

Example 4 with Container

use of net.minecraft.world.inventory.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 : SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_17_R1.ContainerManager_v1_17_R1.SelfContainer) Container(net.minecraft.world.inventory.Container) ItemStack(net.minecraft.world.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack)

Example 5 with Container

use of net.minecraft.world.inventory.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.world.IInventory) ITileEntityContainer(net.minecraft.world.inventory.ITileEntityContainer) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_17_R1.ContainerManager_v1_17_R1.SelfContainer) Container(net.minecraft.world.inventory.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_17_R1.ContainerManager_v1_17_R1.SelfContainer) InventoryCraftResult(net.minecraft.world.inventory.InventoryCraftResult)

Aggregations

Container (net.minecraft.world.inventory.Container)13 IInventory (net.minecraft.world.IInventory)4 ITileEntityContainer (net.minecraft.world.inventory.ITileEntityContainer)4 InventoryCraftResult (net.minecraft.world.inventory.InventoryCraftResult)4 ItemStack (net.minecraft.world.item.ItemStack)4 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_17_1.ContainerManager_v1_17_1.SelfContainer)3 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_17_R1.ContainerManager_v1_17_R1.SelfContainer)3 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_18_R1.ContainerManager_v1_18_R1.SelfContainer)3 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_18_R2.ContainerManager_v1_18_R2.SelfContainer)3 CraftItemStack (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack)2 TileEntityContainer (com.bgsoftware.wildchests.objects.containers.TileEntityContainer)1 ChatComponentText (net.minecraft.network.chat.ChatComponentText)1 PacketPlayOutOpenWindow (net.minecraft.network.protocol.game.PacketPlayOutOpenWindow)1 EntityPlayer (net.minecraft.server.level.EntityPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)1 CraftItemStack (org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack)1 CraftItemStack (org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack)1