Link Search Menu Expand Document

Game Tests

The GameTest framework requires you to activate “Enable GameTest Framework” in your world settings and you must be using Minecraft 1.16.210.60 beta or above

GameTests are a new feature which allow developers to create unit tests to make it easier to test if game mechanics work. They are created with javascript files in the behavior pack folder and each file can register multiple GameTests. Each GameTest must also have an .mcstructure file in the BP/structures folder.

It is recommended that your GameTests go in the BP/scripts/gametests directory.

Type declaration files for the GameTest API

Table of contents
  1. Game Tests
    1. Using GameTests
    2. Complete examples
  2. Modules
    1. Namespace: “GameTest”
      1. Variables
        1. Tags
      2. Functions
        1. register
          1. Parameters:
    2. Namespace: “Minecraft”
      1. Variables
        1. BlockLocation
        2. BlockStates
        3. Blocks
        4. ItemStack
  3. Interfaces
    1. Interface: Block
      1. Methods
        1. setState
          1. Parameters:
    2. Interface: BlockLocation
      1. Methods
        1. above
    3. Interface: BlockLocationClass
      1. Constructors
        1. constructor
          1. Parameters:
    4. Interface: Blocks
      1. Methods
        1. get
          1. Parameters:
    5. Interface: BlockStates
      1. Methods
    6. Interface: Commands
      1. Methods
        1. run
          1. Parameters:
    7. Interface: Dimension
    8. Interface: Effect
      1. Methods
        1. getAmplifier
        2. getDuration
    9. Interface: Effects
      1. Methods
        1. absorption
        2. badOmen
        3. blindness
        4. conduitPower
        5. fatalPoison
        6. fireResistance
        7. haste
        8. healthBoost
        9. heroOfTheVillage
        10. hunger
        11. instantDamage
        12. instantHealth
        13. invisibility
        14. jumpBoost
        15. levitation
        16. miningFatigue
        17. nausea
        18. nightVision
        19. poison
        20. regeneration
        21. resistance
        22. saturation
        23. slowFalling
        24. slowness
        25. speed
        26. strength
        27. waterBreathing
        28. weakness
        29. wither
    10. Interface: Entity
      1. Methods
        1. addEffect
          1. Parameters:
        2. getComponent
          1. Parameters:
        3. getComponents
        4. getEffect
          1. Parameters:
        5. getName
        6. hasComponent
          1. Parameters:
        7. kill
    11. Interface: EntityComponent
      1. Methods
        1. getName
        2. leash
          1. Parameters:
        3. setColor
          1. Parameters:
        4. setTamed
          1. Parameters:
        5. unleash
    12. Interface: Item
    13. Interface: Items
      1. Methods
    14. Interface: ItemStack
    15. Interface: ItemStackClass
      1. Constructors
        1. constructor
          1. Parameters:
    16. Interface: Sequence
      1. Methods
        1. assertEntityData
          1. Parameters:
        2. assertEntityHasArmor
          1. Parameters:
        3. assertEntityHasComponent
          1. Parameters:
        4. assertEntityInstancePresent
          1. Parameters:
        5. assertEntityNotTouching
          1. Parameters:
        6. assertEntityTouching
          1. Parameters:
        7. assertIsWaterLogged
          1. Parameters:
        8. assertItemEntityCountIs
          1. Parameters:
        9. assertRedstonePower
          1. Parameters:
        10. print
          1. Parameters:
        11. pulseRedstone
          1. Parameters:
        12. spawn
          1. Parameters:
        13. spawnItem
          1. Parameters:
        14. thenExecute
          1. Parameters:
        15. thenExecuteAfter
          1. Parameters:
        16. thenIdle
          1. Parameters:
        17. thenSucceed
        18. thenWait
          1. Parameters:
        19. thenWaitWithDelay
          1. Parameters:
    17. Interface: State
    18. Interface: Tags
      1. Properties
        1. suiteAll
        2. suiteBroken
        3. suiteDebug
        4. suiteDefault
    19. Interface: Test
      1. Methods
        1. assertBlockNotPresent
          1. Parameters:
        2. assertBlockPresent
          1. Parameters:
        3. assertBlockState
          1. Parameters:
        4. assertContainerContains
          1. Parameters:
        5. assertContainerEmpty
          1. Parameters:
        6. assertEntityNotPresent
          1. Parameters:
        7. assertEntityNotPresentInArea
          1. Parameters:
        8. assertEntityPresent
          1. Parameters:
        9. assertEntityPresentInArea
          1. Parameters:
        10. assertItemEntityNotPresent
          1. Parameters:
        11. assertItemEntityPresent
          1. Parameters:
        12. fail
          1. Parameters:
        13. failIf
          1. Parameters:
        14. killAllEntities
        15. pressButton
          1. Parameters:
        16. pullLever
          1. Parameters:
        17. runAfterDelay
          1. Parameters:
        18. runAtTickTime
          1. Parameters:
        19. setBlock
          1. Parameters:
        20. startSequence
        21. succeed
        22. succeedOnTick
          1. Parameters:
        23. succeedOnTickWhen
          1. Parameters:
        24. succeedWhen
          1. Parameters:
        25. succeedWhenBlockPresent
          1. Parameters:
          2. Parameters:
        26. succeedWhenEntityHasComponent
          1. Parameters:
        27. succeedWhenEntityNotPresent
          1. Parameters:
        28. succeedWhenEntityPresent
          1. Parameters:
    20. Interface: TestRunner
      1. Methods
        1. batch
          1. Parameters:
        2. maxAttempts
          1. Parameters:
        3. maxTicks
          1. Parameters:
        4. padding
          1. Parameters:
        5. required
          1. Parameters:
        6. requiredSuccessfulAttempts
          1. Parameters:
        7. setupTicks
          1. Parameters:
        8. structureName
          1. Parameters:
        9. tag
          1. Parameters:
    21. Interface: World
      1. Methods
        1. addEventListener
          1. Parameters:
        2. getDimension
    22. Interface: WorldLocation
    23. Interface: WorldLocationClass
      1. Constructors
        1. constructor
          1. Parameters:
  4. Type aliases
    1. WorldEvent

