use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class Commands method showCurrent.
private static void showCurrent(ProcessorTileEntity processor, int i, RunningProgram program) {
CompiledOpcode currentOpcode = program.getCurrentOpcode(processor);
int x = currentOpcode.getGridX();
int y = currentOpcode.getGridY();
String id = currentOpcode.getOpcode().getId();
processor.log("Core " + i + ": [" + x + "," + y + "] " + id);
if (program.getLock() != null) {
processor.log(TextFormatting.YELLOW + "[LOCKED on " + program.getLock() + "]!");
}
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class ProcessorTileEntity method handleEventsRedstoneOn.
private void handleEventsRedstoneOn(int i, CompiledCard compiledCard, String node, int prevMask, int newMask) {
int redstoneOnMask = newMask & ~prevMask;
if (redstoneOnMask != 0) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_REDSTONE_ON)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
BlockSide side = evaluateSideParameter(compiledOpcode, null, 0);
if (side != null && node.equals(side.getNodeName())) {
EnumFacing facing = side.getSide();
if (facing == null || ((redstoneOnMask >> facing.ordinal()) & 1) == 1) {
runOrQueueEvent(i, event, null, null);
}
}
}
}
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class ProcessorTileEntity method handleEventsCraftResume.
private void handleEventsCraftResume(int cardIndex, CompiledCard compiledCard) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_CRAFTRESUME)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
int ticks = evaluateIntParameter(compiledOpcode, null, 0);
if (ticks > 0 && tickCount % ticks == 0) {
if (!waitingForItems.isEmpty()) {
WaitForItem found = null;
int foundIdx = -1;
for (int i = 0; i < waitingForItems.size(); i++) {
WaitForItem wfi = waitingForItems.get(i);
if (wfi.getInventory() == null || wfi.getItemStack().isEmpty()) {
foundIdx = i;
found = wfi;
break;
} else {
IItemHandler handler = getItemHandlerAt(wfi.getInventory());
int cnt = countItemInHandler(wfi.getItemStack(), handler);
if (cnt >= wfi.getItemStack().getCount()) {
foundIdx = i;
found = wfi;
break;
}
}
}
if (found != null) {
waitingForItems.remove(foundIdx);
runOrQueueEvent(cardIndex, event, found.getTicket(), null);
}
}
}
}
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class ProcessorTileEntity method handleEventsRedstoneOff.
private void handleEventsRedstoneOff(int i, CompiledCard compiledCard, String node, int prevMask, int newMask) {
int redstoneOffMask = prevMask & ~newMask;
if (redstoneOffMask != 0) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_REDSTONE_OFF)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
BlockSide side = evaluateSideParameter(compiledOpcode, null, 0);
if (side != null && node.equals(side.getNodeName())) {
EnumFacing facing = side.getSide();
if (facing == null || ((redstoneOffMask >> facing.ordinal()) & 1) == 1) {
runOrQueueEvent(i, event, null, null);
}
}
}
}
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class ProcessorTileEntity method fireCraftEvent.
public void fireCraftEvent(String ticket, ItemStack stackToCraft) {
for (int i = 0; i < cardInfo.length; i++) {
CardInfo info = cardInfo[i];
CompiledCard compiledCard = info.getCompiledCard();
if (compiledCard != null) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_CRAFT)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
ItemStack stack = evaluateItemParameter(compiledOpcode, null, 0);
Inventory inv = evaluateInventoryParameter(compiledOpcode, null, 1);
if (!stack.isEmpty()) {
if (stack.isItemEqual(stackToCraft)) {
runOrQueueEvent(i, event, ticket, null);
return;
}
} else if (inv != null) {
IItemHandler handler = getItemHandlerAt(inv);
ItemStack craftingCard = findCraftingCard(handler, stackToCraft);
if (!craftingCard.isEmpty()) {
runOrQueueEvent(i, event, ticket, null);
return;
}
}
}
}
}
}
Aggregations