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
@@ -23,7 +23,6 @@ import java.util.HashSet;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;
@@ -218,7 +217,7 @@ public class CellInventory implements ICellInventory
return input;
}
final ItemStack sharedItemStack = input.getItemStack();
final ItemStack sharedItemStack = input.createItemStack();
if( CellInventory.isStorageCell( sharedItemStack ) )
{
@@ -269,11 +268,11 @@ public class CellInventory implements ICellInventory
{
if( input.getStackSize() > remainingItemCount )
{
final ItemStack toReturn = Platform.cloneItemStack( sharedItemStack );
final ItemStack toReturn = sharedItemStack.copy();
toReturn.setCount( sharedItemStack.getCount() - remainingItemCount );
if( mode == Actionable.MODULATE )
{
final ItemStack toWrite = Platform.cloneItemStack( sharedItemStack );
final ItemStack toWrite = sharedItemStack.copy();
toWrite.setCount( remainingItemCount );
this.cellItems.add( AEItemStack.create( toWrite ) );
@@ -368,22 +367,10 @@ public class CellInventory implements ICellInventory
{
itemCount += v.getStackSize();
final NBTBase c = this.tagCompound.getTag( itemSlots[x] );
if( c instanceof NBTTagCompound )
{
v.writeToNBT( (NBTTagCompound) c );
}
else
{
final NBTTagCompound g = new NBTTagCompound();
v.writeToNBT( g );
this.tagCompound.setTag( itemSlots[x], g );
}
final NBTTagCompound g = new NBTTagCompound();
v.writeToNBT( g );
this.tagCompound.setTag( itemSlots[x], g );
/*
* NBTBase tagSlotCount = tagCompound.getTag( itemSlotCount[x] ); if ( tagSlotCount instanceof
* NBTTagInt ) ((NBTTagInt) tagSlotCount).data = (int) v.getStackSize(); else
*/
this.tagCompound.setInteger( itemSlotCount[x], (int) v.getStackSize() );
x++;
@@ -79,11 +79,11 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
if( type == Actionable.SIMULATE )
{
out = this.adaptor.simulateAdd( input.getItemStack() );
out = this.adaptor.simulateAdd( input.createItemStack() );
}
else
{
out = this.adaptor.addItems( input.getItemStack() );
out = this.adaptor.addItems( input.createItemStack() );
}
if( type == Actionable.MODULATE )
@@ -109,11 +109,11 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
if( type == Actionable.SIMULATE )
{
out = this.adaptor.simulateRemove( (int) request.getStackSize(), request.getItemStack(), null );
out = this.adaptor.simulateRemove( (int) request.getStackSize(), request.getDefinition(), null );
}
else
{
out = this.adaptor.removeItems( (int) request.getStackSize(), request.getItemStack(), null );
out = this.adaptor.removeItems( (int) request.getStackSize(), request.getDefinition(), null );
}
if( out.isEmpty() )
@@ -51,7 +51,7 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
{
if( this.hasPermission( src ) )
{
if( AEApi.instance().definitions().items().biometricCard().isSameAs( input.getItemStack() ) )
if( AEApi.instance().definitions().items().biometricCard().isSameAs( input.createItemStack() ) )
{
if( this.canAccept( input ) )
{
@@ -143,7 +143,7 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
if( input.getItem() instanceof IBiometricCard )
{
final IBiometricCard tbc = (IBiometricCard) input.getItem();
final GameProfile newUser = tbc.getProfile( input.getItemStack() );
final GameProfile newUser = tbc.getProfile( input.createItemStack() );
final int PlayerID = AEApi.instance().registries().players().getID( newUser );
if( this.securityTile.getOwner() == PlayerID )
@@ -155,7 +155,7 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
{
if( ais.isMeaningful() )
{
final GameProfile thisUser = tbc.getProfile( ais.getItemStack() );
final GameProfile thisUser = tbc.getProfile( ais.createItemStack() );
if( thisUser == newUser )
{
return false;