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