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 i = 0; i < this.intArray.length; ++i)
032        {
033            par1DataOutput.writeInt(this.intArray[i]);
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 i = par1DataInput.readInt();
043        this.intArray = new int[i];
044
045        for (int j = 0; j < i; ++j)
046        {
047            this.intArray[j] = 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[] aint = new int[this.intArray.length];
070        System.arraycopy(this.intArray, 0, aint, 0, this.intArray.length);
071        return new NBTTagIntArray(this.getName(), aint);
072    }
073
074    public boolean equals(Object par1Obj)
075    {
076        if (!super.equals(par1Obj))
077        {
078            return false;
079        }
080        else
081        {
082            NBTTagIntArray nbttagintarray = (NBTTagIntArray)par1Obj;
083            return this.intArray == null && nbttagintarray.intArray == null || this.intArray != null && Arrays.equals(this.intArray, nbttagintarray.intArray);
084        }
085    }
086
087    public int hashCode()
088    {
089        return super.hashCode() ^ Arrays.hashCode(this.intArray);
090    }
091}