diff --git a/core/sync/packets/PacketNEIRecipe.java b/core/sync/packets/PacketNEIRecipe.java index 1578b1793..783339d41 100644 --- a/core/sync/packets/PacketNEIRecipe.java +++ b/core/sync/packets/PacketNEIRecipe.java @@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import appeng.api.config.Actionable; import appeng.api.config.SecurityPermissions; import appeng.api.networking.IGrid; @@ -37,7 +38,7 @@ import appeng.util.item.AEItemStack; public class PacketNEIRecipe extends AppEngPacket { - ItemStack[] recipe; + ItemStack[][] recipe; // automatic. public PacketNEIRecipe(ByteBuf stream) throws IOException { @@ -46,10 +47,18 @@ public class PacketNEIRecipe extends AppEngPacket NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes ); if ( comp != null ) { - recipe = new ItemStack[9]; + recipe = new ItemStack[9][]; for (int x = 0; x < recipe.length; x++) { - recipe[x] = ItemStack.loadItemStackFromNBT( comp.getCompoundTag( "#" + x ) ); + NBTTagList list = comp.getTagList( "#"+x, 10 ); + if ( list.tagCount() > 0 ) + { + recipe[x] = new ItemStack[ list.tagCount() ]; + for ( int y = 0; y < list.tagCount(); y++ ) + { + recipe[x][y] = ItemStack.loadItemStackFromNBT( list.getCompoundTagAt(y) ); + } + } } } } @@ -81,8 +90,13 @@ public class PacketNEIRecipe extends AppEngPacket { InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 ); for (int x = 0; x < 9; x++) - ic.setInventorySlotContents( x, recipe[x] ); - + { + if ( recipe[x] != null && recipe[x].length > 0 ) + { + ic.setInventorySlotContents( x, recipe[x][0] ); + } + } + IRecipe r = Platform.findMatchingRecipe( ic, pmp.worldObj ); if ( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) ) @@ -124,8 +138,28 @@ public class PacketNEIRecipe extends AppEngPacket if ( PatternItem != null && currentItem == null ) { - craftMatrix.setInventorySlotContents( x, Platform.extractItemsByRecipe( energy, cct.getSource(), stor, player.worldObj, r, - is, ic, PatternItem, x, all, realForFake ) ); + ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), stor, player.worldObj, r, + is, ic, PatternItem, x, all, realForFake ); + + if ( whichItem == null ) + { + for ( int y = 0; y < recipe[x].length; y++ ) + { + IAEItemStack request = AEItemStack.create( recipe[x][y] ); + if ( request != null ) + { + request.setStackSize( 1 ); + IAEItemStack out = Platform.poweredExtraction( energy, stor, request, cct.getSource() ); + if ( out != null ) + { + whichItem = out.getItemStack(); + break; + } + } + } + } + + craftMatrix.setInventorySlotContents( x, whichItem ); } } con.onCraftMatrixChanged( craftMatrix ); diff --git a/integration/modules/NEIHelpers/NEICraftingHandler.java b/integration/modules/NEIHelpers/NEICraftingHandler.java index bef183794..82f96de40 100644 --- a/integration/modules/NEIHelpers/NEICraftingHandler.java +++ b/integration/modules/NEIHelpers/NEICraftingHandler.java @@ -55,7 +55,7 @@ public class NEICraftingHandler implements IOverlayHandler PositionedStack pstack = ingredients.get( i ); int col = (pstack.relx - 25) / 18; int row = (pstack.rely - 6) / 18; - if ( pstack.item != null ) + if ( pstack.items != null && pstack.items.length > 0 ) { for (Slot slot : (List) gui.inventorySlots.inventorySlots) { @@ -64,9 +64,14 @@ public class NEICraftingHandler implements IOverlayHandler Slot ctSlot = (Slot) slot; if ( ctSlot.getSlotIndex() == col + row * 3 ) { - NBTTagCompound inbt = new NBTTagCompound(); - pstack.item.writeToNBT( inbt ); - recipe.setTag( "#" + ctSlot.getSlotIndex(), inbt ); + NBTTagList ilist = new NBTTagList(); + for ( int x = 0; x < pstack.items.length; x++ ) + { + NBTTagCompound inbt = new NBTTagCompound(); + pstack.items[x].writeToNBT( inbt ); + ilist.addtag( inbt ); + } + recipe.setTag( "#" + ctSlot.getSlotIndex(), ilist ); break; } }