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 TagDouble extends AbstractTag {
   protected double value;

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

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

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

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

   public void setValue(double d) {
      this.value = d;
   }

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