fix some ae2 integration api

partially resolves #2961 but we have a jnlua issue with iterating lua 5.3 tables
This commit is contained in:
payonel 2018-10-22 23:06:25 -07:00
parent 0ec817ff2b
commit ac2e734547

View File

@ -63,16 +63,18 @@ trait NetworkControl[AETile >: Null <: TileEntity with IActionHost with IGridHos
private def allCraftables: Iterable[IAEItemStack] = allItems.collect{ case aeItem if aeItem.isCraftable => aeCraftItem(aeItem) } private def allCraftables: Iterable[IAEItemStack] = allItems.collect{ case aeItem if aeItem.isCraftable => aeCraftItem(aeItem) }
private def convert(aeItem: IAEItemStack): java.util.Map[AnyRef, AnyRef] = { private def convert(aeItem: IAEItemStack): java.util.Map[AnyRef, AnyRef] = {
case class AnyRefAnyRefMap (value: java.util.HashMap[AnyRef, AnyRef])
// I would prefer to move the convert code to the registry for IAEItemStack // I would prefer to move the convert code to the registry for IAEItemStack
// but craftables need the device that crafts them // but craftables need the device that crafts them
Registry.convert(Array(aePotentialItem(aeItem).createItemStack()))(0) match { val hash = new java.util.HashMap[AnyRef, AnyRef]()
case AnyRefAnyRefMap(jmap) => { Registry.convert(Array[AnyRef](aePotentialItem(aeItem).createItemStack()))
jmap.update("isCraftable", Boolean.box(aeItem.isCraftable)) .head
jmap.update("size", Int.box(aeItem.getStackSize.toInt)) .asInstanceOf[java.util.Map[Object, Object]]
jmap .collect {
} case (key, value) => hash += key -> value
} }
hash.update("isCraftable", Boolean.box(aeItem.isCraftable))
hash.update("size", Int.box(aeItem.getStackSize.toInt))
hash
} }
@Callback(doc = "function():table -- Get a list of tables representing the available CPUs in the network.") @Callback(doc = "function():table -- Get a list of tables representing the available CPUs in the network.")
@ -155,16 +157,21 @@ trait NetworkControl[AETile >: Null <: TileEntity with IActionHost with IGridHos
private def matches(stack: java.util.Map[AnyRef, AnyRef], filter: scala.collection.mutable.Map[AnyRef, AnyRef]): Boolean = { private def matches(stack: java.util.Map[AnyRef, AnyRef], filter: scala.collection.mutable.Map[AnyRef, AnyRef]): Boolean = {
if (stack == null) return false if (stack == null) return false
filter.forall { filter.forall {
case (key: AnyRef, value: AnyRef) => { case (key: AnyRef, value: AnyRef) if stack.containsKey(key) => {
val stack_value = stack.get(key) Option(stack.get(key)) match {
value match { case Some(stack_value) => {
case number: Number => stack_value match { value match {
case stack_number: Number => number.intValue == stack_number.intValue case number: Number => stack_value match {
case any => number.toString.equals(any.toString) case stack_number: Number => number.intValue == stack_number.intValue
case any => number.toString.equals(any.toString)
}
case any => any.toString.equals(stack_value.toString)
}
} }
case any => any.toString.equals(stack_value.toString) case _ => false
} }
} }
case _ => false
} }
} }
} }