mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
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:
parent
0ec817ff2b
commit
ac2e734547
@ -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,8 +157,9 @@ 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 {
|
||||||
|
case Some(stack_value) => {
|
||||||
value match {
|
value match {
|
||||||
case number: Number => stack_value match {
|
case number: Number => stack_value match {
|
||||||
case stack_number: Number => number.intValue == stack_number.intValue
|
case stack_number: Number => number.intValue == stack_number.intValue
|
||||||
@ -165,6 +168,10 @@ trait NetworkControl[AETile >: Null <: TileEntity with IActionHost with IGridHos
|
|||||||
case any => any.toString.equals(stack_value.toString)
|
case any => any.toString.equals(stack_value.toString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case _ => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case _ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user