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
+12 -45
View File
@@ -103,7 +103,6 @@ import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IAETagCompound;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
@@ -123,7 +122,6 @@ import appeng.me.helpers.AENetworkProxy;
import appeng.util.helpers.ItemComparisonHelper;
import appeng.util.helpers.P2PHelper;
import appeng.util.item.AEItemStack;
import appeng.util.item.AESharedNBT;
import appeng.util.prioritylist.IPartitionList;
@@ -571,11 +569,11 @@ public class Platform
}
@SideOnly( Side.CLIENT )
public static List getTooltip( final Object o )
public static List<String> getTooltip( final Object o )
{
if( o == null )
{
return new ArrayList();
return new ArrayList<>();
}
ItemStack itemStack = ItemStack.EMPTY;
@@ -590,7 +588,7 @@ public class Platform
}
else
{
return new ArrayList();
return new ArrayList<>();
}
try
@@ -601,7 +599,7 @@ public class Platform
}
catch( final Exception errB )
{
return new ArrayList();
return new ArrayList<>();
}
}
@@ -661,32 +659,6 @@ public class Platform
}
}
public static boolean hasSpecialComparison( final IAEItemStack willAdd )
{
if( willAdd == null )
{
return false;
}
final IAETagCompound tag = willAdd.getTagCompound();
if( tag != null && tag.getSpecialComparison() != null )
{
return true;
}
return false;
}
public static boolean hasSpecialComparison( final ItemStack willAdd )
{
if( AESharedNBT.isShared( willAdd.getTagCompound() ) )
{
if( ( (IAETagCompound) willAdd.getTagCompound() ).getSpecialComparison() != null )
{
return true;
}
}
return false;
}
public static boolean isWrench( final EntityPlayer player, final ItemStack eq, final BlockPos pos )
{
if( !eq.isEmpty() )
@@ -1475,7 +1447,7 @@ public class Platform
final IAEItemStack ae_ext = src.extractItems( ae_req, realForFake, mySrc );
if( ae_ext != null )
{
final ItemStack extracted = ae_ext.getItemStack();
final ItemStack extracted = ae_ext.createItemStack();
if( !extracted.isEmpty() )
{
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG );
@@ -1484,21 +1456,21 @@ public class Platform
}
}
final boolean checkFuzzy = ae_req.isOre() || providedTemplate.getItemDamage() == OreDictionary.WILDCARD_VALUE || providedTemplate
final boolean checkFuzzy = ae_req.getOre().isPresent() || providedTemplate.getItemDamage() == OreDictionary.WILDCARD_VALUE || providedTemplate
.hasTagCompound() || providedTemplate.isItemStackDamageable();
if( items != null && checkFuzzy )
{
for( final IAEItemStack x : items )
{
final ItemStack sh = x.getItemStack();
if( ( Platform.itemComparisons().isEqualItemType( providedTemplate,
sh ) || ae_req.sameOre( x ) ) && !Platform.itemComparisons().isEqualItem( sh, output ) )
final ItemStack sh = x.getDefinition();
if( ( Platform.itemComparisons().isEqualItemType( providedTemplate, sh ) || ae_req.sameOre( x ) ) && !ItemStack.areItemsEqual( sh,
output ) )
{ // Platform.isSameItemType( sh, providedTemplate )
final ItemStack cp = Platform.cloneItemStack( sh );
final ItemStack cp = sh.copy();
cp.setCount( 1 );
ci.setInventorySlotContents( slot, cp );
if( r.matches( ci, w ) && Platform.itemComparisons().isEqualItem( r.getCraftingResult( ci ), output ) )
if( r.matches( ci, w ) && ItemStack.areItemsEqual( r.getCraftingResult( ci ), output ) )
{
final IAEItemStack ax = x.copy();
ax.setStackSize( 1 );
@@ -1508,7 +1480,7 @@ public class Platform
if( ex != null )
{
energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG );
return ex.getItemStack();
return ex.createItemStack();
}
}
}
@@ -1520,11 +1492,6 @@ public class Platform
return ItemStack.EMPTY;
}
public static ItemStack cloneItemStack( final ItemStack a )
{
return a.copy();
}
public static ItemStack getContainerItem( final ItemStack stackInSlot )
{
if( stackInSlot == null )