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
Table of contents
- Game Tests
- Modules
- Interfaces
- Interface: Block
- Interface: BlockLocation
- Interface: BlockLocationClass
- Interface: Blocks
- Interface: BlockStates
- Interface: Commands
- Interface: Dimension
- Interface: Effect
- Interface: Effects
- Methods
- absorption
- badOmen
- blindness
- conduitPower
- fatalPoison
- fireResistance
- haste
- healthBoost
- heroOfTheVillage
- hunger
- instantDamage
- instantHealth
- invisibility
- jumpBoost
- levitation
- miningFatigue
- nausea
- nightVision
- poison
- regeneration
- resistance
- saturation
- slowFalling
- slowness
- speed
- strength
- waterBreathing
- weakness
- wither
- Methods
- Interface: Entity
- Interface: EntityComponent
- Interface: Item
- Interface: Items
- Interface: ItemStack
- Interface: ItemStackClass
- Interface: Sequence
- Methods
- assertEntityData
- assertEntityHasArmor
- assertEntityHasComponent
- assertEntityInstancePresent
- assertEntityNotTouching
- assertEntityTouching
- assertIsWaterLogged
- assertItemEntityCountIs
- assertRedstonePower
- pulseRedstone
- spawn
- spawnItem
- thenExecute
- thenExecuteAfter
- thenIdle
- thenSucceed
- thenWait
- thenWaitWithDelay
- Methods
- Interface: State
- Interface: Tags
- Interface: Test
- Methods
- assertBlockNotPresent
- assertBlockPresent
- assertBlockState
- assertContainerContains
- assertContainerEmpty
- assertEntityNotPresent
- assertEntityNotPresentInArea
- assertEntityPresent
- assertEntityPresentInArea
- assertItemEntityNotPresent
- assertItemEntityPresent
- fail
- failIf
- killAllEntities
- pressButton
- pullLever
- runAfterDelay
- runAtTickTime
- setBlock
- startSequence
- succeed
- succeedOnTick
- succeedOnTickWhen
- succeedWhen
- succeedWhenBlockPresent
- succeedWhenEntityHasComponent
- succeedWhenEntityNotPresent
- succeedWhenEntityPresent
- Methods
- Interface: TestRunner
- Interface: World
- Interface: WorldLocation
- Interface: WorldLocationClass
- Type aliases
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(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”