use of mcjty.rftoolscontrol.logic.running.ProgException in project RFToolsControl by McJty.
the class ProcessorTileEntity method getEnergyLong.
@Override
public long getEnergyLong(Inventory side) {
TileEntity te = getTileEntityAt(side);
EnergyTools.EnergyLevelMulti level = EnergyTools.getEnergyLevelMulti(te);
if (level.getMaxEnergy() >= 0) {
throw new ProgException(EXCEPT_NORF);
}
return level.getEnergy();
}
use of mcjty.rftoolscontrol.logic.running.ProgException in project RFToolsControl by McJty.
the class ProcessorTileEntity method craftFail.
public void craftFail(IProgram program) {
if (!program.hasCraftTicket()) {
throw new ProgException(EXCEPT_MISSINGCRAFTTICKET);
}
String ticket = program.getCraftTicket();
for (BlockPos p : craftingStations) {
TileEntity te = getWorld().getTileEntity(p);
if (te instanceof CraftingStationTileEntity) {
CraftingStationTileEntity craftingStation = (CraftingStationTileEntity) te;
craftingStation.craftFail(ticket);
}
}
}
use of mcjty.rftoolscontrol.logic.running.ProgException in project RFToolsControl by McJty.
the class ProcessorTileEntity method getStorageScanner.
private IStorageScanner getStorageScanner() {
int card = getStorageCard();
if (card == -1) {
throw new ProgException(EXCEPT_MISSINGSTORAGECARD);
}
ItemStack storageStack = getStackInSlot(card);
if (!storageStack.hasTagCompound()) {
throw new ProgException(EXCEPT_MISSINGSTORAGECARD);
}
NBTTagCompound tagCompound = storageStack.getTagCompound();
BlockPos c = new BlockPos(tagCompound.getInteger("monitorx"), tagCompound.getInteger("monitory"), tagCompound.getInteger("monitorz"));
int dim = tagCompound.getInteger("monitordim");
World world = DimensionManager.getWorld(dim);
if (world == null) {
throw new ProgException(EXCEPT_MISSINGSTORAGE);
}
if (!WorldTools.chunkLoaded(world, c)) {
throw new ProgException(EXCEPT_MISSINGSTORAGE);
}
TileEntity te = world.getTileEntity(c);
if (te == null) {
throw new ProgException(EXCEPT_MISSINGSTORAGE);
}
if (!(te instanceof IStorageScanner)) {
throw new ProgException(EXCEPT_MISSINGSTORAGE);
}
return (IStorageScanner) te;
}
use of mcjty.rftoolscontrol.logic.running.ProgException in project RFToolsControl by McJty.
the class ProcessorTileEntity method getIngredientsSmart.
public int getIngredientsSmart(IProgram program, Inventory inv, @Nonnull Inventory cardInv, ItemStack item, int slot1, int slot2, @Nonnull Inventory destInv) {
IStorageScanner scanner = getScannerForInv(inv);
IItemHandler handler = getHandlerForInv(inv);
if (item.isEmpty()) {
item = getCraftResult(program);
}
if (item.isEmpty()) {
throw new ProgException(EXCEPT_MISSINGCRAFTRESULT);
}
IItemHandler destHandler = getHandlerForInv(destInv);
if (destHandler == null) {
throw new ProgException(EXCEPT_INVALIDINVENTORY);
}
IItemHandler cardHandler = getItemHandlerAt(cardInv);
ItemStack card = findCraftingCard(cardHandler, item);
if (card.isEmpty()) {
throw new ProgException(EXCEPT_MISSINGCRAFTINGCARD);
}
CardInfo info = this.cardInfo[((RunningProgram) program).getCardIndex()];
List<ItemStack> ingredients;
if (CraftingCardItem.fitsGrid(card) && (slot2 - slot1 >= 8)) {
// We have something that fits a crafting grid and we have enough room for a 3x3 grid
ingredients = CraftingCardItem.getIngredientsGrid(card);
} else {
ingredients = CraftingCardItem.getIngredients(card);
}
boolean strictnbt = CraftingCardItem.isStrictNBT(card);
List<ItemStack> needed = combineIngredients(ingredients);
int requested = checkAvailableItemsAndRequestMissing(destInv, scanner, handler, needed);
if (requested != 0) {
return requested;
}
// We got everything;
IItemHandler itemHandler = getItemHandler();
int slot = slot1;
for (ItemStack ingredient : ingredients) {
int realSlot = info.getRealSlot(slot);
if (!ingredient.isEmpty()) {
ItemStack stack = InventoryTools.extractItem(handler, scanner, ingredient.getCount(), true, false, strictnbt, ingredient, null);
if (!stack.isEmpty()) {
itemHandler.insertItem(realSlot, stack, false);
}
}
slot++;
}
return 0;
}
use of mcjty.rftoolscontrol.logic.running.ProgException in project RFToolsControl by McJty.
the class ProcessorTileEntity method handleCall.
public void handleCall(IProgram program, String signal) {
RunningProgram p = (RunningProgram) program;
CardInfo info = this.cardInfo[p.getCardIndex()];
CompiledCard compiledCard = info.getCompiledCard();
if (compiledCard != null) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_SIGNAL)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
String sig = evaluateStringParameter(compiledOpcode, null, 0);
if (signal.equals(sig)) {
p.pushCall(p.getCurrentOpcode(this).getPrimaryIndex());
p.setCurrent(event.getIndex());
return;
}
}
}
throw new ProgException(EXCEPT_MISSINGSIGNAL);
}
Aggregations