001package net.minecraft.nbt; 002 003import java.io.DataInput; 004import java.io.DataOutput; 005import java.io.IOException; 006import java.util.Arrays; 007 008public class NBTTagByteArray extends NBTBase 009{ 010 /** The byte array stored in the tag. */ 011 public byte[] byteArray; 012 013 public NBTTagByteArray(String par1Str) 014 { 015 super(par1Str); 016 } 017 018 public NBTTagByteArray(String par1Str, byte[] par2ArrayOfByte) 019 { 020 super(par1Str); 021 this.byteArray = par2ArrayOfByte; 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.byteArray.length); 030 par1DataOutput.write(this.byteArray); 031 } 032 033 /** 034 * Read the actual data contents of the tag, implemented in NBT extension classes 035 */ 036 void load(DataInput par1DataInput) throws IOException 037 { 038 int i = par1DataInput.readInt(); 039 this.byteArray = new byte[i]; 040 par1DataInput.readFully(this.byteArray); 041 } 042 043 /** 044 * Gets the type byte for the tag. 045 */ 046 public byte getId() 047 { 048 return (byte)7; 049 } 050 051 public String toString() 052 { 053 return "[" + this.byteArray.length + " bytes]"; 054 } 055 056 /** 057 * Creates a clone of the tag. 058 */ 059 public NBTBase copy() 060 { 061 byte[] abyte = new byte[this.byteArray.length]; 062 System.arraycopy(this.byteArray, 0, abyte, 0, this.byteArray.length); 063 return new NBTTagByteArray(this.getName(), abyte); 064 } 065 066 public boolean equals(Object par1Obj) 067 { 068 return super.equals(par1Obj) ? Arrays.equals(this.byteArray, ((NBTTagByteArray)par1Obj).byteArray) : false; 069 } 070 071 public int hashCode() 072 { 073 return super.hashCode() ^ Arrays.hashCode(this.byteArray); 074 } 075}