Class GameTest
-
public final class GameTestA game test is a special blocked-off area in the world that allows you to test blocks, items, entities, and other game mechanics in a controlled environment. It contains a success condition that looks at the world and determines when the test has succeeded.
This represents a running test in the world.
Default behaviour is to simply succeed.
-
-
Constructor Summary
Constructors Constructor Description GameTest(GameTestConfig config, World world, BlockPosition center, BoundingBox boundingBox)
-
Method Summary
Modifier and Type Method Description final GameTestConfiggetConfig()final WorldgetWorld()final BlockPositiongetCenter()final BoundingBoxgetBoundingBox()final voidsucceed()final voidsucceedWhen(Function0<Boolean> condition)Set the condition under which the test will succeed. final voidfail(String message, Throwable cause)final voidfail(String message)final BooleanentityInBounds(Function1<Entity, Boolean> predicate)Checks whether any entity in the gametest matches predicate final voidwithDelay(Integer ticks, Runnable runnable)Runs runnable on the main thread after waiting for the specified number of ticks final BlockPositionposition()Returns the center position of the game test final BlockPositionposition(BlockPosition offset)Returns a position relative to the center of the game test final BlockPositionposition(Integer x, Integer y, Integer z)Returns a position relative to the center of the game test final Locationlocation()Returns the center location of the game test final Locationlocation(Location location)Returns a location relative to the center of the game test final Locationlocation(Double x, Double y, Double z)Returns a location relative to the center of the game test -
-
Constructor Detail
-
GameTest
GameTest(GameTestConfig config, World world, BlockPosition center, BoundingBox boundingBox)
-
-
Method Detail
-
getConfig
final GameTestConfig getConfig()
-
getCenter
final BlockPosition getCenter()
-
getBoundingBox
final BoundingBox getBoundingBox()
-
succeed
final void succeed()
-
succeedWhen
final void succeedWhen(Function0<Boolean> condition)
Set the condition under which the test will succeed. Will be checked periodically.
-
fail
@JvmOverloads() final void fail(String message, Throwable cause)
-
fail
@JvmOverloads() final void fail(String message)
-
entityInBounds
final Boolean entityInBounds(Function1<Entity, Boolean> predicate)
Checks whether any entity in the gametest matches predicate
-
position
final BlockPosition position()
Returns the center position of the game test
-
position
final BlockPosition position(BlockPosition offset)
Returns a position relative to the center of the game test
-
position
final BlockPosition position(Integer x, Integer y, Integer z)
Returns a position relative to the center of the game test
-
location
final Location location(Location location)
Returns a location relative to the center of the game test
-
-
-
-