Using GameTests

In the behavior pack manifest you need to add a javascript module where you set an entry point for your GameTests.

BP/manifest.json

{
    "format_version": 2,
    "header": {
        "name": "Pack Name",
        "description": "Pack descripton",
        "min_engine_version": [
            1,
            16,
            210
        ],
        "uuid": "604420b9-f4c3-4df2-9f09-4364486f1195",
        "version": [
            1,
            0,
            0
        ]
    },
    "modules": [
        {
            "description": "",
            "type": "data",
            "uuid": "42651ba5-6619-4547-9d48-84a5a37cf2a3",
            "version": [
                1,
                0,
                0
            ]
        },
        {
            "description": "",
            "uuid": "239c134f-67bf-4738-9bcc-8c69d31b1f72",
            "version": [
                1,
                0,
                0
            ],
            "type": "javascript",
            "entry": "scripts/gametests/Main.js"
        }
    ],
    "dependencies": [
      {
      // Minecraft native module - needed to use the "Minecraft" module
      "uuid": "b26a4d4c-afdf-4690-88f8-931846312678",
      "version": [ 0, 1, 0 ]
    },
    {
      // GameTest native module - needed to use the "GameTest" module
      "uuid": "6f4b6893-1bb6-42fd-b458-7fa3d0c89616",
      "version": [ 0, 1, 0 ]
    }
    ]
}

The entry point should link to a file containing imports to your GameTest files.

BP/scripts/gametests/Main.js

import "scripts/gametests/MyGameTest.js";
import "scripts/gametests/OtherGameTest.js"

GameTests can be used with the /gametest command.

  • /gametest runthis

Runs the nearest GameTest in range.

  • /gametest runthese

Runs all GameTests in range.

  • /gametest pos

Tells you the relative coordinates of the nearest GameTest.

  • /gametest clearall [radius: int]

Removes all GameTests in the specified radius.

  • /gametest run <testName: GameTestName> [rotationSteps: int]

Creates and runs the specified GameTest.

  • /gametest runset [tagTag: GameTestTag] [rotationSteps: int]

Creates and runs all GameTests with the specified tag.

  • /gametest create <testName: string> [width: int] [height: int] [depth: int]

Creates a blank GameTest area with the specified dimensions.

Complete examples

// Structure Path: BP/structures/MinecartTests/turn.mcstructure

import * as GameTest from "GameTest";
import { BlockLocation } from "Minecraft";

