From fe4f63dc23eaf95dc0cd26425daee0bf4901c784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Thu, 22 Jan 2015 16:24:36 +0100 Subject: [PATCH] Fixed AE2 integration's getCraftables returning stored stacks; now properly returning recipe output stacks (mostly noticeable in the stack size of a craftable). Closes #841. --- .../cil/oc/integration/appeng/DriverController.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/scala/li/cil/oc/integration/appeng/DriverController.scala b/src/main/scala/li/cil/oc/integration/appeng/DriverController.scala index abe2a6180..75037560f 100644 --- a/src/main/scala/li/cil/oc/integration/appeng/DriverController.scala +++ b/src/main/scala/li/cil/oc/integration/appeng/DriverController.scala @@ -63,9 +63,17 @@ object DriverController extends DriverTileEntity with EnvironmentAware { "busy" -> cpu.isBusy))) @Callback(doc = "function():table -- Get a list of known item recipes. These can be used to issue crafting requests.") - def getCraftables(context: Context, args: Arguments): Array[AnyRef] = + def getCraftables(context: Context, args: Arguments): Array[AnyRef] = { result(tileEntity.getProxy.getStorage.getItemInventory.getStorageList. - filter(_.isCraftable).map(new Craftable(tileEntity, _)).toArray) + filter(_.isCraftable).map(stack => { + val patterns = tileEntity.getProxy.getCrafting.getCraftingFor(stack, null, 0, tileEntity.getWorld) + val result = patterns.find(pattern => pattern.getOutputs.exists(_.isSameType(stack))) match { + case Some(pattern) => pattern.getOutputs.find(_.isSameType(stack)).get + case _ => stack.copy.setStackSize(0) // Should not be possible, but hey... + } + new Craftable(tileEntity, result) + }).toArray) + } @Callback(doc = "function():table -- Get a list of the stored items in the network.") def getItemsInNetwork(context: Context, args: Arguments): Array[AnyRef] =