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:
@@ -393,7 +393,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
final double y = add.getY();
|
||||
final double z = add.getZ();
|
||||
|
||||
final EntityItem overflowEntity = new EntityItem( w, x, y, z, overflow.getItemStack() );
|
||||
final EntityItem overflowEntity = new EntityItem( w, x, y, z, overflow.createItemStack() );
|
||||
overflowEntity.motionX = 0;
|
||||
overflowEntity.motionY = 0;
|
||||
overflowEntity.motionZ = 0;
|
||||
|
||||
@@ -266,9 +266,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
{
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
return AEItemStack.create( d.addItems( items.getItemStack() ) );
|
||||
return AEItemStack.create( d.addItems( items.createItemStack() ) );
|
||||
}
|
||||
return AEItemStack.create( d.simulateAdd( items.getItemStack() ) );
|
||||
return AEItemStack.create( d.simulateAdd( items.createItemStack() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
|
||||
private void pushItemIntoTarget( final InventoryAdaptor d, final IEnergyGrid energy, final IMEInventory<IAEItemStack> inv, IAEItemStack ais )
|
||||
{
|
||||
final ItemStack is = ais.getItemStack();
|
||||
final ItemStack is = ais.createItemStack();
|
||||
is.setCount( (int) this.itemToSend );
|
||||
|
||||
final ItemStack o = d.simulateAdd( is );
|
||||
@@ -320,7 +320,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
{
|
||||
this.itemToSend -= itemsToAdd.getStackSize();
|
||||
|
||||
final ItemStack failed = d.addItems( itemsToAdd.getItemStack() );
|
||||
final ItemStack failed = d.addItems( itemsToAdd.createItemStack() );
|
||||
if( !failed.isEmpty() )
|
||||
{
|
||||
ais.setStackSize( failed.getCount() );
|
||||
|
||||
@@ -436,7 +436,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
|
||||
final YesNo placeBlock = (YesNo) this.getConfigManager().getSetting( Settings.PLACE_BLOCK );
|
||||
|
||||
final ItemStack is = input.getItemStack();
|
||||
final ItemStack is = input.createItemStack();
|
||||
final Item i = is.getItem();
|
||||
|
||||
long maxStorage = Math.min( input.getStackSize(), is.getMaxStackSize() );
|
||||
|
||||
@@ -218,12 +218,12 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getItemStack(), fzMode,
|
||||
newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), fzMode,
|
||||
this.configDestination( inv ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
newItems = myAdaptor.removeItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getItemStack(), this.configDestination( inv ) );
|
||||
newItems = myAdaptor.removeItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), this.configDestination( inv ) );
|
||||
}
|
||||
|
||||
if( !newItems.isEmpty() )
|
||||
@@ -245,7 +245,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
|
||||
if( failed != null )
|
||||
{
|
||||
myAdaptor.addItems( failed.getItemStack() );
|
||||
myAdaptor.addItems( failed.createItemStack() );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -272,7 +272,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
||||
}
|
||||
else
|
||||
{
|
||||
itemStackToImport = whatToImport.getItemStack();
|
||||
itemStackToImport = whatToImport.getDefinition();
|
||||
}
|
||||
|
||||
final IAEItemStack itemAmountNotStorable;
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.parts.automation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
|
||||
|
||||
@@ -43,7 +42,7 @@ public class StackUpgradeInventory extends UpgradeInventory
|
||||
|
||||
for( final ItemStack is : upgrades.getSupported().keySet() )
|
||||
{
|
||||
if( Platform.itemComparisons().isEqualItem( this.stack, is ) )
|
||||
if( ItemStack.areItemsEqual( this.stack, is ) )
|
||||
{
|
||||
max = upgrades.getSupported().get( is );
|
||||
break;
|
||||
|
||||
@@ -68,7 +68,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
@Override
|
||||
public IAEItemStack injectItems( IAEItemStack iox, Actionable type, IActionSource src )
|
||||
{
|
||||
ItemStack orgInput = iox.getItemStack();
|
||||
ItemStack orgInput = iox.createItemStack();
|
||||
ItemStack remaining = orgInput;
|
||||
|
||||
int slotCount = this.itemHandler.getSlots();
|
||||
@@ -99,7 +99,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, IActionSource src )
|
||||
{
|
||||
|
||||
ItemStack requestedItemStack = request.getItemStack();
|
||||
ItemStack requestedItemStack = request.createItemStack();
|
||||
int remainingSize = requestedItemStack.getCount();
|
||||
|
||||
// Use this to gather the requested items
|
||||
|
||||
@@ -160,11 +160,11 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if ( hand == EnumHand.OFF_HAND )
|
||||
if( hand == EnumHand.OFF_HAND )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
final ItemStack is = player.getHeldItem( hand );
|
||||
|
||||
// UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor( is.getItem() );
|
||||
@@ -265,7 +265,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
break;
|
||||
}
|
||||
|
||||
if( !newType.isEmpty() && !Platform.itemComparisons().isEqualItem( newType, this.getItemStack() ) )
|
||||
if( !newType.isEmpty() && !ItemStack.areItemsEqual( newType, this.getItemStack() ) )
|
||||
{
|
||||
final boolean oldOutput = this.isOutput();
|
||||
final short myFreq = this.getFrequency();
|
||||
|
||||
@@ -93,7 +93,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
if( item.isEmpty() && this.getDisplayed() != null )
|
||||
{
|
||||
ModeB = true;
|
||||
item = ( (IAEItemStack) this.getDisplayed() ).getItemStack();
|
||||
item = ( (IAEItemStack) this.getDisplayed() ).createItemStack();
|
||||
}
|
||||
|
||||
if( !item.isEmpty() )
|
||||
@@ -119,7 +119,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
final IAEItemStack insertItem = input.copy();
|
||||
insertItem.setStackSize( targetStack.getCount() );
|
||||
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, insertItem, new PlayerSource( player, this ) );
|
||||
player.inventory.setInventorySlotContents( x, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.getItemStack() );
|
||||
player.inventory.setInventorySlotContents( x, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
{
|
||||
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
|
||||
player.inventory.setInventorySlotContents( player.inventory.currentItem,
|
||||
failedToInsert == null ? ItemStack.EMPTY : failedToInsert.getItemStack() );
|
||||
failedToInsert == null ? ItemStack.EMPTY : failedToInsert.createItemStack() );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
@@ -154,13 +154,13 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
final IMEMonitor<IAEItemStack> cell = this.getProxy().getStorage().getItemInventory();
|
||||
|
||||
final ItemStack is = input.getItemStack();
|
||||
final ItemStack is = input.createItemStack();
|
||||
input.setStackSize( is.getMaxStackSize() );
|
||||
|
||||
final IAEItemStack retrieved = Platform.poweredExtraction( energy, cell, input, new PlayerSource( player, this ) );
|
||||
if( retrieved != null )
|
||||
{
|
||||
ItemStack newItems = retrieved.getItemStack();
|
||||
ItemStack newItems = retrieved.createItemStack();
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player );
|
||||
newItems = adaptor.addItems( newItems );
|
||||
if( !newItems.isEmpty() )
|
||||
|
||||
@@ -137,13 +137,13 @@ public class PartPatternTerminal extends AbstractPartTerminal
|
||||
for( int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++ )
|
||||
{
|
||||
final IAEItemStack item = details.getInputs()[x];
|
||||
this.crafting.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.getItemStack() );
|
||||
this.crafting.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.createItemStack() );
|
||||
}
|
||||
|
||||
for( int x = 0; x < this.output.getSlots() && x < details.getOutputs().length; x++ )
|
||||
{
|
||||
final IAEItemStack item = details.getOutputs()[x];
|
||||
this.output.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.getItemStack() );
|
||||
this.output.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.createItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user