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 TagByte extends AbstractTag {
   protected byte value;

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

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

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

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

   public void setValue(byte b) {
      this.value = b;
   }

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