GameTest.register("MinecartTests", "turn", (test) => {
  const minecartActorType = "minecart";

  const endPos = new BlockLocation(1, 2, 2);
  const startPos = new BlockLocation(1, 2, 0);

  test.assertEntityPresent(minecartActorType, startPos);
  test.assertEntityNotPresent(minecartActorType, endPos);

  test.pressButton(new BlockLocation(0, 3, 0));

  test.succeedWhenEntityPresent(minecartActorType, endPos);
}).tag(GameTest.Tags.suiteDefault);
// Structure Path: BP/structures/DoorTests/four_villagers_one_door.mcstructure

import * as GameTest from "GameTest";
import { BlockLocation } from "Minecraft";

GameTest.register("DoorTests", "four_villagers_one_door", (test) => {
  const villagerActorType = "minecraft:villager_v2";
  const villagerActorSpawnType =
    "minecraft:villager_v2<minecraft:spawn_farmer>"; // Attempt to spawn the villagers as farmers

  test.spawn(villagerActorSpawnType, new BlockLocation(5, 2, 4));
  test.spawn(villagerActorSpawnType, new BlockLocation(4, 2, 5));
  test.spawn(villagerActorSpawnType, new BlockLocation(2, 2, 5));
  test.spawn(villagerActorSpawnType, new BlockLocation(1, 2, 4));

  test.succeedWhen(() => {
    test.assertEntityPresent(villagerActorType, new BlockLocation(5, 2, 2));
    test.assertEntityPresent(villagerActorType, new BlockLocation(5, 2, 1));
    test.assertEntityPresent(villagerActorType, new BlockLocation(1, 2, 2));
    test.assertEntityPresent(villagerActorType, new BlockLocation(1, 2, 1));
  });
})
  .tag(GameTest.Tags.suiteDefault)
  .padding(50) // Space out villager tests to stop them from confusing each other
  .batch("night") // This should be a constant at some point
  .maxTicks(600);

Modules

Namespace: “GameTest”

Variables

Tags

Const Tags: Tags

Functions

register

register(namespace: string, identifier: string, func: (test: Test) => void): TestRunner

Registers a GameTest into Minecraft

Parameters:
Name Type Description
namespace string Namespace of the GameTest. Should match the namespace of the mcstructure file
identifier string Identifier of the GameTest. Should match the identifier of the mcstructure file
func (test: Test) => void -

Returns: TestRunner

Namespace: “Minecraft”

Variables

BlockLocation

Const BlockLocation: BlockLocationClass


BlockStates

Const BlockStates: BlockStates


Blocks

Const Blocks: Blocks


ItemStack

Const ItemStack: ItemStackClass

Interfaces

Interface: Block

Methods

setState

setState(state: State): Block

Parameters:
Name Type
state State

Returns: Block

Interface: BlockLocation

Methods

above

above(): BlockLocation

Returns the block position it was called on but increases the y coordinate by 1

Returns: BlockLocation

Interface: BlockLocationClass

Constructors

constructor

+ new BlockLocation(x: number, y: number, z: number): BlockLocation

Creates a block position

Parameters:
Name Type
x number
y number
z number

Returns: BlockLocation

Interface: Blocks

Methods

Contains a method for every vanilla block. Every method is in camelCase. Example:

air(): Block


get

get(id: string): Block

Fetches the requested block and returns it, if the block doesn’t exist, this returns null

Parameters:
Name Type Description
id string The identifier of the block to get

Returns: Block

Interface: BlockStates

Methods

Contains a method for every block state. Every method is in camelCase. Example:

topSlotBit(data: boolean): State

Interface: Commands

Methods

run

run(command: string): void

Runs the given command when called

Parameters:
Name Type Description
command string The command to run (should start with a ‘/’)

Returns: void

Interface: Dimension

Interface: Effect

Methods

getAmplifier

getAmplifier(): any

Gets the effect’s amplifier level

Returns: any


getDuration

getDuration(): any

Gets the effect’s remaining duration in ticks

Returns: any

Interface: Effects

Methods

absorption

absorption(): Effect

Returns: Effect


badOmen

badOmen(): Effect

Returns: Effect


blindness

blindness(): Effect

Returns: Effect


conduitPower

conduitPower(): Effect

Returns: Effect


fatalPoison

fatalPoison(): Effect

Returns: Effect


fireResistance

fireResistance(): Effect

Returns: Effect


haste

haste(): Effect

Returns: Effect


healthBoost

healthBoost(): Effect

Returns: Effect


