package com.evilco.mc.nbt.tag;

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

public class TagInteger extends AbstractTag {
   protected int value;

   public TagInteger(@Nonnull String name, int value) {
      super(name);
      this.setValue(value);
   }

   public TagInteger(@Nonnull NbtInputStream inputStream, boolean anonymous) throws IOException {
      super(inputStream, anonymous);
      this.setValue(inputStream.readInt());
   }

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

   public int getValue() {
      return this.value;
   }

   public void setValue(int i) {
      this.value = i;
   }

   public void write(NbtOutputStream outputStream, boolean anonymous) throws IOException {
      super.write(outputStream, anonymous);
      outputStream.writeInt(this.value);
   }
}
