Untested NEI Packet Update, this should hopefully fix issue with metadata ( not ore dictionary crafting, as well as some non oredictionary group issues like Pure vs Not Pure quartz.

This commit is contained in:
AlgorithmX2
2014-08-19 15:00:32 -05:00
parent ee7869a61a
commit 6e7721c36b
2 changed files with 50 additions and 11 deletions
+41 -7
View File
@@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
@@ -37,7 +38,7 @@ import appeng.util.item.AEItemStack;
public class PacketNEIRecipe extends AppEngPacket public class PacketNEIRecipe extends AppEngPacket
{ {
ItemStack[] recipe; ItemStack[][] recipe;
// automatic. // automatic.
public PacketNEIRecipe(ByteBuf stream) throws IOException { public PacketNEIRecipe(ByteBuf stream) throws IOException {
@@ -46,10 +47,18 @@ public class PacketNEIRecipe extends AppEngPacket
NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes ); NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes );
if ( comp != null ) if ( comp != null )
{ {
recipe = new ItemStack[9]; recipe = new ItemStack[9][];
for (int x = 0; x < recipe.length; x++) 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 ); InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
for (int x = 0; x < 9; x++) 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 ); IRecipe r = Platform.findMatchingRecipe( ic, pmp.worldObj );
if ( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) ) if ( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
@@ -124,8 +138,28 @@ public class PacketNEIRecipe extends AppEngPacket
if ( PatternItem != null && currentItem == null ) if ( PatternItem != null && currentItem == null )
{ {
craftMatrix.setInventorySlotContents( x, Platform.extractItemsByRecipe( energy, cct.getSource(), stor, player.worldObj, r, ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), stor, player.worldObj, r,
is, ic, PatternItem, x, all, realForFake ) ); 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 ); con.onCraftMatrixChanged( craftMatrix );
@@ -55,7 +55,7 @@ public class NEICraftingHandler implements IOverlayHandler
PositionedStack pstack = ingredients.get( i ); PositionedStack pstack = ingredients.get( i );
int col = (pstack.relx - 25) / 18; int col = (pstack.relx - 25) / 18;
int row = (pstack.rely - 6) / 18; int row = (pstack.rely - 6) / 18;
if ( pstack.item != null ) if ( pstack.items != null && pstack.items.length > 0 )
{ {
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots) for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots)
{ {
@@ -64,9 +64,14 @@ public class NEICraftingHandler implements IOverlayHandler
Slot ctSlot = (Slot) slot; Slot ctSlot = (Slot) slot;
if ( ctSlot.getSlotIndex() == col + row * 3 ) if ( ctSlot.getSlotIndex() == col + row * 3 )
{ {
NBTTagCompound inbt = new NBTTagCompound(); NBTTagList ilist = new NBTTagList();
pstack.item.writeToNBT( inbt ); for ( int x = 0; x < pstack.items.length; x++ )
recipe.setTag( "#" + ctSlot.getSlotIndex(), inbt ); {
NBTTagCompound inbt = new NBTTagCompound();
pstack.items[x].writeToNBT( inbt );
ilist.addtag( inbt );
}
recipe.setTag( "#" + ctSlot.getSlotIndex(), ilist );
break; break;
} }
} }