Search in sources :

Example 26 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.

the class CraftingCardContainer method setGridContents.

public void setGridContents(EntityPlayer player, List<ItemStack> stacks) {
    ItemStack craftingCard = player.getHeldItem(EnumHand.MAIN_HAND);
    ItemStackList s = ItemStackList.create(INPUT_SLOTS + 1);
    int x = 0;
    int y = 0;
    for (int i = 0; i < stacks.size(); i++) {
        if (i == 0) {
            s.set(SLOT_OUT, stacks.get(i));
        } else {
            int slot = y * GRID_WIDTH + x;
            s.set(slot, stacks.get(i));
            x++;
            if (x >= 3) {
                x = 0;
                y++;
            }
        }
    }
    CraftingCardItem.putStacksInItem(craftingCard, s);
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) ItemStack(net.minecraft.item.ItemStack)

Example 27 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.

the class CraftingCardItem method testRecipe.

public static void testRecipe(World world, ItemStack craftingCard) {
    ItemStackList stacks = getStacksFromItem(craftingCard);
    InventoryCrafting workInventory = new InventoryCrafting(new Container() {

        @Override
        public boolean canInteractWith(EntityPlayer var1) {
            return false;
        }
    }, 3, 3);
    for (int y = 0; y < 3; y++) {
        for (int x = 0; x < 3; x++) {
            int idx = y * 3 + x;
            int idxCard = y * GRID_WIDTH + x;
            workInventory.setInventorySlotContents(idx, stacks.get(idxCard));
        }
    }
    IRecipe recipe = CraftingManager.findMatchingRecipe(workInventory, world);
    if (recipe != null) {
        ItemStack stack = recipe.getCraftingResult(workInventory);
        stacks.set(INPUT_SLOTS, stack);
    } else {
        stacks.set(INPUT_SLOTS, ItemStack.EMPTY);
    }
    putStacksInItem(craftingCard, stacks);
}
Also used : Container(net.minecraft.inventory.Container) ItemStackList(mcjty.lib.varia.ItemStackList) IRecipe(net.minecraft.item.crafting.IRecipe) EntityPlayer(net.minecraft.entity.player.EntityPlayer) InventoryCrafting(net.minecraft.inventory.InventoryCrafting) ItemStack(net.minecraft.item.ItemStack)

Example 28 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.

the class GuiCraftingCard method getStacks.

@Nonnull
private ItemStackList getStacks() {
    ItemStack cardItem = mc.player.getHeldItem(EnumHand.MAIN_HAND);
    ItemStackList stacks = ItemStackList.EMPTY;
    if (!cardItem.isEmpty() && cardItem.getItem() instanceof CraftingCardItem) {
        stacks = CraftingCardItem.getStacksFromItem(cardItem);
    }
    return stacks;
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 29 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.

the class GuiCraftingCard method createSelectionEvent.

private BlockRenderEvent createSelectionEvent(final int idx) {
    return new BlockRenderEvent() {

        @Override
        public void select(Widget parent) {
            ItemStack itemstack = mc.player.inventory.getItemStack();
            slots[idx].setRenderItem(itemstack);
            ItemStackList stacks = getStacks();
            if (!stacks.isEmpty()) {
                stacks.set(idx, itemstack);
                ItemStack cardItem = mc.player.getHeldItem(EnumHand.MAIN_HAND);
                CraftingCardItem.putStacksInItem(cardItem, stacks);
                RFToolsCtrlMessages.INSTANCE.sendToServer(new PacketItemNBTToServer(cardItem.getTagCompound()));
            }
        }

        @Override
        public void doubleClick(Widget parent) {
        }
    };
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) BlockRenderEvent(mcjty.lib.gui.events.BlockRenderEvent) ItemStack(net.minecraft.item.ItemStack) PacketItemNBTToServer(mcjty.rftoolscontrol.network.PacketItemNBTToServer)

Example 30 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.

the class CraftingStationTileEntity method getCraftableItems.

public ItemStackList getCraftableItems() {
    ItemStackList items = ItemStackList.create();
    for (BlockPos p : processorList) {
        TileEntity te = getWorld().getTileEntity(p);
        if (te instanceof ProcessorTileEntity) {
            ProcessorTileEntity processor = (ProcessorTileEntity) te;
            processor.getCraftableItems(items);
        }
    }
    return items;
}
Also used : ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) GenericTileEntity(mcjty.lib.entity.GenericTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) ItemStackList(mcjty.lib.varia.ItemStackList) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

ItemStackList (mcjty.lib.varia.ItemStackList)30 ItemStack (net.minecraft.item.ItemStack)21 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)9 TileEntity (net.minecraft.tileentity.TileEntity)5 BlockPos (net.minecraft.util.math.BlockPos)5 GenericTileEntity (mcjty.lib.entity.GenericTileEntity)4 ProcessorTileEntity (mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity)4 NBTTagList (net.minecraft.nbt.NBTTagList)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Nonnull (javax.annotation.Nonnull)1 InventoryHelper (mcjty.lib.container.InventoryHelper)1 BlockRenderEvent (mcjty.lib.gui.events.BlockRenderEvent)1 RFTools (mcjty.rftools.RFTools)1 ModularStorageTileEntity (mcjty.rftools.blocks.storage.ModularStorageTileEntity)1 GenericRFToolsItem (mcjty.rftools.items.GenericRFToolsItem)1 FILTER_SLOTS (mcjty.rftools.items.storage.StorageFilterContainer.FILTER_SLOTS)1