Ported to 1.7

This commit is contained in:
AlgorithmX2
2014-02-08 19:34:52 -06:00
parent 30c1deb8cf
commit d50c7f6312
328 changed files with 2209 additions and 2311 deletions
+41 -50
View File
@@ -1,8 +1,9 @@
package appeng.util.item;
import io.netty.buffer.ByteBuf;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
@@ -10,11 +11,7 @@ import java.util.List;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagShort;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
@@ -157,51 +154,45 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
public void writeToNBT(NBTTagCompound i)
{
/*
* Ugly Yes, but it saves a lot in the memory department.
* Mojang Fucked this over ; GC Optimization - Ugly Yes, but it saves a lot in the memory department.
*/
NBTBase id = i.getTag( "id" );
NBTBase Count = i.getTag( "Count" );
// NBTBase Priority = i.getTag( "Priority" );
NBTBase Cnt = i.getTag( "Cnt" );
NBTBase Req = i.getTag( "Req" );
NBTBase Craft = i.getTag( "Craft" );
NBTBase Damage = i.getTag( "Damage" );
/*
* NBTBase id = i.getTag( "id" ); NBTBase Count = i.getTag( "Count" ); NBTBase Cnt = i.getTag( "Cnt" ); NBTBase
* Req = i.getTag( "Req" ); NBTBase Craft = i.getTag( "Craft" ); NBTBase Damage = i.getTag( "Damage" );
*/
if ( id != null && id instanceof NBTTagShort )
((NBTTagShort) id).data = (short) this.def.item.itemID;
else
i.setShort( "id", (short) this.def.item.itemID );
/*
* if ( id != null && id instanceof NBTTagShort ) ((NBTTagShort) id).data = (short) this.def.item.itemID; else
*/
i.setShort( "id", (short) Item.itemRegistry.getIDForObject( this.def.item ) );
// if ( Priority != null && Priority instanceof NBTTagInt )
// ((NBTTagInt) Priority).data = this.priority;
// else
// i.setInteger( "Priority", this.priority );
/*
* if ( Count != null && Count instanceof NBTTagByte ) ((NBTTagByte) Count).data = (byte) 0; else
*/
i.setByte( "Count", (byte) 0 );
if ( Count != null && Count instanceof NBTTagByte )
((NBTTagByte) Count).data = (byte) 0;
else
i.setByte( "Count", (byte) 0 );
/*
* if ( Cnt != null && Cnt instanceof NBTTagLong ) ((NBTTagLong) Cnt).data = this.stackSize; else
*/
i.setLong( "Cnt", this.stackSize );
if ( Cnt != null && Cnt instanceof NBTTagLong )
((NBTTagLong) Cnt).data = this.stackSize;
else
i.setLong( "Cnt", this.stackSize );
/*
* if ( Req != null && Req instanceof NBTTagLong ) ((NBTTagLong) Req).data = this.stackSize; else
*/
i.setLong( "Req", this.getCountRequestable() );
if ( Req != null && Req instanceof NBTTagLong )
((NBTTagLong) Req).data = this.stackSize;
else
i.setLong( "Req", this.getCountRequestable() );
/*
* if ( Craft != null && Craft instanceof NBTTagByte ) ((NBTTagByte) Craft).data = (byte) (this.isCraftable() ?
* 1 : 0); else
*/
i.setBoolean( "Craft", this.isCraftable() );
if ( Craft != null && Craft instanceof NBTTagByte )
((NBTTagByte) Craft).data = (byte) (this.isCraftable() ? 1 : 0);
else
i.setBoolean( "Craft", this.isCraftable() );
if ( Damage != null && Damage instanceof NBTTagShort )
((NBTTagShort) Damage).data = (short) this.def.damageValue;
else
i.setShort( "Damage", (short) this.def.damageValue );
/*
* if ( Damage != null && Damage instanceof NBTTagShort ) ((NBTTagShort) Damage).data = (short)
* this.def.damageValue; else
*/
i.setShort( "Damage", (short) this.def.damageValue );
if ( def.tagCompound != null )
i.setTag( "tag", (NBTTagCompound) def.tagCompound );
@@ -238,7 +229,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
@Override
public int compareTo(AEItemStack b)
{
int id = def.item.itemID - b.def.item.itemID;
int id = def.item.hashCode() - b.def.item.hashCode();
int dv = def.damageValue - b.def.damageValue;
int dspv = def.dspDamage - b.def.dspDamage;
@@ -279,14 +270,14 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
}
@Override
void writeIdentity(DataOutputStream i) throws IOException
void writeIdentity(ByteBuf i) throws IOException
{
i.writeShort( def.item.itemID );
i.writeShort( Item.itemRegistry.getIDForObject( def.item ) );
i.writeShort( getItemDamage() );
}
@Override
void readNBT(DataOutputStream i) throws IOException
void readNBT(ByteBuf i) throws IOException
{
if ( hasTagCompound() )
{
@@ -299,11 +290,11 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
int size = tagBytes.length;
i.writeInt( size );
i.write( tagBytes );
i.writeBytes( tagBytes );
}
}
public static IAEItemStack loadItemStackFromPacket(DataInputStream data) throws IOException
public static IAEItemStack loadItemStackFromPacket(ByteBuf data) throws IOException
{
byte mask = data.readByte();
// byte PriorityType = (byte) (mask & 0x03);
@@ -324,10 +315,10 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
int len = data.readInt();
byte[] bd = new byte[len];
data.readFully( bd );
data.readBytes( bd );
DataInput di = ByteStreams.newDataInput( bd );
d.setCompoundTag( "tag", CompressedStreamTools.read( di ) );
d.setTag( "tag", CompressedStreamTools.read( di ) );
}
// long priority = getPacketValue( PriorityType, data );