Rework AEItemStack (#3091)

* Use itemstack as itemdef
* HIGH_TAG/LOW_TAG should be compared both directions
* Remove getTagCompound
* Make Itemlist implementation independent
* Cache item id for performance reasons
* Add preconditions to saveguard against external meddling
* Chache itemDamage
* Remove IAEStackSearchKey for now, rename getDisplayStack
This commit is contained in:
fscan
2017-09-30 17:18:30 +02:00
committed by yueh
parent 2ed7a5598a
commit 1e15b23506
75 changed files with 559 additions and 1512 deletions
@@ -240,8 +240,8 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
{
if( i.hasNext() )
{
final ItemStack g = i.next().getItemStack();
g.setCount( 1 );
// TODO: check if ok
final ItemStack g = i.next().asItemStackRepresentation();
ItemHandlerUtil.setStackInSlot( inv, x, g );
}
else
@@ -26,7 +26,6 @@ import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.util.Platform;
public class ContainerMEPortableCell extends ContainerMEMonitorable
@@ -67,7 +66,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
{
if( !currentItem.isEmpty() )
{
if( Platform.itemComparisons().isEqualItem( this.civ.getItemStack(), currentItem ) )
if( ItemStack.areItemsEqual( this.civ.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.civ.getItemStack() );
}
@@ -73,7 +73,7 @@ public class ContainerNetworkTool extends AEBaseContainer
{
if( !currentItem.isEmpty() )
{
if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) )
if( ItemStack.areItemsEqual( this.toolInv.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
}
@@ -364,7 +364,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
inv = playerInv;
}
if( !inv.simulateAdd( out.getItemStack() ).isEmpty() )
if( !inv.simulateAdd( out.createItemStack() ).isEmpty() )
{
return;
}
@@ -374,7 +374,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
if( extracted != null )
{
inv.addItems( extracted.getItemStack() );
inv.addItems( extracted.createItemStack() );
if( p instanceof EntityPlayerMP )
{
this.updateHeld( (EntityPlayerMP) p );
@@ -388,7 +388,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < 9; x++ )
{
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].getItemStack() );
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].createItemStack() );
}
final IRecipe r = CraftingManager.findMatchingRecipe( ic, p.world );
@@ -73,7 +73,7 @@ public class ContainerQuartzKnife extends AEBaseContainer
{
if( !currentItem.isEmpty() )
{
if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) )
if( ItemStack.areItemsEqual( this.toolInv.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
}
@@ -165,8 +165,8 @@ public class ContainerStorageBus extends ContainerUpgradeable
{
if( i.hasNext() && this.isSlotEnabled( ( x / 9 ) - 2 ) )
{
final ItemStack g = i.next().getItemStack();
g.setCount( 1 );
// TODO: check if ok
final ItemStack g = i.next().asItemStackRepresentation();
ItemHandlerUtil.setStackInSlot( inv, x, g );
}
else
@@ -245,7 +245,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
{
if( !currentItem.isEmpty() )
{
if( Platform.itemComparisons().isEqualItem( this.tbInventory.getItemStack(), currentItem ) )
if( ItemStack.areItemsEqual( this.tbInventory.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.tbSlot, this.tbInventory.getItemStack() );
}