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:
@@ -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 )
|
||||
|
||||
Reference in New Issue
Block a user