heroOfTheVillage

heroOfTheVillage(): Effect

Returns: Effect


hunger

hunger(): Effect

Returns: Effect


instantDamage

instantDamage(): Effect

Returns: Effect


instantHealth

instantHealth(): Effect

Returns: Effect


invisibility

invisibility(): Effect

Returns: Effect


jumpBoost

jumpBoost(): Effect

Returns: Effect


levitation

levitation(): Effect

Returns: Effect


miningFatigue

miningFatigue(): Effect

Returns: Effect


nausea

nausea(): Effect

Returns: Effect


nightVision

nightVision(): Effect

Returns: Effect


poison

poison(): Effect

Returns: Effect


regeneration

regeneration(): Effect

Returns: Effect


resistance

resistance(): Effect

Returns: Effect


saturation

saturation(): Effect

Returns: Effect


slowFalling

slowFalling(): Effect

Returns: Effect


slowness

slowness(): Effect

Returns: Effect


speed

speed(): Effect

Returns: Effect


strength

strength(): Effect

Returns: Effect


waterBreathing

waterBreathing(): Effect

Returns: Effect


weakness

weakness(): Effect

Returns: Effect


wither

wither(): Effect

Returns: Effect

Interface: Entity

Methods

addEffect

addEffect(effect: Effect, duration: number, amplifier: number): Effect

Adds an effect to the Entity

Parameters:
Name Type
effect Effect
duration number
amplifier number

Returns: Effect


getComponent

getComponent(component: string): EntityComponent

Returns the component matching the given identifier

Parameters:
Name Type Description
component string The component identifier to get

Returns: EntityComponent


getComponents

getComponents(): EntityComponent[]

Returns an array of supported components

Returns: EntityComponent[]


getEffect

getEffect(effect: Effect): Effect

Gets an effect from the Entity

Parameters:
Name Type
effect Effect

Returns: Effect


getName

getName(): string

Returns the name of the entity (e.g. “Horse”)

Returns: string


hasComponent

hasComponent(component: string): boolean

Returns true if the given component exists on the entity and is supported

Parameters:
Name Type Description
component string The component identifier to check for

Returns: boolean


kill

kill(): void

Kills the entity

Returns: void

Interface: EntityComponent

Methods

getName

getName(): string

Returns the name of the component

Returns: string


leash

leash(entity: Entity): void

Leashes this entity to another given entity. This must be used on the “minecraft:leashable” component

Parameters:
Name Type Description
entity Entity The entity to leash this entity to

Returns: void


setColor

setColor(color: number): void

Sets the entities color value. This must be used on the “minecraft:color” component

Parameters:
Name Type Description
color number The color value to set

Returns: void


setTamed

setTamed(particles: boolean): void

Sets the entity as tamed

Parameters:
Name Type Description
particles boolean Whether to display taming particles

Returns: void


unleash

unleash(): void

Causes this entity to detach leashes. This must be used on the “minecraft:leashable” component

Returns: void

Interface: Item

Interface: Items

Methods

Contains a method for every vanilla item. Every method is in camelCase. Example:

apple(): Item

Interface: ItemStack

Interface: ItemStackClass

Constructors

constructor

+ new ItemStack(item: Item, amount: number, data: number): ItemStack

Creates a an item stack

Parameters:
Name Type
item Item
amount number
data number

Returns: ItemStack

Interface: Sequence

Methods

assertEntityData

assertEntityData(position: BlockLocation, id: string, func: (entity: Entity) => void): void

Asserts that the given condition is true for all entities of the given type at the given location

Parameters:
Name Type Description
position BlockLocation Position of the entity to test
id string Identifier of the entity to test
func (entity: Entity) => void  

Returns: void


assertEntityHasArmor

assertEntityHasArmor(id: string, slot: number, item: string, data: number, position: BlockLocation, bool: boolean): void

Asserts an error when the armor is found on the entity at the given coordinates

Parameters:
Name Type Description
id string The identifier of the entity to check for the armor on
slot number The slot of the entity to test for the item
item string The item to test for in the given slot
data number The data value of the item
position BlockLocation The position of the entity to test for the armor
bool boolean Unknown function of parameter…

Returns: void


assertEntityHasComponent

assertEntityHasComponent(id: string, component: string, position: BlockLocation, bool: boolean): void

Asserts an error when the given entity has the component

