/* * Decompiled with CFR 0.152. */ package com.evilco.mc.nbt.stream; import com.evilco.mc.nbt.tag.ITag; import com.evilco.mc.nbt.tag.TagType; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Constructor; public class NbtInputStream extends DataInputStream { public NbtInputStream(InputStream in) { super(in); } public ITag readTag() throws IOException { byte type = this.readByte(); TagType tagType = TagType.valueOf(type); if (tagType == null) { throw new IOException("Invalid NBT tag: Found unknown tag type " + type + "."); } if (tagType == TagType.END) { return null; } return this.readTag(tagType, false); } public ITag readTag(TagType type, boolean anonymous) throws IOException { Constructor constructor = null; try { constructor = type.tagType.getConstructor(NbtInputStream.class, Boolean.TYPE); } catch (NoSuchMethodException ex) { throw new IOException("Invalid NBT implementation state: Type " + type.tagType.getName() + " has no de-serialization constructor."); } try { return constructor.newInstance(this, anonymous); } catch (Exception ex) { throw new IOException("Invalid NBT implementation state: Type " + type.tagType.getName() + " in (" + this.getClass().getName() + ") has no valid constructor: " + ex.getMessage(), ex); } } }