Search in sources :

Example 1 with ProcessorTileEntity

use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.

the class CraftingStationTileEntity method startCraft.

private void startCraft(int index, int amount) {
    Pair<ProcessorTileEntity, ItemStack> pair = findCraftableItem(index);
    if (pair == null) {
        // Somehow not possible
        System.out.println("What? Can't happen");
        return;
    }
    String ticket = getNewTicket(null);
    ItemStack stack = pair.getValue();
    int count = (amount + stack.getCount() - 1) / stack.getCount();
    CraftingRequest request = new CraftingRequest(ticket, stack, count);
    if (!checkRequestAmount()) {
        return;
    }
    activeCraftingRequests.add(request);
    pair.getKey().fireCraftEvent(ticket, stack);
    cleanupCounter--;
    if (cleanupCounter <= 0) {
        cleanupCounter = 50;
        cleanupStaleRequests();
    }
}
Also used : ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ProcessorTileEntity

use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.

the class CraftingStationTileEntity method request.

public boolean request(ItemStack item, @Nullable Inventory destination) {
    for (BlockPos p : processorList) {
        TileEntity te = getWorld().getTileEntity(p);
        if (te instanceof ProcessorTileEntity) {
            ProcessorTileEntity processor = (ProcessorTileEntity) te;
            ItemStackList items = ItemStackList.create();
            processor.getCraftableItems(items);
            for (ItemStack i : items) {
                if (item.isItemEqual(i)) {
                    String ticket = getNewTicket(destination);
                    if (!checkRequestAmount()) {
                        return false;
                    }
                    activeCraftingRequests.add(new CraftingRequest(ticket, i, 1));
                    processor.fireCraftEvent(ticket, i);
                    return true;
                }
            }
        }
    }
    return false;
}
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) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ProcessorTileEntity

use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.

the class CommandHandler method registerCommands.

public static void registerCommands() {
    McJtyLib.registerCommand(RFToolsControl.MODID, CMD_TESTRECIPE, (player, arguments) -> {
        ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
        if (heldItem.isEmpty()) {
            return false;
        }
        if (heldItem.getItem() instanceof CraftingCardItem) {
            CraftingCardItem.testRecipe(player.getEntityWorld(), heldItem);
        }
        return true;
    });
    McJtyLib.registerCommand(RFToolsControl.MODID, CMD_GETGRAPHICS, (player, arguments) -> {
        TileEntity te = player.getEntityWorld().getTileEntity(arguments.getBlockPos());
        if (te instanceof ProcessorTileEntity) {
            ProcessorTileEntity processor = (ProcessorTileEntity) te;
            RFToolsCtrlMessages.INSTANCE.sendTo(new PacketGraphicsReady(processor), (EntityPlayerMP) player);
        }
        return true;
    });
}
Also used : ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) PacketGraphicsReady(mcjty.rftoolscontrol.network.PacketGraphicsReady) ItemStack(net.minecraft.item.ItemStack) CraftingCardItem(mcjty.rftoolscontrol.items.craftingcard.CraftingCardItem)

Example 4 with ProcessorTileEntity

use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.

the class CraftingStationTileEntity method findItem.

private int findItem(String itemName, int meta, String nbtString) {
    int index = 0;
    for (BlockPos p : processorList) {
        TileEntity te = getWorld().getTileEntity(p);
        if (te instanceof ProcessorTileEntity) {
            ProcessorTileEntity processor = (ProcessorTileEntity) te;
            ItemStackList items = ItemStackList.create();
            processor.getCraftableItems(items);
            for (ItemStack item : items) {
                if (item.getItemDamage() == meta && itemName.equals(item.getItem().getRegistryName().toString())) {
                    if (item.hasTagCompound()) {
                        if (nbtString.equalsIgnoreCase(item.serializeNBT().toString())) {
                            return index;
                        }
                    } else {
                        return index;
                    }
                }
                index++;
            }
        }
    }
    return -1;
}
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) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ProcessorTileEntity

use of mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity in project RFToolsControl by McJty.

the class CraftingStationTileEntity method findCraftableItem.

private Pair<ProcessorTileEntity, ItemStack> findCraftableItem(int index) {
    for (BlockPos p : processorList) {
        TileEntity te = getWorld().getTileEntity(p);
        if (te instanceof ProcessorTileEntity) {
            ProcessorTileEntity processor = (ProcessorTileEntity) te;
            ItemStackList items = ItemStackList.create();
            processor.getCraftableItems(items);
            for (ItemStack item : items) {
                if (index == 0) {
                    // found!
                    return Pair.of(processor, item);
                }
                index--;
            }
        }
    }
    return null;
}
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) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ProcessorTileEntity (mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity)12 TileEntity (net.minecraft.tileentity.TileEntity)11 GenericTileEntity (mcjty.lib.entity.GenericTileEntity)5 Block (net.minecraft.block.Block)5 ItemStack (net.minecraft.item.ItemStack)5 ItemStackList (mcjty.lib.varia.ItemStackList)4 BlockPos (net.minecraft.util.math.BlockPos)4 World (net.minecraft.world.World)3 TextComponentString (net.minecraft.util.text.TextComponentString)2 Parameter (mcjty.rftoolscontrol.api.parameters.Parameter)1 Tuple (mcjty.rftoolscontrol.api.parameters.Tuple)1 CraftingCardItem (mcjty.rftoolscontrol.items.craftingcard.CraftingCardItem)1 PacketGraphicsReady (mcjty.rftoolscontrol.network.PacketGraphicsReady)1 ModuleDataLog (mcjty.rftoolscontrol.rftoolssupport.ModuleDataLog)1 ModuleDataVariable (mcjty.rftoolscontrol.rftoolssupport.ModuleDataVariable)1 ModuleDataVectorArt (mcjty.rftoolscontrol.rftoolssupport.ModuleDataVectorArt)1