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
@@ -352,12 +352,11 @@ public class GuiCraftConfirm extends AEBaseGui
final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
final int posY = y * offY + yo;
final ItemStack is = refStack.getItemStack();
is.setCount( 1 );
final ItemStack is = refStack.asItemStackRepresentation();
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
dspToolTip = Platform.getItemDisplayName( refStack );
if( lineList.size() > 0 )
{
@@ -309,12 +309,11 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
final int posX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
final int posY = y * offY + ITEMSTACK_TOP_OFFSET;
final ItemStack is = refStack.getItemStack();
is.setCount( 1 );
final ItemStack is = refStack.asItemStackRepresentation();
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
dspToolTip = Platform.getItemDisplayName( refStack );
if( lineList.size() > 0 )
{
@@ -180,7 +180,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
if( this.tooltip == z - viewStart )
{
toolTip = Platform.getItemDisplayName( this.repo.getItem( z ) );
toolTip = Platform.getItemDisplayName( refStack );
toolTip += ( '\n' + GuiText.Installed.getLocal() + ": " + ( refStack.getStackSize() ) );
if( refStack.getCountRequestable() > 0 )
@@ -192,7 +192,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
toolPosY = y * 18 + yo;
}
this.drawItem( posX, posY, this.repo.getItem( z ) );
this.drawItem( posX, posY, refStack.asItemStackRepresentation() );
x++;
@@ -42,7 +42,7 @@ public class InternalSlotME
ItemStack getStack()
{
return this.repo.getItem( this.offset );
return this.getAEStack() == null ? ItemStack.EMPTY : this.getAEStack().asItemStackRepresentation();
}
IAEItemStack getAEStack()
@@ -50,7 +50,6 @@ public class ItemRepo
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
private final ArrayList<IAEItemStack> view = new ArrayList<>();
private final ArrayList<ItemStack> dsp = new ArrayList<>();
private final IScrollSource src;
private final ISortSource sortSrc;
@@ -78,17 +77,6 @@ public class ItemRepo
return this.view.get( idx );
}
public ItemStack getItem( int idx )
{
idx += this.src.getCurrentScroll() * this.rowSize;
if( idx >= this.dsp.size() )
{
return ItemStack.EMPTY;
}
return this.dsp.get( idx );
}
void setSearch( final String search )
{
this.searchString = search == null ? "" : search;
@@ -118,10 +106,8 @@ public class ItemRepo
public void updateView()
{
this.view.clear();
this.dsp.clear();
this.view.ensureCapacity( this.list.size() );
this.dsp.ensureCapacity( this.list.size() );
final Enum viewMode = this.sortSrc.getSortDisplay();
final Enum searchMode = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE );
@@ -235,13 +221,6 @@ public class ItemRepo
{
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME );
}
for( final IAEItemStack is : this.view )
{
final ItemStack displayStack = is.getItemStack();
displayStack.setCount( 1 );
this.dsp.add( displayStack );
}
}
private void updateJEI( String filter )
@@ -126,8 +126,7 @@ public class TesrRenderHelper
*/
public static void renderItem2dWithAmount( IAEItemStack itemStack, float itemScale, float spacing )
{
final ItemStack renderStack = itemStack.getItemStack();
renderStack.setCount( 1 );
final ItemStack renderStack = itemStack.asItemStackRepresentation();
TesrRenderHelper.renderItem2d( renderStack, itemScale );
@@ -46,8 +46,7 @@ public class AssemblerFX extends Particle implements ICanDie
this.motionY = 0;
this.motionZ = 0;
this.speed = speed;
final ItemStack displayItem = is.getItemStack();
displayItem.setCount( 1 );
final ItemStack displayItem = is.asItemStackRepresentation();
this.fi = new EntityFloatingItem( this, w, x, y, z, displayItem );
w.spawnEntity( this.fi );
this.particleMaxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;