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
+12 -9
View File
@@ -26,7 +26,7 @@ import io.netty.buffer.ByteBuf;
import appeng.api.storage.data.IAEStack;
public abstract class AEStack<StackType extends IAEStack> implements IAEStack<StackType>
public abstract class AEStack<StackType extends IAEStack<StackType>> implements IAEStack<StackType>
{
private boolean isCraftable;
@@ -106,6 +106,14 @@ public abstract class AEStack<StackType extends IAEStack> implements IAEStack<St
return (StackType) this;
}
@Override
public StackType empty()
{
final StackType dup = this.copy();
dup.reset();
return dup;
}
@Override
public boolean isMeaningful()
{
@@ -144,15 +152,14 @@ public abstract class AEStack<StackType extends IAEStack> implements IAEStack<St
i.writeByte( mask );
this.writeIdentity( i );
this.writeToStream( i );
this.readNBT( i );
// putPacketValue( i, priority );
this.putPacketValue( i, this.stackSize );
this.putPacketValue( i, this.countRequestable );
}
protected abstract void writeToStream( final ByteBuf data ) throws IOException;
private byte getType( final long num )
{
if( num <= 255 )
@@ -175,10 +182,6 @@ public abstract class AEStack<StackType extends IAEStack> implements IAEStack<St
abstract boolean hasTagCompound();
abstract void writeIdentity( ByteBuf i ) throws IOException;
abstract void readNBT( ByteBuf i ) throws IOException;
private void putPacketValue( final ByteBuf tag, final long num )
{
if( num <= 255 )