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
@@ -673,7 +673,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
else if( itemStack.getStackSize() > 0 )
{
// make sure strange things didn't happen...
if( !adaptor.simulateAdd( itemStack.getItemStack() ).isEmpty() )
if( !adaptor.simulateAdd( itemStack.createItemStack() ).isEmpty() )
{
changed = true;
throw new GridAccessException();
@@ -683,7 +683,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
if( acquired != null )
{
changed = true;
final ItemStack issue = adaptor.addItems( acquired.getItemStack() );
final ItemStack issue = adaptor.addItems( acquired.createItemStack() );
if( !issue.isEmpty() )
{
throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" );
@@ -702,7 +702,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
long diff = toStore.getStackSize();
// make sure strange things didn't happen...
final ItemStack canExtract = adaptor.simulateRemove( (int) diff, toStore.getItemStack(), null );
// TODO: check if OK
final ItemStack canExtract = adaptor.simulateRemove( (int) diff, toStore.getDefinition(), null );
if( canExtract.isEmpty() || canExtract.getCount() != diff )
{
changed = true;
@@ -1118,11 +1119,11 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
if( mode == Actionable.SIMULATE )
{
return AEItemStack.create( adaptor.simulateAdd( acquired.getItemStack() ) );
return AEItemStack.create( adaptor.simulateAdd( acquired.createItemStack() ) );
}
else
{
final IAEItemStack is = AEItemStack.create( adaptor.addItems( acquired.getItemStack() ) );
final IAEItemStack is = AEItemStack.create( adaptor.addItems( acquired.createItemStack() ) );
this.updatePlan( slot );
return is;
}
@@ -83,7 +83,7 @@ public class MultiCraftingTracker
public boolean handleCrafting( final int x, final long itemToCraft, final IAEItemStack ais, final InventoryAdaptor d, final World w, final IGrid g, final ICraftingGrid cg, final IActionSource mySrc )
{
if( ais != null && d.simulateAdd( ais.getItemStack() ).isEmpty() )
if( ais != null && d.simulateAdd( ais.createItemStack() ).isEmpty() )
{
final Future<ICraftingJob> craftingJob = this.getJob( x );
@@ -334,7 +334,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
if( this.outputs != null && this.outputs.length > 0 )
{
return this.outputs[0].getItemStack();
return this.outputs[0].createItemStack();
}
return ItemStack.EMPTY;