mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
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.
This commit is contained in:
parent
60c97140d9
commit
fe4f63dc23
@ -63,9 +63,17 @@ object DriverController extends DriverTileEntity with EnvironmentAware {
|
|||||||
"busy" -> cpu.isBusy)))
|
"busy" -> cpu.isBusy)))
|
||||||
|
|
||||||
@Callback(doc = "function():table -- Get a list of known item recipes. These can be used to issue crafting requests.")
|
@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.
|
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.")
|
@Callback(doc = "function():table -- Get a list of the stored items in the network.")
|
||||||
def getItemsInNetwork(context: Context, args: Arguments): Array[AnyRef] =
|
def getItemsInNetwork(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user