Use IItemHandler instead of IInventory internally (#2971)

* Use IItemHandler instead of IInventory internally
This commit is contained in:
fscan
2017-07-28 22:04:32 +02:00
committed by yueh
parent c077840988
commit 52d28fabe3
156 changed files with 2410 additions and 4604 deletions
@@ -30,14 +30,13 @@ import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
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 net.minecraft.util.EnumFacing;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.config.Actionable;
@@ -58,6 +57,8 @@ import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.WrapperInvItemHandler;
import appeng.util.item.AEItemStack;
import appeng.util.prioritylist.IPartitionList;
@@ -128,8 +129,8 @@ public class PacketJEIRecipe extends AppEngPacket
final IStorageGrid inv = grid.getCache( IStorageGrid.class );
final IEnergyGrid energy = grid.getCache( IEnergyGrid.class );
final ISecurityGrid security = grid.getCache( ISecurityGrid.class );
final IInventory craftMatrix = cct.getInventoryByName( "crafting" );
final IInventory playerInventory = cct.getInventoryByName( "player" );
final IItemHandler craftMatrix = cct.getInventoryByName( "crafting" );
final IItemHandler playerInventory = cct.getInventoryByName( "player" );
final Actionable realForFake = cct.useRealItems() ? Actionable.MODULATE : Actionable.SIMULATE;
@@ -156,7 +157,7 @@ public class PacketJEIRecipe extends AppEngPacket
final IItemList all = storage.getStorageList();
final IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
for( int x = 0; x < craftMatrix.getSizeInventory(); x++ )
for( int x = 0; x < craftMatrix.getSlots(); x++ )
{
final ItemStack patternItem = testInv.getStackInSlot( x );
@@ -176,11 +177,11 @@ public class PacketJEIRecipe extends AppEngPacket
cct.getActionSource() );
if( out != null )
{
craftMatrix.setInventorySlotContents( x, out.getItemStack() );
ItemHandlerUtil.setStackInSlot( craftMatrix, x, out.getItemStack() );
}
else
{
craftMatrix.setInventorySlotContents( x, ItemStack.EMPTY );
ItemHandlerUtil.setStackInSlot( craftMatrix, x, ItemStack.EMPTY );
}
currentItem = craftMatrix.getStackInSlot( x );
@@ -224,10 +225,10 @@ public class PacketJEIRecipe extends AppEngPacket
whichItem = this.extractItemFromPlayerInventory( player, realForFake, patternItem );
}
craftMatrix.setInventorySlotContents( x, whichItem );
ItemHandlerUtil.setStackInSlot( craftMatrix, x, whichItem );
}
}
con.onCraftMatrixChanged( craftMatrix );
con.onCraftMatrixChanged( new WrapperInvItemHandler( craftMatrix ) );
}
}
}
@@ -245,7 +246,7 @@ public class PacketJEIRecipe extends AppEngPacket
*/
private ItemStack extractItemFromPlayerInventory( final EntityPlayer player, final Actionable mode, final ItemStack patternItem )
{
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player );
final AEItemStack request = AEItemStack.create( patternItem );
final boolean isSimulated = mode == Actionable.SIMULATE;
final boolean checkFuzzy = request.isOre() || patternItem.getItemDamage() == OreDictionary.WILDCARD_VALUE || patternItem.hasTagCompound() || patternItem
@@ -77,7 +77,8 @@ public class PacketPartPlacement extends AppEngPacket
final EntityPlayerMP sender = (EntityPlayerMP) player;
AppEng.proxy.updateRenderMode( sender );
PartPlacement.setEyeHeight( this.eyeHeight );
PartPlacement.place( sender.getHeldItem( this.hand ), new BlockPos( this.x, this.y, this.z ), EnumFacing.VALUES[this.face], sender, this.hand, sender.world,
PartPlacement.place( sender.getHeldItem( this.hand ), new BlockPos( this.x, this.y, this.z ), EnumFacing.VALUES[this.face], sender, this.hand,
sender.world,
PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 );
AppEng.proxy.updateRenderMode( null );
}
@@ -26,7 +26,7 @@ import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.storage.data.IAEItemStack;
@@ -72,7 +72,7 @@ public class PacketPatternSlot extends AppEngPacket
}
// api
public PacketPatternSlot( final IInventory pat, final IAEItemStack slotItem, final boolean shift ) throws IOException
public PacketPatternSlot( final IItemHandler pat, final IAEItemStack slotItem, final boolean shift ) throws IOException
{
this.slotItem = slotItem;