Parameters:
Name Type Description
id string The identifier of the entity to test
component string The name of the component to test for
position BlockLocation The position of the entity to test
bool boolean Unknown function of parameter…

Returns: void


assertEntityInstancePresent

assertEntityInstancePresent(id: string, position: BlockLocation): void

Asserts an error when the given entity is found at the given coordinates

Parameters:
Name Type Description
id string The identifier of the entity to check for
position BlockLocation The relative position to test for the actor

Returns: void


assertEntityNotTouching

assertEntityNotTouching(id: string, position: BlockLocation): void

Asserts that there is no entity of the given type at the given position

Parameters:
Name Type Description
id string The entity to test for
position BlockLocation The position of the entity to test

Returns: void


assertEntityTouching

assertEntityTouching(id: string, position: BlockLocation): void

Asserts that there is an entity of the given type at the given position

Parameters:
Name Type Description
id string The entity to test for
position BlockLocation The position of the entity to test

Returns: void


assertIsWaterLogged

assertIsWaterLogged(position: BlockLocation, isWaterLoggged: boolean): void

Asserts that the block at the given location is waterlogged

Parameters:
Name Type Description
position BlockLocation Position of the block to test
isWaterLoggged boolean Whether to test if the block is or isn’t waterlogged

Returns: void


assertItemEntityCountIs

assertItemEntityCountIs(item: Item, position: BlockLocation, searchDistance: number, count: number): void

Asserts that the entity item count in the given search area matches the expected count

Parameters:
Name Type Description
item Item The item type to test for
position BlockLocation The position of the item to test for
searchDistance number The distance to search for the item
count number The amount of items to expect in the stack

Returns: void


assertRedstonePower

assertRedstonePower(position: BlockLocation, power: number): void

Asserts the redstone power level at the given location

Parameters:
Name Type Description
position BlockLocation Position of the block to test
power number The redstone power level to test for

Returns: void


print

print(text: string): void

Prints the given text to the chat

Parameters:
Name Type Description
text string The text to print out

Returns: void


pulseRedstone

pulseRedstone(position: BlockLocation, duration: number): void

Creates a Redstone block at the given position and destroys it after “duration” ticks

Parameters:
Name Type Description
position BlockLocation Position to place the redstone block
duration number The time until the redstone block is destroyed

Returns: void


spawn

spawn(id: string, position: BlockLocation): Entity

Spawns the specified entity at the specified coordinates

Parameters:
Name Type Description
id string The identifier of the entity to spawn
position BlockLocation The relative position to spawn the entity

Returns: Entity


spawnItem

spawnItem(item: ItemStack, location: WorldLocation): Item

Spawns an item at the given location

Parameters:
Name Type Description
item ItemStack The item stack to spawn
location WorldLocation -

Returns: Item


thenExecute

thenExecute(func: () => void): Sequence

Executes the function when called

Parameters:
Name Type
func () => void

Returns: Sequence


thenExecuteAfter

thenExecuteAfter(time: number, func: () => void): Sequence

Executes the function after the time given when called

Parameters:
Name Type Description
time number The amount of time until the function is called
func () => void  

Returns: Sequence


thenIdle

thenIdle(time: number): Sequence

Causes the sequence to wait for the given amount of time

Parameters:
Name Type Description
time number The amount of time to wait for

Returns: Sequence


thenSucceed

thenSucceed(): void

Causes the GameTest to succeed

Returns: void


thenWait

thenWait(func: () => void): Sequence

Causes the sequence to wait until the function asserts an error

Parameters:
Name Type
func () => void

Returns: Sequence


thenWaitWithDelay

thenWaitWithDelay(delayTicks: number, func: () => void): Sequence

Causes the sequence to wait until the function asserts an error and the delay has passed

Parameters:
Name Type Description
delayTicks number The amount of ticks to wait
func () => void  

Returns: Sequence

Interface: State

Interface: Tags

Properties

suiteAll

suiteAll: string


suiteBroken

suiteBroken: string


suiteDebug

suiteDebug: string


suiteDefault

suiteDefault: string

Interface: Test

Methods

assertBlockNotPresent

assertBlockNotPresent(id: Block, position: BlockLocation): void

Asserts an error when the given block is not found at the given coordinates

Parameters:
Name Type Description
id Block The block to check for
position BlockLocation The relative position to test for the block

Returns: void


assertBlockPresent

assertBlockPresent(id: Block, position: BlockLocation): void

