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);
}
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);
}
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;
}
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) {
}
};
}
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;
}
Aggregations