def littleEndianNBT():
    """
    Pocket edition NBT files are encoded in little endian, instead of big endian.
    This sets all the required paramaters to read little endian NBT, and makes sure they get set back after usage.
    :return: None
    """

    # We need to override the function to access the hard-coded endianness.
    def override_write_string(string, buf):
        encoded = string.encode('utf-8')
        buf.write(struct.pack("<h%ds" % (len(encoded),), len(encoded), encoded))

    def reset_write_string(string, buf):
        encoded = string.encode('utf-8')
        buf.write(struct.pack(">h%ds" % (len(encoded),), len(encoded), encoded))

    def override_byte_array_write_value(self, buf):
        value_str = self.value.tostring()
        buf.write(struct.pack("<I%ds" % (len(value_str),), self.value.size, value_str))

    def reset_byte_array_write_value(self, buf):
        value_str = self.value.tostring()
        buf.write(struct.pack(">I%ds" % (len(value_str),), self.value.size, value_str))

    global string_len_fmt
    string_len_fmt = struct.Struct("<H")
    TAG_Byte.fmt = struct.Struct("<b")
    TAG_Short.fmt = struct.Struct("<h")
    TAG_Int.fmt = struct.Struct("<i")
    TAG_Long.fmt = struct.Struct("<q")
    TAG_Float.fmt = struct.Struct("<f")
    TAG_Double.fmt = struct.Struct("<d")
    TAG_Int_Array.dtype = numpy.dtype("<u4")
    TAG_Long_Array.dtype = numpy.dtype("<q")
    TAG_Short_Array.dtype = numpy.dtype("<u2")
    global write_string
    write_string = override_write_string
    TAG_Byte_Array.write_value = override_byte_array_write_value
    yield
    string_len_fmt = struct.Struct(">H")
    TAG_Byte.fmt = struct.Struct(">b")
    TAG_Short.fmt = struct.Struct(">h")
    TAG_Int.fmt = struct.Struct(">i")
    TAG_Long.fmt = struct.Struct(">q")
    TAG_Float.fmt = struct.Struct(">f")
    TAG_Double.fmt = struct.Struct(">d")
    TAG_Int_Array.dtype = numpy.dtype(">u4")
    TAG_Long_Array.dtype = numpy.dtype(">q")
    TAG_Short_Array.dtype = numpy.dtype(">u2")
    write_string = reset_write_string
    TAG_Byte_Array.write_value = reset_byte_array_write_value

    Pocket edition NBT files are encoded in little endian, instead of big endian.
    This sets all the required paramaters to read little endian NBT, and makes sure they get set back after usage.
    :return: None
    
pymclevel/nbt.py