package com.evilco.mc.nbt.tag;

import com.evilco.mc.nbt.stream.NbtInputStream;
import com.evilco.mc.nbt.stream.NbtOutputStream;
import com.google.common.base.Preconditions;
import java.io.IOException;
import javax.annotation.Nonnull;

public class TagIntegerArray extends AbstractTag {
   protected int[] values;

   public TagIntegerArray(@Nonnull String name, @Nonnull int[] values) {
      super(name);
      this.setValues(values);
   }

   public TagIntegerArray(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
      super(inputStream, anonymous);
      int size = inputStream.readInt();
      int[] data = new int[size];

      for(int i = 0; i < size; ++i) {
         data[i] = inputStream.readInt();
      }

      this.values = data;
   }

   public byte getTagID() {
      return TagType.INTEGER_ARRAY.typeID;
   }

   public int[] getValues() {
      return this.values;
   }

   public void setValues(@Nonnull int[] i) {
      Preconditions.checkNotNull(i, "i");
      this.values = i;
   }

   public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
      super.write(outputStream, anonymous);
      outputStream.writeInt(this.values.length);
      int[] var3 = this.values;
      int var4 = var3.length;

      for(int var5 = 0; var5 < var4; ++var5) {
         int i = var3[var5];
         outputStream.writeInt(i);
      }

   }
}
