public static TagBase readTagFromStream(InputStream inputStream) throws IOException {
		DataInput input = null;
		
		if (inputStream instanceof DataInputStream) {
			input = (DataInputStream) inputStream;
		} else {
			input = new DataInputStream(inputStream);
		}
		
		int tagTypeId = input.readByte();
		String tagName = null;
		
		TagBase tag = null;
		
		EnumTagType tagType = EnumTagType.fromTypeId(tagTypeId);
		if (tagType != null) {
			if (tagType != EnumTagType.TAG_End) {
				tagName = input.readUTF();
				try {
					tag = (TagBase) tagType.getTagClass().getConstructor(String.class).newInstance(tagName);
				} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
					e.printStackTrace();
				}
			} else {
				tag = (TagBase) new TagEnd();
			}
		}
		
		if (tag != null && tag.getType() != EnumTagType.TAG_End) {
			tag.loadData(input);
			return tag;
		} else {
			return null;
		}
	}