Table of Contents

Utilities

NTE provides a number of helper classes to provide some information or to implement functions more simply.

Output of test information

Versions

Functions are provided where you can get the version number to ensure compatibility with different versions of mods (if any).

Functions Description
static Resources.getMTRVersion(): String Returns the version of the MTR, for example, 1.19.2-3.1.1.0-hotfix-1.
static Resources.getNTEVersion(): String Returns the version of the NTE, for example, 0.4.0+1.19.2.
static Resources.getNTEVersionInt(): int Returns the NTE version as a number for easy comparison. For example, 0.4.0 would be 400, 1.9.1 would be 10901.
static Resources.getNTEProtoVersion(): int Returns the NTE protocol version.

TextUtil

MTR uses the station naming format Name in CJK|Name in another language||EXTRA, so NTE provides functions to separate these parts.

[Translator's note: MTR distinguishes text in CJK languages from the rest to allow them to be displayed nicely. It is not necessary to use CJK languages, e.g. you can easily use the scheme Name in Russian|Name in English||EXTRA or even use more languages.

For reference, CJK is Chinese, Japanese and Korean].

Functions Description
static TextUtil.getCjkParts(src: String): String Returns the CJK parts of the passed string.
static TextUtil.getNonCjkParts(src: String): String Returns the non-CJK parts of the passed string.
static TextUtil.getExtraParts(src: String): String Returns the extra part of the passed string.
static TextUtil.getNonExtraParts(src: String): String Returns everything except the extra part.
static TextUtil.getNonCjkAndExtraParts(src: String): String Returns everything except the CJK parts.
static TextUtil.isCjk(src: String): String Checks if the string contains CJK characters. [Translator's note: this function is supposed to return a Boolean value].

Timing

StateTracker

Sometimes it is necessary to take transition states into account. For example, to play an animation only once when a certain condition is reached (because if (…distance < 300) ctx.play… would be satisfied every frame after the condition was met, and then play every frame after that, which would result in hundreds of animations), or to play an animation in the first second after a page switch.

Since each train must have its own tracker, you would probably want to store it in the train's state.

CycleTracker

This is a StateTracker that automatically switches on a cyclic basis by time.

Since each train must have its own tracker, you would probably want to store it in the train's state.

RateLimit

Some tasks do not require too frequent execution, for example, the display may not be updated every frame, but only 10 times per second. Therefore, you can limit the frequency of their execution to improve performance.

Since each train must have its own data, you would probably want to store it in the train's state.

MTRClientData

Client data from MTR that can be used to read routes, transfers, etc. See the source code of ClientData.java from MTR.

MinecraftClient

Due to obfuscation, there is no way to directly provide a client class for use. Therefore, several helper methods are created:

Source

* https://www.zbx1425.cn/nautilus/mtr-nte/#/js-util