dev.polymodloader.api.devtools.gametest
이 페이지는 소스의 Javadoc에서 ./gradlew apiReference로 만든 것입니다. 설명은 코드에 적힌 영어 그대로입니다. 직접 고치지 말고 소스의 주석을 고친 뒤 다시 만드세요.
| 형식 | 종류 | 설명 |
|---|---|---|
GameTest | 함수형 인터페이스 | One in-game test. |
GameTestContext | 인터페이스 | A running game test. |
GameTestRegistrar | 인터페이스 | Registers in-game tests that run on Mojang's game test server (net.minecraft.gametest.Main, for example through the polyScenarios Gradle tasks). |
TestArea | 레코드 | The empty space a game test gets, in blocks; (0, 0, 0) is its lowest corner. |
GameTest
함수형 인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface GameTest
One in-game test.
run(GameTestContext)
void run(GameTestContext context)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Starts the test on the server thread. The test passes when it calls GameTestContext.succeed() (now or from a later tick) and fails when an assertion or the code throws.
| 인자 | 타입 | 설명 |
|---|---|---|
context | GameTestContext | — |
GameTestContext
인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface GameTestContext
A running game test. Positions are relative to the test area; (0, 0, 0) is its lowest corner and the area is at least 1×1×1 blocks plus room above.
Assertions throw an exception the game reports as a test failure with the position and message.
world()
WorldView world()
추가된 버전 0.1.0-alpha.4 또는 그 이전
The world the test runs in.
반환 WorldView
absolute(BlockPos)
BlockPos absolute(BlockPos relative)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Converts a test-relative position into a world position.
| 인자 | 타입 | 설명 |
|---|---|---|
relative | BlockPos | — |
반환 BlockPos
setBlock(BlockPos, ResourceId)
void setBlock(BlockPos relative, ResourceId block)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Places the default state of block at a test-relative position.
| 인자 | 타입 | 설명 |
|---|---|---|
relative | BlockPos | — |
block | ResourceId | — |
assertBlock(BlockPos, ResourceId)
void assertBlock(BlockPos relative, ResourceId expected)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Fails unless the block at a test-relative position is expected.
| 인자 | 타입 | 설명 |
|---|---|---|
relative | BlockPos | — |
expected | ResourceId | — |
assertTrue(boolean, String)
void assertTrue(boolean condition, String message)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Fails with message unless condition holds.
| 인자 | 타입 | 설명 |
|---|---|---|
condition | boolean | — |
message | String | — |
createMockPlayer()
PlayerView createMockPlayer()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Creates a survival-mode player in the test world that is not connected to any client.
반환 PlayerView
createMockServerPlayer()
PlayerView createMockServerPlayer()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Creates a survival-mode server player that is not connected and not in the world, for what needs one, such as advancements.
반환 PlayerView
createConnectedMockPlayer()
PlayerView createConnectedMockPlayer()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Creates a survival-mode player that joins the server like a client over an in-memory connection (PlayerEvents.JOINED fires) and reports that it finished loading, so it can take damage. It stands where the game puts new players. Interactions work as for createMockServerPlayer().
While connected it affects the whole test world like a real player: mobs far from every player despawn and mobs spawn near it, which disturbs other tests running at the same time. Call disconnect before the test function returns; players still connected when the test ends are disconnected then.
반환 PlayerView
respawn(PlayerView, boolean)
PlayerView respawn(PlayerView player, boolean returnedFromEnd)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Respawns a player from createConnectedMockPlayer() as its client asks from the death screen (or after the End credits): the game builds a new player object, PlayerEvents.COPY and RESPAWNED fire, and the new player reports that it loaded.
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | — |
returnedFromEnd | boolean | true to respawn as when leaving the End (everything is kept); false to respawn after death |
반환 PlayerView — the new player
예외 IllegalArgumentException — when player is not a connected mock player of this test
예외 IllegalStateException — when respawning after death and the player is alive
disconnect(PlayerView)
void disconnect(PlayerView player)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Disconnects a player from createConnectedMockPlayer() (PlayerEvents.LEAVING fires); does nothing for a player that already left.
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | — |
예외 IllegalArgumentException — when player is not a connected mock player of this test
useBlock(BlockPos, PlayerView)
void useBlock(BlockPos relative, PlayerView player)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Makes player use (right-click) the block at a test-relative position with an empty hand.
| 인자 | 타입 | 설명 |
|---|---|---|
relative | BlockPos | — |
player | PlayerView | — |
interactBlock(PlayerView, BlockPos, Direction)
InteractionResult interactBlock(PlayerView player, BlockPos relative, Direction face)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Makes a server player (from createMockServerPlayer()) right-click a face of the block at a test-relative position with its main hand, the way the server handles the click from a connected client: interaction events first, then the held item and the block. Unlike useBlock, a held block item is placed.
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | — |
relative | BlockPos | — |
face | Direction | — |
반환 InteractionResult — the result the game reached, mapped onto the Native API's result
예외 IllegalArgumentException — when player is not a server player
interactItem(PlayerView)
InteractionResult interactItem(PlayerView player)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Makes a server player use the item in its main hand in the air, the way the server handles the click from a connected client (interaction events, then the item).
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | — |
반환 InteractionResult
예외 IllegalArgumentException — when player is not a server player
interactEntity(PlayerView, EntityView)
InteractionResult interactEntity(PlayerView player, EntityView target)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Makes a server player right-click target with its main hand, the way the server handles the click from a connected client (interaction events, then the entity and the item).
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | — |
target | EntityView | — |
반환 InteractionResult
예외 IllegalArgumentException — when player is not a server player
attackEntity(PlayerView, EntityView)
void attackEntity(PlayerView player, EntityView target)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Makes a server player attack target with its main hand, as a left-click does (interaction events, then damage and knockback).
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | — |
target | EntityView | — |
예외 IllegalArgumentException — when player is not a server player
breakBlock(PlayerView, BlockPos)
boolean breakBlock(PlayerView player, BlockPos relative)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Makes a server player break the block at a test-relative position at once, the way the server finishes a player's digging: block events, the game's checks, drops in survival mode.
| 인자 | 타입 | 설명 |
|---|---|---|
player | PlayerView | — |
relative | BlockPos | — |
반환 boolean — whether the block was broken
예외 IllegalArgumentException — when player is not a server player
runCommand(String)
int runCommand(String command)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Runs a command as the server at the test area's origin.
| 인자 | 타입 | 설명 |
|---|---|---|
command | String | — |
반환 int — the command's result value; 0 when it failed
runAfter(int, Runnable)
void runAfter(int ticks, Runnable action)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Runs action after ticks more ticks, on the server thread.
| 인자 | 타입 | 설명 |
|---|---|---|
ticks | int | — |
action | Runnable | — |
succeed()
void succeed()
추가된 버전 0.1.0-alpha.4 또는 그 이전
Marks the test passed.
fail(String)
void fail(String message)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Marks the test failed.
| 인자 | 타입 | 설명 |
|---|---|---|
message | String | — |
GameTestRegistrar
인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public interface GameTestRegistrar
Registers in-game tests that run on Mojang's game test server (net.minecraft.gametest.Main, for example through the polyScenarios Gradle tasks). Each test gets a fresh empty area; its ID is <mod id>:<name>, so --tests <mod id>:* runs all of a mod's tests. In a normal world they also run with /test run <mod id>:<name>.
When: inside common entrypoints.
register(String, GameTest)
default void register(String name, GameTest test)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Registers a required test that must finish within 100 ticks.
| 인자 | 타입 | 설명 |
|---|---|---|
name | String | — |
test | GameTest | — |
register(String, int, GameTest)
default void register(String name, int maxTicks, GameTest test)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Registers a required test.
| 인자 | 타입 | 설명 |
|---|---|---|
name | String | — |
maxTicks | int | ticks before the test fails with a timeout |
test | GameTest | — |
예외 IllegalArgumentException — for an invalid or already used name (POLY-GAMETEST-001)
예외 IllegalStateException — after registration closed (POLY-GAMETEST-002)
register(String, int, TestArea, GameTest)
void register(String name, int maxTicks, TestArea area, GameTest test)
추가된 버전 0.1.0-alpha.4 또는 그 이전
Registers a required test that gets area to itself.
| 인자 | 타입 | 설명 |
|---|---|---|
name | String | — |
maxTicks | int | — |
area | TestArea | — |
test | GameTest | — |
예외 IllegalArgumentException — for an invalid or already used name (POLY-GAMETEST-001)
예외 IllegalStateException — after registration closed (POLY-GAMETEST-002)
TestArea
레코드 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전
public record TestArea(int width, int height, int depth)
The empty space a game test gets, in blocks; (0, 0, 0) is its lowest corner. The game keeps a few blocks between neighbouring test areas, so a test that builds or moves things beyond one block needs an area that covers them, or it may disturb its neighbours.
| 구성 요소 | 타입 | 설명 |
|---|---|---|
width | int | size along x, 1–48 |
height | int | size along y, 1–48 |
depth | int | size along z, 1–48 |
| 상수·필드 | 타입 | 설명 |
|---|---|---|
SINGLE_BLOCK | TestArea | One block, the default. |
cube(int)
public static TestArea cube(int size)
추가된 버전 0.1.0-alpha.4 또는 그 이전
A size × size × size cube.
| 인자 | 타입 | 설명 |
|---|---|---|
size | int | — |
반환 TestArea