use of mcjty.rftoolscontrol.logic.compiled.CompiledEvent in project RFToolsControl by McJty.
the class ProcessorTileEntity method handleEventsTimer.
private void handleEventsTimer(int i, CompiledCard compiledCard) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_TIMER)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
int ticks = evaluateIntParameter(compiledOpcode, null, 0);
if (ticks > 0 && tickCount % ticks == 0) {
runOrDropEvent(i, event, null, null);
}
}
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledEvent 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.CompiledEvent 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.CompiledEvent in project RFToolsControl by McJty.
the class ProcessorTileEntity method readEventQueue.
private void readEventQueue(NBTTagCompound tagCompound) {
eventQueue.clear();
NBTTagList eventQueueList = tagCompound.getTagList("events", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < eventQueueList.tagCount(); i++) {
NBTTagCompound tag = eventQueueList.getCompoundTagAt(i);
int card = tag.getInteger("card");
int index = tag.getInteger("index");
boolean single = tag.getBoolean("single");
String ticket = tag.hasKey("ticket") ? tag.getString("ticket") : null;
Parameter parameter = null;
if (tag.hasKey("parameter")) {
parameter = ParameterTools.readFromNBT(tag.getCompoundTag("parameter"));
}
eventQueue.add(new QueuedEvent(card, new CompiledEvent(index, single), ticket, parameter));
}
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledEvent 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);
}
}
}
}
}
Aggregations