Store

object Store

A simple global key→value store for script state (numbers, booleans, strings).

Use it instead of many module-level lets when callbacks need to share mutable state: the swc4j bytecode compiler boxes each reassigned captured variable and miscomputes the stack when a single callback captures many of them (→ VerifyError). Reading/writing through Store keeps callbacks capture-free, sidestepping that limit. Keys are arbitrary strings.

Store.setNum("size", 2);
Jim.register(Event.RENDER_ENTITY, (e: EntityWrapper) => Tessellator.scale(Store.getNum("size", 1), 1, 1));

Functions

Link copied to clipboard

Wipe everything (e.g. on a fresh load).

Link copied to clipboard
fun getBool(key: String, fallback: Boolean): Boolean
Link copied to clipboard
fun getNum(key: String, fallback: Double): Double
Link copied to clipboard
fun getStr(key: String, fallback: String): String
Link copied to clipboard
fun setBool(key: String, value: Boolean)
Link copied to clipboard
fun setNum(key: String, value: Double)
Link copied to clipboard
fun setStr(key: String, value: String)
Link copied to clipboard

Flip a boolean (defaulting to false) and return the new value.