Search in sources :

Example 1 with CpuCore

use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.

the class ProcessorTileEntity method reset.

public void reset() {
    waitingForItems.clear();
    eventQueue.clear();
    stopPrograms();
    for (EnumFacing facing : EnumFacing.values()) {
        powerOut[facing.ordinal()] = 0;
    }
    for (BlockPos np : networkNodes.values()) {
        TileEntity te = getWorld().getTileEntity(np);
        if (te instanceof NodeTileEntity) {
            NodeTileEntity tileEntity = (NodeTileEntity) te;
            for (EnumFacing facing : EnumFacing.values()) {
                tileEntity.setPowerOut(facing, 0);
            }
        }
    }
    gfxOps.clear();
    orderedOps.clear();
    for (CpuCore core : cpuCores) {
        core.setDebug(false);
    }
    markDirty();
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) CraftingStationTileEntity(mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity) WorkbenchTileEntity(mcjty.rftoolscontrol.blocks.workbench.WorkbenchTileEntity) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) MultiTankTileEntity(mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore) EnumFacing(net.minecraft.util.EnumFacing) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with CpuCore

use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.

the class ProcessorTileEntity method writeCores.

private void writeCores(NBTTagCompound tagCompound) {
    NBTTagList coreList = new NBTTagList();
    for (CpuCore core : cpuCores) {
        coreList.appendTag(core.writeToNBT());
    }
    tagCompound.setTag("cores", coreList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore)

Example 3 with CpuCore

use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.

the class ProcessorTileEntity method stopPrograms.

private void stopPrograms(int cardIndex) {
    for (CpuCore core : cpuCores) {
        if (core.hasProgram() && core.getProgram().getCardIndex() == cardIndex) {
            core.stopProgram();
        }
    }
    Set<Pair<Integer, Integer>> newRunningEvents = new HashSet<>();
    for (Pair<Integer, Integer> pair : runningEvents) {
        if (pair.getLeft() != cardIndex) {
            newRunningEvents.add(pair);
        }
    }
    runningEvents = newRunningEvents;
}
Also used : CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore) Pair(org.apache.commons.lang3.tuple.Pair)

Example 4 with CpuCore

use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.

the class ProcessorTileEntity method processEventQueue.

private void processEventQueue() {
    QueuedEvent queuedEvent = eventQueue.peek();
    if (queuedEvent != null) {
        CompiledEvent compiledEvent = queuedEvent.getCompiledEvent();
        if (compiledEvent.isSingle() && runningEvents.contains(Pair.of(queuedEvent.getCardIndex(), compiledEvent.getIndex()))) {
            return;
        }
        CpuCore core = findAvailableCore(queuedEvent.getCardIndex());
        if (core != null) {
            eventQueue.remove();
            RunningProgram program = new RunningProgram(queuedEvent.getCardIndex());
            program.startFromEvent(compiledEvent);
            program.setCraftTicket(queuedEvent.getTicket());
            program.setLastValue(queuedEvent.getParameter());
            core.startProgram(program);
            if (compiledEvent.isSingle()) {
                runningEvents.add(Pair.of(queuedEvent.getCardIndex(), compiledEvent.getIndex()));
            }
        }
    }
}
Also used : CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore) CompiledEvent(mcjty.rftoolscontrol.logic.compiled.CompiledEvent) RunningProgram(mcjty.rftoolscontrol.logic.running.RunningProgram)

Example 5 with CpuCore

use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.

the class ProcessorTileEntity method updateCores.

private void updateCores() {
    if (coresDirty) {
        coresDirty = false;
        // @todo, keep state of current running programs?
        cpuCores.clear();
        for (int i = SLOT_EXPANSION; i < SLOT_EXPANSION + EXPANSION_SLOTS; i++) {
            ItemStack expansionStack = inventoryHelper.getStackInSlot(i);
            if (!expansionStack.isEmpty() && expansionStack.getItem() instanceof CPUCoreItem) {
                CPUCoreItem coreItem = (CPUCoreItem) expansionStack.getItem();
                CpuCore core = new CpuCore();
                core.setTier(coreItem.getTier());
                cpuCores.add(core);
            }
        }
    }
}
Also used : CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore) ItemStack(net.minecraft.item.ItemStack)

Aggregations

CpuCore (mcjty.rftoolscontrol.logic.running.CpuCore)13 RunningProgram (mcjty.rftoolscontrol.logic.running.RunningProgram)5 NBTTagList (net.minecraft.nbt.NBTTagList)2 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)1 Parameter (mcjty.rftoolscontrol.api.parameters.Parameter)1 ParameterType (mcjty.rftoolscontrol.api.parameters.ParameterType)1 CraftingStationTileEntity (mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity)1 MultiTankTileEntity (mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity)1 NodeTileEntity (mcjty.rftoolscontrol.blocks.node.NodeTileEntity)1 WorkbenchTileEntity (mcjty.rftoolscontrol.blocks.workbench.WorkbenchTileEntity)1 CompiledEvent (mcjty.rftoolscontrol.logic.compiled.CompiledEvent)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagString (net.minecraft.nbt.NBTTagString)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1 Pair (org.apache.commons.lang3.tuple.Pair)1