Skip to content

ModContainerHelper ​

com.jsmacrosce.jsmacros.api.helper.ModContainerHelper

Since1.8.4

A loaded mod's metadata exposed to scripts. Obtain wrappers from getMod() for a single mod, or from getLoadedMods().
Values come from loader metadata; use getId() to identify a mod rather than its display name. Loader differences include getAuthors() returning null and getEnv() returning "UNKNOWN".

js
// List loaded mods and their ids and versions
const mods = Client.getLoadedMods();  
let i = 0;  
while (i !== mods.size()) {
 Chat.log(`${mods.get(i).getId()} ${mods.get(i).getVersion()}`);  
 i += 1;  
}

// Look up a mod by id
const sodium = Client.getMod("sodium");  
if (sodium !== null) {
 Chat.log(sodium.getName());  
}

Type Parameters ​

  • T: the loader-specific mod container wrapped by this helper

Methods ​

getAuthors ​

getAuthors(): List<String>Since1.8.4#
Returns the author names from metadata on Fabric; NeoForge returns null.
Returns: a list of all authors, or null on NeoForge where it is not reported

getDependencies ​

getDependencies(): List<String>Since1.8.4#
Returns ids from the mod's declared dependency metadata, including non-required entries exposed by the loader; this is not a list of resolved required mods.
Returns: a list of all dependencies.

getDescription ​

getDescription(): StringSince1.8.4#
Returns the mod's description from loader metadata.
Returns: the mod's description.

getEnv ​

getEnv(): StringSince1.8.4#
Returns the mod's declared environment: "CLIENT", "SERVER", or "BOTH"; NeoForge may also return "UNKNOWN" for an absent or unrecognized side value.
Returns: the environment this mod is intended for.

getId ​

getId(): StringSince1.8.4#
Returns the mod's loader-defined id (for example, "sodium"), used to look it up with getMod().
Returns: the loader-defined id used by Client.getMod(id)

getName ​

getName(): StringSince1.8.4#
Returns the mod's display name; it need not match getId().
Returns: the mod's name.

getVersion ​

getVersion(): StringSince1.8.4#
Returns the mod's loader-reported version string; its format is loader- and mod-defined.
Returns: the mod's version.

toString ​

toString(): String#
Returns a diagnostic label containing the values from getId(), getName(), and getVersion() at call time. The values are inserted with %s formatting and are not JSON-escaped.
Returns: a label with the mod id, name, and version