NTE provides a number of helper classes to provide some information or to implement functions more simply.
static print(params: Object...): void
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. |
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]. |
static Timing.elapsed(): double
static Timing.delta(): double
render
call and the previous one. This can be used, for example, to calculate the angle by which the wheel have turned during the elapsed time.
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
.
new StateTracker()
StateTracker.setState(value: String): void
StateTracker.stateNow(): String
StateTracker.stateLast(): String
null
is returned.StateTracker.stateNowDuration(): double
StateTracker.stateNowFirst(): boolean
setState
function in this loop or not?
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
.
new CycleTracker(params: Object[])
new CycleTracker([“route”, 5, “nextStation”, 5])
.CycleTracker.tick(): void
CycleTracker.stateNow(): String
CycleTracker.stateLast(): String
null
is returned.CycleTracker.stateNowDuration(): double
CycleTracker.stateNowFirst(): boolean
tick
function called in this loop or not?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
.
new RateLimit(interval: double)
interval
is the interval in seconds between two triggers, for example, an interval of 0.1 means it should occur ten times per second.RateLimit.shouldUpdate(): boolean
if (state.rateLimitXXX.shouldUpdate()) { … }
to limit its execution frequency.RateLimit.resetCoolDown(): void
Client data from MTR that can be used to read routes, transfers, etc. See the source code of ClientData.java from MTR.
Due to obfuscation, there is no way to directly provide a client class for use. Therefore, several helper methods are created:
static MinecraftClient.worldIsRaining(): boolean
static MinecraftClient.worldIsRainingAt(pos: Vector3f): boolean
static MinecraftClient.worldDayTime(): int
static MinecraftClient.narrate(message: String): void
static MinecraftClient.displayMessage(message: String, actionBar: boolean): void