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 TagShort extends AbstractTag {
   protected short value;

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

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

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

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

   public void setValue(short s) {
      this.value = s;
   }

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