Search in sources :

Example 6 with Container

use of net.minecraft.server.v1_11_R1.Container in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_16_R3 method openPage.

@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    String title = inventory.getTitle();
    Container container = createContainer(entityPlayer.nextContainerCounter(), entityPlayer.inventory, inventory);
    container.setTitle(new ChatComponentText(title));
    entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), container.getTitle()));
    entityPlayer.activeContainer = container;
    entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
Also used : Container(net.minecraft.server.v1_16_R3.Container) TileEntityContainer(com.bgsoftware.wildchests.objects.containers.TileEntityContainer) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) PacketPlayOutOpenWindow(net.minecraft.server.v1_16_R3.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.server.v1_16_R3.ChatComponentText)

Example 7 with Container

use of net.minecraft.server.v1_11_R1.Container 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 (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_11_R1.ItemStack)

Example 8 with Container

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

the class CustomInventoryCrafting method setItems.

protected void setItems(List<org.bukkit.inventory.ItemStack> items) {
    int index = 0;
    for (org.bukkit.inventory.ItemStack item : items) {
        this.items.set(index++, CraftItemStack.asNMSCopy(item));
    }
    // Want to update the result without having to use a real player
    if (this.resultInventory instanceof InventoryCraftResult) {
        CustomContainerWorkbench container = new CustomContainerWorkbench(manager.mockPlayer.getBukkitEntity(), bloc, this, (InventoryCraftResult) resultInventory);
        container.a(this);
        CraftingInventory crafting = (CraftingInventory) container.getBukkitView().getTopInventory();
        Bukkit.getPluginManager().callEvent(new PrepareItemCraftEvent(crafting, container.getBukkitView(), false));
    }
    display.forceUpdate();
}
Also used : CraftingInventory(org.bukkit.inventory.CraftingInventory) PublicCraftingInventory(io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory) PrepareItemCraftEvent(org.bukkit.event.inventory.PrepareItemCraftEvent) InventoryCraftResult(net.minecraft.server.v1_11_R1.InventoryCraftResult)

Example 9 with Container

use of net.minecraft.server.v1_11_R1.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 == null ? ItemStack.a : item);
    for (Container container : containers) {
        container.a(this);
    }
    // Update the armorstand grid
    display.update();
}
Also used : SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_11_R1.ContainerManager_v1_11_R1.SelfContainer) Container(net.minecraft.server.v1_11_R1.Container)

Example 10 with Container

use of net.minecraft.server.v1_11_R1.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_11_R1.ContainerManager_v1_11_R1.SelfContainer) Container(net.minecraft.server.v1_11_R1.Container) CraftItemStack(org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_11_R1.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