Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
+109 -109
View File
@@ -18,12 +18,14 @@
package appeng.util.item;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import appeng.api.storage.data.IAEStack;
public abstract class AEStack<StackType extends IAEStack> implements IAEStack<StackType>
{
@@ -31,10 +33,67 @@ public abstract class AEStack<StackType extends IAEStack> implements IAEStack<St
protected long stackSize;
protected long countRequestable;
@Override
public boolean isMeaningful()
static long getPacketValue( byte type, ByteBuf tag )
{
return this.stackSize != 0 || this.countRequestable > 0 || this.isCraftable;
if( type == 0 )
{
long l = tag.readByte();
l -= Byte.MIN_VALUE;
return l;
}
else if( type == 1 )
{
long l = tag.readShort();
l -= Short.MIN_VALUE;
return l;
}
else if( type == 2 )
{
long l = tag.readInt();
l -= Integer.MIN_VALUE;
return l;
}
return tag.readLong();
}
@Override
public long getStackSize()
{
return this.stackSize;
}
@Override
public StackType setStackSize( long ss )
{
this.stackSize = ss;
return (StackType) this;
}
@Override
public long getCountRequestable()
{
return this.countRequestable;
}
@Override
public StackType setCountRequestable( long countRequestable )
{
this.countRequestable = countRequestable;
return (StackType) this;
}
@Override
public boolean isCraftable()
{
return this.isCraftable;
}
@Override
public StackType setCraftable( boolean isCraftable )
{
this.isCraftable = isCraftable;
return (StackType) this;
}
@Override
@@ -48,127 +107,39 @@ public abstract class AEStack<StackType extends IAEStack> implements IAEStack<St
}
@Override
public long getStackSize()
public boolean isMeaningful()
{
return this.stackSize;
return this.stackSize != 0 || this.countRequestable > 0 || this.isCraftable;
}
@Override
public StackType setStackSize(long ss)
{
this.stackSize = ss;
return (StackType) this;
}
@Override
public long getCountRequestable()
{
return this.countRequestable;
}
@Override
public StackType setCountRequestable(long countRequestable)
{
this.countRequestable = countRequestable;
return (StackType) this;
}
@Override
public boolean isCraftable()
{
return this.isCraftable;
}
@Override
public StackType setCraftable(boolean isCraftable)
{
this.isCraftable = isCraftable;
return (StackType) this;
}
@Override
public void decStackSize(long i)
{
this.stackSize -= i;
}
@Override
public void incStackSize(long i)
public void incStackSize( long i )
{
this.stackSize += i;
}
@Override
public void decCountRequestable(long i)
public void decStackSize( long i )
{
this.stackSize -= i;
}
@Override
public void incCountRequestable( long i )
{
this.countRequestable += i;
}
@Override
public void decCountRequestable( long i )
{
this.countRequestable -= i;
}
@Override
public void incCountRequestable(long i)
public void writeToPacket( ByteBuf i ) throws IOException
{
this.countRequestable += i;
}
void putPacketValue(ByteBuf tag, long num)
{
if ( num <= 255 )
tag.writeByte( (byte) (num + Byte.MIN_VALUE) );
else if ( num <= 65535 )
tag.writeShort( (short) (num + Short.MIN_VALUE) );
else if ( num <= 4294967295L )
tag.writeInt( (int) (num + Integer.MIN_VALUE) );
else
tag.writeLong( num );
}
static long getPacketValue(byte type, ByteBuf tag)
{
if ( type == 0 )
{
long l = tag.readByte();
l -= Byte.MIN_VALUE;
return l;
}
else if ( type == 1 )
{
long l = tag.readShort();
l -= Short.MIN_VALUE;
return l;
}
else if ( type == 2 )
{
long l = tag.readInt();
l -= Integer.MIN_VALUE;
return l;
}
return tag.readLong();
}
byte getType(long num)
{
if ( num <= 255 )
return 0;
else if ( num <= 65535 )
return 1;
else if ( num <= 4294967295L )
return 2;
else
return 3;
}
abstract void writeIdentity(ByteBuf i) throws IOException;
abstract void readNBT(ByteBuf i) throws IOException;
abstract boolean hasTagCompound();
@Override
public void writeToPacket(ByteBuf i) throws IOException
{
byte mask = (byte) (this.getType( 0 ) | (this.getType( this.stackSize ) << 2) | (this.getType( this.countRequestable ) << 4) | ((byte) (this.isCraftable ? 1 : 0) << 6) | (this.hasTagCompound() ? 1
: 0) << 7);
byte mask = (byte) ( this.getType( 0 ) | ( this.getType( this.stackSize ) << 2 ) | ( this.getType( this.countRequestable ) << 4 ) | ( (byte) ( this.isCraftable ? 1 : 0 ) << 6 ) | ( this.hasTagCompound() ? 1 : 0 ) << 7 );
i.writeByte( mask );
this.writeIdentity( i );
@@ -180,4 +151,33 @@ public abstract class AEStack<StackType extends IAEStack> implements IAEStack<St
this.putPacketValue( i, this.countRequestable );
}
byte getType( long num )
{
if( num <= 255 )
return 0;
else if( num <= 65535 )
return 1;
else if( num <= 4294967295L )
return 2;
else
return 3;
}
abstract boolean hasTagCompound();
abstract void writeIdentity( ByteBuf i ) throws IOException;
abstract void readNBT( ByteBuf i ) throws IOException;
void putPacketValue( ByteBuf tag, long num )
{
if( num <= 255 )
tag.writeByte( (byte) ( num + Byte.MIN_VALUE ) );
else if( num <= 65535 )
tag.writeShort( (short) ( num + Short.MIN_VALUE ) );
else if( num <= 4294967295L )
tag.writeInt( (int) ( num + Integer.MIN_VALUE ) );
else
tag.writeLong( num );
}
}