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:
+2
-1
@@ -484,7 +484,8 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
{
|
||||
if( ais.getItem() == whatToCraft.getItem() && ( !ais.getItem().getHasSubtypes() || ais.getItemDamage() == whatToCraft.getItemDamage() ) )
|
||||
{
|
||||
if( details.isValidItemForSlot( slotIndex, ais.getItemStack(), world ) )
|
||||
// TODO: check if OK
|
||||
if( details.isValidItemForSlot( slotIndex, ais.createItemStack(), world ) )
|
||||
{
|
||||
return this.craftableItems.get( ais );
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
fuzz = fuzz.copy();
|
||||
fuzz.setStackSize( g.getStackSize() );
|
||||
final IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.SIMULATE, this.machineSrc );
|
||||
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack();
|
||||
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack();
|
||||
|
||||
if( !is.isEmpty() && is.getCount() == g.getStackSize() )
|
||||
{
|
||||
@@ -526,7 +526,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
else
|
||||
{
|
||||
final IAEItemStack ais = this.inventory.extractItems( g.copy(), Actionable.SIMULATE, this.machineSrc );
|
||||
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack();
|
||||
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack();
|
||||
|
||||
if( is.isEmpty() || is.getCount() < g.getStackSize() )
|
||||
{
|
||||
@@ -690,10 +690,10 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
fuzz = fuzz.copy();
|
||||
fuzz.setStackSize( input[x].getStackSize() );
|
||||
|
||||
if( details.isValidItemForSlot( x, fuzz.getItemStack(), this.getWorld() ) )
|
||||
if( details.isValidItemForSlot( x, fuzz.createItemStack(), this.getWorld() ) )
|
||||
{
|
||||
final IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.MODULATE, this.machineSrc );
|
||||
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack();
|
||||
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack();
|
||||
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
@@ -708,7 +708,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
else
|
||||
{
|
||||
final IAEItemStack ais = this.inventory.extractItems( input[x].copy(), Actionable.MODULATE, this.machineSrc );
|
||||
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack();
|
||||
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.createItemStack();
|
||||
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
@@ -1217,7 +1217,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
if( pattern != null && pattern.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
final ICraftingPatternItem cpi = (ICraftingPatternItem) pattern.getItem();
|
||||
final ICraftingPatternDetails details = cpi.getPatternForItem( pattern.getItemStack(), this.getWorld() );
|
||||
final ICraftingPatternDetails details = cpi.getPatternForItem( pattern.createItemStack(), this.getWorld() );
|
||||
if( details != null )
|
||||
{
|
||||
final TaskProgress tp = new TaskProgress();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user