Class: Test
Main class for GameTest functions, with helpers and data for manipulating the respective test. Note that all methods of this class expect BlockLocations and Locations relative to the GameTest structure block.
Constructors
new Test()
private
new Test():Test
Returns
Methods
assert()
assert(
condition
,message
):void
Parameters
Parameter | Type | Description |
---|---|---|
condition | boolean | Expression of the condition to evaluate. |
message | string | Message that is passed if the condition does not evaluate to true. |
Returns
void
Remarks
Tests that the condition specified in condition is true. If not, an error with the specified message is thrown.
Throws
This function can throw errors.
assertBlockPresent()
assertBlockPresent(
blockType
,blockLocation
,isPresent
?):void
Parameters
Parameter | Type | Description |
---|---|---|
blockType | string | BlockType | Expected block type. |
blockLocation | Vector3 | Location of the block to test at. |
isPresent ? | boolean | If true, this function tests whether a block of the specified type is at the location. If false, tests that a block of the specified type is not present. |
Returns
void
Remarks
Tests that a block of the specified type is present at the specified location. If it is not, an exception is thrown.
Throws
This function can throw errors.
assertBlockState()
assertBlockState(
blockLocation
,callback
):void
Parameters
Parameter | Type | Description |
---|---|---|
blockLocation | Vector3 | Location of the block to test at. |
callback | (arg ) => boolean | Callback function that contains additional tests based on the block at the specified location. |
Returns
void
Remarks
Tests that a block has a particular state value at the specified location. If it does not have that state value, an exception is thrown.
Throws
This function can throw errors.
Example
test.assertBlockState(buttonPos, (block) => {
return block.permutation.getProperty("button_pressed_bit") == 0;
});
assertCanReachLocation()
assertCanReachLocation(
mob
,blockLocation
,canReach
?):void
Parameters
Parameter | Type | Description |
---|---|---|
mob | Entity | Entity that you wish to test the location against. |
blockLocation | Vector3 | Structure-relative location to test whether the specified mob can reach. |
canReach ? | boolean | If true, tests whether the mob can reach the location. If false, tests whether the mob is not able to reach the location. |
Returns
void
Remarks
Tests that an entity can reach a particular location. Depending on the value of canReach, throws an exception if the condition is not met.
Throws
This function can throw errors.
assertContainerContains()
assertContainerContains(
itemStack
,blockLocation
):void
Parameters
Parameter | Type | Description |
---|---|---|
itemStack | ItemStack | Represents the type of item to check for. The specified container must contain at least 1 item matching the item type defined in itemStack. |
blockLocation | Vector3 | Location of the block with a container (for example, a chest) to test the contents of. |
Returns
void
Remarks
Tests that a container (e.g., a chest) at the specified location contains a specified of item stack. If not, an error is thrown.
Throws
This function can throw errors.
assertContainerEmpty()
assertContainerEmpty(
blockLocation
):void
Parameters
Parameter | Type | Description |
---|---|---|
blockLocation | Vector3 | Location of the block with a container (for example, a chest) to test is empty of contents. |
Returns
void
Remarks
Tests that a container (e.g., a chest) at the specified location is empty. If not, an error is thrown.
Throws
This function can throw errors.
assertEntityHasArmor()
assertEntityHasArmor(
entityTypeIdentifier
,armorSlot
,armorName
,armorData
,blockLocation
,hasArmor
?):void
Parameters
Parameter | Type | Description |
---|---|---|
entityTypeIdentifier | string | Identifier of the entity to match (e.g., 'minecraft:skeleton'). |
armorSlot | number | Container slot index to test. |
armorName | string | Name of the armor to look for. |
armorData | number | Data value integer to look for. |
blockLocation | Vector3 | Location of the entity with armor to test for. |
hasArmor ? | boolean | Whether or not the entity is expected to have the specified armor equipped. |
Returns
void
Remarks
Tests that an entity has a specific piece of armor equipped. If not, an error is thrown.
Throws
This function can throw errors.
Example
test.assertEntityHasArmor("minecraft:horse", armorSlotTorso, "diamond_horse_armor", 0, horseLocation, true);
assertEntityHasComponent()
assertEntityHasComponent(
entityTypeIdentifier
,componentIdentifier
,blockLocation
,hasComponent
?):void
Parameters
Parameter | Type | Description |
---|---|---|
entityTypeIdentifier | string | Identifier of the specified entity (e.g., 'minecraft:skeleton'). If the namespace is not specified, 'minecraft:' is assumed. |
componentIdentifier | string | Identifier of the component to check for. If the namespace is not specified, 'minecraft:' is assumed. |
blockLocation | Vector3 | Location of the block with a container (for example, a chest.) |
hasComponent ? | boolean | Determines whether to test that the component exists, or does not. |
Returns
void
Remarks
Tests that an entity has a particular component. If not, an exception is thrown.
Throws
This function can throw errors.
Example
test.assertEntityHasComponent("minecraft:sheep", "minecraft:is_sheared", entityLoc, false);
assertEntityInstancePresent()
assertEntityInstancePresent(
entity
,blockLocation
,isPresent
?):void
Parameters
Parameter | Type | Description |
---|---|---|
entity | Entity | Specific entity to test for. |
blockLocation | Vector3 | Location of the entity to test for. |
isPresent ? | boolean | Whether to test that an entity is present or not present at the specified location. |
Returns
void
Remarks
Depending on the value for isPresent, tests that a particular entity is present or not present at the specified location. Depending on the value of isPresent, if the entity is found or not found, an error is thrown.
Throws
This function can throw errors.
assertEntityInstancePresentInArea()
assertEntityInstancePresentInArea(
entity
,isPresent
?):void
Parameters
Parameter | Type | Description |
---|---|---|
entity | Entity | Entity instance to test for. |
isPresent ? | boolean | If true, this function tests whether the specified entity is present in the GameTest area. If false, tests that the specified entity is not present. |
Returns
void