@@ -26,11 +26,10 @@ import li.cil.oc.integration.ae2fc.Ae2FcUtil
2626import li .cil .oc .integration .appeng .NetworkControl ._
2727import li .cil .oc .integration .appeng .internal .SubscriptionBase
2828import li .cil .oc .integration .ec .ECUtil
29- import li .cil .oc .server .driver .Registry
30- import li .cil .oc .util .{AE2Bridge , DatabaseAccess }
3129import li .cil .oc .util .ExtendedArguments ._
3230import li .cil .oc .util .ExtendedNBT ._
3331import li .cil .oc .util .ResultWrapper ._
32+ import li .cil .oc .util .{AE2Bridge , DatabaseAccess }
3433import net .minecraft .item .{Item , ItemStack }
3534import net .minecraft .nbt .{JsonToNBT , NBTTagCompound }
3635import net .minecraft .tileentity .TileEntity
@@ -189,7 +188,7 @@ trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActi
189188 }
190189 DatabaseAccess .withDatabase(node, args.checkString(1 ), database => {
191190 val items = allItems
192- .collect { case aeItem if matches(convert(aeItem, tile), filter) => aePotential( aeItem, tile) }.toArray
191+ .collect { case aeItem if matches(convert(aeItem, tile), filter) => aeItem }.toArray
193192 val offset = args.optSlot(database.data, 2 , 0 )
194193 val count = args.optInteger(3 , Int .MaxValue ) min (database.size - offset) min items.length
195194 var slot = offset
@@ -641,32 +640,28 @@ object NetworkControl extends AETypes {
641640 }
642641 }
643642
644- private def aePotential (aeItem : AEStack , tile : TileEntity with IGridProxyable ): AEStack = {
645- if (aeItem.getStackSize > 0 || ! aeItem.isCraftable)
646- aeItem
647- else
648- asCraft(aeItem, tile)
649- }
650-
651- private def hashConvert (value : java.util.HashMap [_, _]) = {
652- val hash = new java.util.HashMap [String , AnyRef ]
653- value.collect { case (k : String , v : AnyRef ) => hash += k -> v }
643+ private def hashConvert (value : java.util.HashMap [AnyRef , AnyRef ]) = {
644+ val hash = new java.util.HashMap [String , AnyRef ](((value.size() + 1 ) / 0.75 ).toInt)
645+ val it = value.entrySet().iterator()
646+ while (it.hasNext) {
647+ val entry = it.next()
648+ val k = entry.getKey
649+ val v = entry.getValue
650+ k match {
651+ case str : String =>
652+ hash.put(str, v)
653+ case _ =>
654+ }
655+ }
654656 hash
655657 }
656658
657659 def convert (aeItem : AEStack , tile : TileEntity with IGridProxyable ): java.util.HashMap [String , AnyRef ] = {
658- val potentialItem = aePotential(aeItem, tile)
659- val result = Registry .convert(Array [AnyRef ](potentialItem))
660- .collect { case hash : java.util.HashMap [_, _] => hashConvert(hash) }
661- if (result.length > 0 ) {
662- val hash = result(0 )
663- // it would have been nice to put these fields in a registry convert
664- // but the potential ae item needs the tile and position data
665- hash.update(" size" , Long .box(aeItem.getStackSize))
666- hash.update(" isCraftable" , Boolean .box(aeItem.isCraftable))
667- return hash
660+ val converted = new java.util.HashMap [AnyRef , AnyRef ]()
661+ try AEStackFactory .convert(aeItem, converted) catch {
662+ case t : Throwable => OpenComputers .log.warn(" Type converter threw an exception." , t)
668663 }
669- null
664+ hashConvert(converted)
670665 }
671666
672667 private def loadController (nbt : NBTTagCompound , f : TileEntity with IGridProxyable with IActionHost => Unit ): Unit = {
0 commit comments