Appearance
helix / Sim
Class: Sim โ
Defined in: core/sim/sim.ts:31
Runs a built datapack's functions without the game, for tests. Covers the command subset helix packs emit and throws on anything else.
const sim = new Sim(buildDatapack(dp), { block: (x, y) => (y < 64 ? "minecraft:stone" : "minecraft:air") }); sim.load(); sim.run("execute positioned 0 70 0 run function demo:spawn"); sim.tick(); expect(sim.errors).toEqual([]);
Constructors โ
Constructor โ
new Sim(
files,options?):Sim
Defined in: core/sim/sim.ts:54
Parameters โ
files โ
ReadonlyMap<string, string>
options? โ
SimOptions = {}
Returns โ
Sim
Properties โ
entities โ
readonlyentities:SimEntity[] =[]
Defined in: core/sim/sim.ts:33
Live entities, in summon order.
errors โ
readonlyerrors:string[] =[]
Defined in: core/sim/sim.ts:35
Commands that failed as they would in game (int overflow, missing score...), with why.
files โ
readonlyfiles:ReadonlyMap<string,string>
Defined in: core/sim/sim.ts:55
options โ
readonlyoptions:SimOptions={}
Defined in: core/sim/sim.ts:56
said โ
readonlysaid:string[] =[]
Defined in: core/sim/sim.ts:37
Text every say has printed, so a pack can report to its test runner.
Accessors โ
gametime โ
Get Signature โ
get gametime():
number
Defined in: core/sim/sim.ts:45
Game ticks run so far, as time query gametime reads it.
Returns โ
number
Methods โ
blockIs() โ
blockIs(
pos,id):boolean
Defined in: core/sim/sim.ts:208
Whether the block at pos is id, or in #tag.
Parameters โ
pos โ
V3
id โ
string
Returns โ
boolean
call() โ
call(
id,src,args?):number
Defined in: core/sim/sim.ts:139
Runs a function (ns:path) line by line; returns its return value, or 0. args fill a macro's $(name)s; like the game, a missing one fails the whole call.
Parameters โ
id โ
string
src โ
args? โ
Compound
Returns โ
number
charge() โ
charge():
void
Defined in: core/sim/sim.ts:116
Counts one command against the running chain. Matches the game's charges: each command run (per source), each execute clause, and each function call cost 1.
Returns โ
void
kill() โ
kill(
entity):void
Defined in: core/sim/sim.ts:202
Parameters โ
entity โ
Returns โ
void
load() โ
load():
void
Defined in: core/sim/sim.ts:60
Runs the #minecraft:load functions.
Returns โ
void
resetScore() โ
resetScore(
holder,objective?):void
Defined in: core/sim/sim.ts:175
Parameters โ
holder โ
string
objective? โ
string
Returns โ
void
run() โ
run(
command,source?):number
Defined in: core/sim/sim.ts:87
Runs one command as the server, at the world origin unless source says otherwise.
Parameters โ
command โ
string
source? โ
Partial<Omit<SimSource, "sim">> = {}
Returns โ
number
schedule() โ
schedule(
id,ticks,replace):void
Defined in: core/sim/sim.ts:74
Queues id to run ticks from now; replace drops its earlier entries first.
Parameters โ
id โ
string
ticks โ
number
replace โ
boolean
Returns โ
void
score() โ
score(
holder,objective):number|undefined
Defined in: core/sim/sim.ts:167
A score, or undefined when it's unset. holder is a name or an entity's UUID.
Parameters โ
holder โ
string
objective โ
string
Returns โ
number | undefined
setBlock() โ
setBlock(
pos,id):void
Defined in: core/sim/sim.ts:215
Places id (block states dropped) at a block position.
Parameters โ
pos โ
V3
id โ
string
Returns โ
void
setScore() โ
setScore(
holder,objective,value):void
Defined in: core/sim/sim.ts:171
Parameters โ
holder โ
string
objective โ
string
value โ
number
Returns โ
void
storage() โ
storage(
id):Compound
Defined in: core/sim/sim.ts:182
A command storage compound, created empty on first use.
Parameters โ
id โ
string
Returns โ
Compound
summon() โ
summon(
type,pos,nbt?):SimEntity
Defined in: core/sim/sim.ts:189
Adds an entity. Tags and UUID in nbt become its tags and UUID.
Parameters โ
type โ
string
pos โ
V3
nbt? โ
Compound = {}
Returns โ
tick() โ
tick():
void
Defined in: core/sim/sim.ts:65
Runs one game tick: the #minecraft:tick functions, then any scheduled ones now due.
Returns โ
void
unschedule() โ
unschedule(
id):number
Defined in: core/sim/sim.ts:80
Drops every queued run of id; returns how many there were.
Parameters โ
id โ
string
Returns โ
number