    001package net.minecraft.nbt;
    002
    003import java.io.DataInput;
    004import java.io.DataOutput;
    005import java.io.IOException;
    006import java.util.Arrays;
    007
    008public class NBTTagIntArray extends NBTBase
    009{
    010    /** The array of saved integers */
    011    public int[] intArray;
    012
    013    public NBTTagIntArray(String par1Str)
    014    {
    015        super(par1Str);
    016    }
    017
    018    public NBTTagIntArray(String par1Str, int[] par2ArrayOfInteger)
    019    {
    020        super(par1Str);
    021        this.intArray = par2ArrayOfInteger;
    022    }
    023
    024    /**
    025     * Write the actual data contents of the tag, implemented in NBT extension classes
    026     */
    027    void write(DataOutput par1DataOutput) throws IOException
    028    {
    029        par1DataOutput.writeInt(this.intArray.length);
    030
    031        for (int var2 = 0; var2 < this.intArray.length; ++var2)
    032        {
    033            par1DataOutput.writeInt(this.intArray[var2]);
    034        }
    035    }
    036
    037    /**
    038     * Read the actual data contents of the tag, implemented in NBT extension classes
    039     */
    040    void load(DataInput par1DataInput) throws IOException
    041    {
    042        int var2 = par1DataInput.readInt();
    043        this.intArray = new int[var2];
    044
    045        for (int var3 = 0; var3 < var2; ++var3)
    046        {
    047            this.intArray[var3] = par1DataInput.readInt();
    048        }
    049    }
    050
    051    /**
    052     * Gets the type byte for the tag.
    053     */
    054    public byte getId()
    055    {
    056        return (byte)11;
    057    }
    058
    059    public String toString()
    060    {
    061        return "[" + this.intArray.length + " bytes]";
    062    }
    063
    064    /**
    065     * Creates a clone of the tag.
    066     */
    067    public NBTBase copy()
    068    {
    069        int[] var1 = new int[this.intArray.length];
    070        System.arraycopy(this.intArray, 0, var1, 0, this.intArray.length);
    071        return new NBTTagIntArray(this.getName(), var1);
    072    }
    073
    074    public boolean equals(Object par1Obj)
    075    {
    076        if (!super.equals(par1Obj))
    077        {
    078            return false;
    079        }
    080        else
    081        {
    082            NBTTagIntArray var2 = (NBTTagIntArray)par1Obj;
    083            return this.intArray == null && var2.intArray == null || this.intArray != null && Arrays.equals(this.intArray, var2.intArray);
    084        }
    085    }
    086
    087    public int hashCode()
    088    {
    089        return super.hashCode() ^ Arrays.hashCode(this.intArray);
    090    }
    091}