Asserts an error when the specified block is found at the specified coordinates

Parameters:
Name Type Description
id Block The block to check for
position BlockLocation The relative position to test for the block

Returns: void


assertBlockState

assertBlockState(state: string, stateValue: string | number, position: BlockLocation): void

Asserts an error when the given block at the given coordinates has the block state

Parameters:
Name Type Description
state string The block state to test for
stateValue string | number The value of the state to test for
position BlockLocation The relative position to test for the block

Returns: void


assertContainerContains

assertContainerContains(itemStack: ItemStack, position: BlockLocation): void

Asserts an error if there is a container with the given item at the given coordinates

Parameters:
Name Type Description
itemStack ItemStack The item stack to test for in the container
position BlockLocation The relative position of the container to check

Returns: void


assertContainerEmpty

assertContainerEmpty(position: BlockLocation): void

Asserts an error if there is an empty container at the given coordinates

Parameters:
Name Type Description
position BlockLocation The relative position of the container to check

Returns: void


assertEntityNotPresent

assertEntityNotPresent(id: string, position: BlockLocation): void

Asserts an error when the given entity is not found at the given coordinates

Parameters:
Name Type Description
id string The identifier of the entity to check for
position BlockLocation The relative position to test for the actor

Returns: void


assertEntityNotPresentInArea

assertEntityNotPresentInArea(id: string): void

Throws an Error if an entity matching the given identifier does not exist in the test region

Parameters:
Name Type Description
id string The identifer of the entity to test for

Returns: void


assertEntityPresent

assertEntityPresent(id: string, position: BlockLocation): void

Asserts an error when the given entity is found at the given coordinates

Parameters:
Name Type Description
id string The identifier of the entity to check for
position BlockLocation The relative position to test for the actor

Returns: void


assertEntityPresentInArea

assertEntityPresentInArea(id: string): void

Throws an Error if an entity matching the given identifier exists in the test region

Parameters:
Name Type Description
id string The identifer of the entity to test for

Returns: void


assertItemEntityNotPresent

assertItemEntityNotPresent(item: Item, position: BlockLocation, amount: number): void

Asserts an error when the given item is not found at the given coordinates

Parameters:
Name Type Description
item Item -
position BlockLocation The position to test for the item stack
amount number The amount of items that should be in the stack

Returns: void


assertItemEntityPresent

assertItemEntityPresent(item: Item, position: BlockLocation, amount: number): void

Asserts an error when the given item stack is found at the given coordinates

Parameters:
Name Type Description
item Item -
position BlockLocation The position to test for the item stack
amount number The amount of items that should be in the stack

Returns: void


fail

fail(errorMessage: string): void

Causes the GameTest to fail

Parameters:
Name Type
errorMessage string

Returns: void


failIf

failIf(func: () => void): void

When the func parameter calls an assert function the GameTest will fail

Parameters:
Name Type
func () => void

Returns: void


killAllEntities

killAllEntities(): void

Kills all entities in the test

Returns: void


pressButton

pressButton(position: BlockLocation): void

Presses a button at the specified coordinates if there is one there

Parameters:
Name Type Description
position BlockLocation The relative position to press the button

Returns: void


pullLever

pullLever(position: BlockLocation): void

Pulls a lever at the given coordinates if there is one there

Parameters:
Name Type Description
position BlockLocation The relative position to pull the lever

Returns: void


runAfterDelay

runAfterDelay(ticks: number, func: (test: Test) => void): void

Runs the a function after the set delay

Parameters:
Name Type Description
ticks number The amount of ticks that should pass until the function is run
func (test: Test) => void The function that will be run when the delay has passed

Returns: void


runAtTickTime

runAtTickTime(tick: number, func: () => void): any

Parameters:
Name Type
tick number
func () => void

Returns: any


setBlock

setBlock(id: Block, position: BlockLocation): void

Places the specified block at the specified coordinates

Parameters:
Name Type Description
id Block The block to place
position BlockLocation The relative position to place the block

Returns: void


startSequence

startSequence(): Sequence

Allows finer control over advanced test sequences

Returns: Sequence


succeed

succeed(): void

When this is called, the GameTest succeeds

Returns: void


succeedOnTick

succeedOnTick(tick: number): void

The GameTest will succeed when the given amount of ticks has passed

Parameters:
Name Type Description
tick number The tick to succed the test after

Returns: void


