Skip to content

Built-in Commands

JSCore is a thin wrapper around FabricMC, but the mod comes with some commands for convenience.

/jscore eval <script>

Executes a JS expression.

Basic Usage

For example, to show 1 + 1 = 2

sh
/jscore eval 1 + 1

Example: Fibonacci Numbers

Fibonacci numbers are defined as

  • U1 = 1
  • U2 = 1
  • Un = Un-1 + Un-2

To find the first 10 fibonacci numbers, normally we write

js
function fib(n) {
    switch(n) {
        case 1:
        case 2:
            return 1;
        default:
            return fib(n - 1) + fib(n - 2;)
    }
}

let firstTenFibs = [];

for(let i = 1; i <= 10; i++) {
    firstTenFibs.push(fib(i));
}

firstTenFibs.join(', ')

We can squeeze them into one line by removing all the line breaks, which gives us the command below.

sh
/jscore eval function fib(n) { switch(n) { case 1: case 2: return 1; default: return fib(n-1)+fib(n-2)} }; let firstTenFibs=[]; for(let i=1;i<=10;i++) firstTenFibs.push(fib(i)); firstTenFibs.join(', ')

/jscore web <url>

Download a script from url and execute it.

/jscore require <mode> <file>

Evaluate a JS script file in .minecraft/config/jscore.

  • Strict mode will execute the file no matter what.
  • Lazy mode will execute the file only if it has not been executed before.
sh
/jscore require strict init.js

/jscore snapshot

All files related to JSCore are in .minecraft/config/jscore.

/jscore snapshot create

Creates a snapshot (backup) of the folder, and puts it in .minecraft/config/jscore-snapshots.

You can optionally give the snapshot a name with /jscore snapshot create <label>. If there is already another snapshot with the same name, the new snapshot will replace the old one.

sh
/jscore snapshot create bob-the-snapshot

/jscore snapshot delete <label>

Delete a snapshot.

sh
/jscore snapshot delete bob-the-snapshot.zip

/jscore snapshot restore <label>

Restore files in .minecraft/config/jscore to a previous snapshot (backup).

sh
/jscore snapshot restore bob-the-snapshot.zip

The current files in .minecraft/config/jscore will be lost after this.

/jscore snapshot pull <url>

Download a snapshot from url and replace .minecraft/config/jscore with that snapshot.

sh
/jscore snapshot pull https://jscore.siri.ws/bootstrap.zip

The current files in .minecraft/config/jscore will be lost after this.