succeedOnTickWhen

succeedOnTickWhen(tick: number, func: () => void): void

The GameTest will succeed when the given amount of ticks has passed and the func parameter calls an assert function

Parameters:
Name Type
tick number
func () => void

Returns: void


succeedWhen

succeedWhen(func: () => void): void

When the func paramater calls an assert function the GameTest will succeed

Parameters:
Name Type
func () => void

Returns: void


succeedWhenBlockPresent

succeedWhenBlockPresent(id: Block, position: BlockLocation): void

The GameTest will succeed when the given block is found at the given coordinates

Parameters:
Name Type Description
id Block The block to check for
position BlockLocation The relative position to test for the block

Returns: void

succeedWhenBlockPresent(id: Block, position: BlockLocation): void

The GameTest will succeed when the specified block is found at the specified coordinates

Parameters:
Name Type Description
id Block The block to check for
position BlockLocation -

Returns: void


succeedWhenEntityHasComponent

succeedWhenEntityHasComponent(id: string, component: string, position: BlockLocation, hasComponent: boolean): void

The GameTest will succeed when the given entity has the given component

Parameters:
Name Type Description
id string The entity to test for
component string The component identififer to test for
position BlockLocation The position of the entity to test for
hasComponent boolean Whether the entity should or shouldn’t have the component

Returns: void


succeedWhenEntityNotPresent

succeedWhenEntityNotPresent(id: string, position: BlockLocation): void

The GameTest will succeed when the given entity is not found at the given coordinates

Parameters:
Name Type Description
id string The identifier of the entity to check for
position BlockLocation The relative position to test for the actor

Returns: void


succeedWhenEntityPresent

succeedWhenEntityPresent(id: string, position: BlockLocation): void

The GameTest will succeed when the given entity is found at the given coordinates

Parameters:
Name Type Description
id string The identifier of the entity to check for
position BlockLocation The relative position to test for the actor

Returns: void

Interface: TestRunner

Methods

batch

batch(time: night | day): TestRunner

Sets the time of day when the GameTest is run. The time will be changed to the time set here when the GameTest is run

Parameters:
Name Type Description
time night | day The time that the GameTest must take place in

Returns: TestRunner


maxAttempts

maxAttempts(attempts: number): TestRunner

Sets the maximum number of times a test will try to rerun if it fails

Parameters:
Name Type
attempts number

Returns: TestRunner


maxTicks

maxTicks(ticks: number): TestRunner

Sets the maximum amount of ticks the GameTest must complete until it fails

Parameters:
Name Type Description
ticks number The maximum amount of ticks

Returns: TestRunner


padding

padding(time: number): TestRunner

Sets the padding between GameTests being run

Parameters:
Name Type Description
time number The duration of the padding

Returns: TestRunner


required

required(isRequired: boolean): TestRunner

Parameters:
Name Type
isRequired boolean

Returns: TestRunner


requiredSuccessfulAttempts

requiredSuccessfulAttempts(attempts: number): TestRunner

Sets the number of successful test runs to be considered successful

Parameters:
Name Type
attempts number

Returns: TestRunner


setupTicks

setupTicks(ticks: number): TestRunner

Sets the ticks at which the GameTest begins

Parameters:
Name Type Description
ticks number The tick starting point

Returns: TestRunner


structureName

structureName(name: string): TestRunner

Sets the structure name linked with this GameTest

Parameters:
Name Type Description
name string Name of the structure

Returns: TestRunner


tag

tag(tag: any): TestRunner

Sets a tag for the GameTest to be referenced in the “/gametest runall” command

Parameters:
Name Type Description
tag any The tag of the GameTest

Returns: TestRunner

Interface: World

Methods

addEventListener

addEventListener(event: WorldEvent, func: (entity: Entity) => void): void

Registers an event listener for entity events Supported

Parameters:
Name Type Description
event WorldEvent -
func (entity: Entity) => void Function to run when the event is triggered

Returns: void


getDimension

getDimension(): Dimension

Gets the current dimension

Returns: Dimension

Interface: WorldLocation

Interface: WorldLocationClass

Constructors

constructor

+ new Location(x: number, y: number, z: number): WorldLocation

Creates a location

Parameters:
Name Type
x number
y number
z number

Returns: WorldLocation

Type aliases

WorldEvent

Ƭ WorldEvent: “onEntityCreated” | “onEntityDefinitionTriggered