GameTestHelper.java

net.minecraft.gametest.framework.GameTestHelper

信息

  • 全限定名:net.minecraft.gametest.framework.GameTestHelper
  • 类型:public class
  • 包:net.minecraft.gametest.framework
  • 源码路径:src/main/java/net/minecraft/gametest/framework/GameTestHelper.java
  • 起始行号:L79
  • 职责:

    TODO

字段/常量

  • testInfo

    • 类型: GameTestInfo
    • 修饰符: private final
    • 源码定位: L80
    • 说明:

      TODO

  • finalCheckAdded

    • 类型: boolean
    • 修饰符: private
    • 源码定位: L81
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.gametest.framework.GameTestHelper.TestBlockPlaceContext
    • 类型: class
    • 修饰符: private
    • 源码定位: L1123
    • 说明:

      TODO

构造器

public GameTestHelper(GameTestInfo testInfo) @ L83

  • 构造器名:GameTestHelper
  • 源码定位:L83
  • 修饰符:public

参数:

  • testInfo: GameTestInfo

说明:

TODO

方法

下面的方法块按源码顺序生成。

public GameTestAssertException assertionException(Component description) @ L87

  • 方法名:assertionException
  • 源码定位:L87
  • 返回类型:GameTestAssertException
  • 修饰符:public

参数:

  • description: Component

说明:

TODO

public GameTestAssertException assertionException(String descriptionId, Object... arguments) @ L91

  • 方法名:assertionException
  • 源码定位:L91
  • 返回类型:GameTestAssertException
  • 修饰符:public

参数:

  • descriptionId: String
  • arguments: Object…

说明:

TODO

public GameTestAssertPosException assertionException(BlockPos pos, Component description) @ L95

  • 方法名:assertionException
  • 源码定位:L95
  • 返回类型:GameTestAssertPosException
  • 修饰符:public

参数:

  • pos: BlockPos
  • description: Component

说明:

TODO

public GameTestAssertPosException assertionException(BlockPos pos, String descriptionId, Object... arguments) @ L99

  • 方法名:assertionException
  • 源码定位:L99
  • 返回类型:GameTestAssertPosException
  • 修饰符:public

参数:

  • pos: BlockPos
  • descriptionId: String
  • arguments: Object…

说明:

TODO

public ServerLevel getLevel() @ L103

  • 方法名:getLevel
  • 源码定位:L103
  • 返回类型:ServerLevel
  • 修饰符:public

参数:

说明:

TODO

public BlockState getBlockState(BlockPos pos) @ L107

  • 方法名:getBlockState
  • 源码定位:L107
  • 返回类型:BlockState
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public <T extends BlockEntity> T getBlockEntity(BlockPos pos, Class<T> type) @ L111

  • 方法名:getBlockEntity
  • 源码定位:L111
  • 返回类型: T
  • 修饰符:public

参数:

  • pos: BlockPos
  • type: Class

说明:

TODO

public void killAllEntities() @ L122

  • 方法名:killAllEntities
  • 源码定位:L122
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

public void killAllEntitiesOfClass(Class<?extends Entity> baseClass) @ L126

  • 方法名:killAllEntitiesOfClass
  • 源码定位:L126
  • 返回类型:void
  • 修饰符:public

参数:

  • baseClass: Class<?extends Entity>

说明:

TODO

public ItemEntity spawnItem(Item item, Vec3 pos) @ L132

  • 方法名:spawnItem
  • 源码定位:L132
  • 返回类型:ItemEntity
  • 修饰符:public

参数:

  • item: Item
  • pos: Vec3

说明:

TODO

public ItemEntity spawnItem(Item item, float x, float y, float z) @ L141

  • 方法名:spawnItem
  • 源码定位:L141
  • 返回类型:ItemEntity
  • 修饰符:public

参数:

  • item: Item
  • x: float
  • y: float
  • z: float

说明:

TODO

public ItemEntity spawnItem(Item item, BlockPos pos) @ L145

  • 方法名:spawnItem
  • 源码定位:L145
  • 返回类型:ItemEntity
  • 修饰符:public

参数:

  • item: Item
  • pos: BlockPos

说明:

TODO

public void despawnItem(BlockPos pos, double distance) @ L149

  • 方法名:despawnItem
  • 源码定位:L149
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos
  • distance: double

说明:

TODO

public <E extends Entity> E spawn(EntityType<E> entityType, BlockPos pos) @ L157

  • 方法名:spawn
  • 源码定位:L157
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • pos: BlockPos

说明:

TODO

public <E extends Entity> List<E> spawn(EntityType<E> entityType, BlockPos pos, int amount) @ L161

  • 方法名:spawn
  • 源码定位:L161
  • 返回类型: List
  • 修饰符:public

参数:

  • entityType: EntityType
  • pos: BlockPos
  • amount: int

说明:

TODO

public <E extends Entity> List<E> spawn(EntityType<E> entityType, Vec3 pos, int amount) @ L165

  • 方法名:spawn
  • 源码定位:L165
  • 返回类型: List
  • 修饰符:public

参数:

  • entityType: EntityType
  • pos: Vec3
  • amount: int

说明:

TODO

public <E extends Entity> E spawn(EntityType<E> entityType, Vec3 pos) @ L175

  • 方法名:spawn
  • 源码定位:L175
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • pos: Vec3

说明:

TODO

public <E extends Entity> E spawn(EntityType<E> entityType, Vec3 pos, EntitySpawnReason spawnReason) @ L179

  • 方法名:spawn
  • 源码定位:L179
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • pos: Vec3
  • spawnReason: EntitySpawnReason

说明:

TODO

public <E extends Mob> E spawn(EntityType<E> entityType, int x, int y, int z, EntitySpawnReason entitySpawnReason) @ L203

  • 方法名:spawn
  • 源码定位:L203
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • x: int
  • y: int
  • z: int
  • entitySpawnReason: EntitySpawnReason

说明:

TODO

public void hurt(Entity entity, DamageSource source, float damage) @ L207

  • 方法名:hurt
  • 源码定位:L207
  • 返回类型:void
  • 修饰符:public

参数:

  • entity: Entity
  • source: DamageSource
  • damage: float

说明:

TODO

public void kill(Entity entity) @ L211

  • 方法名:kill
  • 源码定位:L211
  • 返回类型:void
  • 修饰符:public

参数:

  • entity: Entity

说明:

TODO

public void discard(Entity entity) @ L215

  • 方法名:discard
  • 源码定位:L215
  • 返回类型:void
  • 修饰符:public

参数:

  • entity: Entity

说明:

TODO

public <E extends Entity> E findOneEntity(EntityType<E> entityType) @ L219

  • 方法名:findOneEntity
  • 源码定位:L219
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType

说明:

TODO

public <E extends Entity> E findClosestEntity(EntityType<E> entityType, int x, int y, int z, double distance) @ L223

  • 方法名:findClosestEntity
  • 源码定位:L223
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • x: int
  • y: int
  • z: int
  • distance: double

说明:

TODO

public <E extends Entity> List<E> findEntities(EntityType<E> entityType, int x, int y, int z, double distance) @ L240

  • 方法名:findEntities
  • 源码定位:L240
  • 返回类型: List
  • 修饰符:public

参数:

  • entityType: EntityType
  • x: int
  • y: int
  • z: int
  • distance: double

说明:

TODO

public <E extends Entity> List<E> findEntities(EntityType<E> entityType, Vec3 pos, double distance) @ L244

  • 方法名:findEntities
  • 源码定位:L244
  • 返回类型: List
  • 修饰符:public

参数:

  • entityType: EntityType
  • pos: Vec3
  • distance: double

说明:

TODO

public <E extends Entity> E spawn(EntityType<E> entityType, int x, int y, int z) @ L252

  • 方法名:spawn
  • 源码定位:L252
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • x: int
  • y: int
  • z: int

说明:

TODO

public <E extends Entity> E spawn(EntityType<E> entityType, float x, float y, float z) @ L256

  • 方法名:spawn
  • 源码定位:L256
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • x: float
  • y: float
  • z: float

说明:

TODO

public <E extends Mob> E spawnWithNoFreeWill(EntityType<E> entityType, BlockPos pos) @ L260

  • 方法名:spawnWithNoFreeWill
  • 源码定位:L260
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • pos: BlockPos

说明:

TODO

public <E extends Mob> E spawnWithNoFreeWill(EntityType<E> entityType, int x, int y, int z) @ L266

  • 方法名:spawnWithNoFreeWill
  • 源码定位:L266
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • x: int
  • y: int
  • z: int

说明:

TODO

public <E extends Mob> E spawnWithNoFreeWill(EntityType<E> entityType, Vec3 pos) @ L270

  • 方法名:spawnWithNoFreeWill
  • 源码定位:L270
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • pos: Vec3

说明:

TODO

public <E extends Mob> E spawnWithNoFreeWill(EntityType<E> entityType, float x, float y, float z) @ L276

  • 方法名:spawnWithNoFreeWill
  • 源码定位:L276
  • 返回类型: E
  • 修饰符:public

参数:

  • entityType: EntityType
  • x: float
  • y: float
  • z: float

说明:

TODO

public void moveTo(Mob mob, float x, float y, float z) @ L280

  • 方法名:moveTo
  • 源码定位:L280
  • 返回类型:void
  • 修饰符:public

参数:

  • mob: Mob
  • x: float
  • y: float
  • z: float

说明:

TODO

public void moveTo(Mob mob, BlockPos pos) @ L284

  • 方法名:moveTo
  • 源码定位:L284
  • 返回类型:void
  • 修饰符:public

参数:

  • mob: Mob
  • pos: BlockPos

说明:

TODO

public void moveTo(Mob mob, Vec3 pos) @ L288

  • 方法名:moveTo
  • 源码定位:L288
  • 返回类型:void
  • 修饰符:public

参数:

  • mob: Mob
  • pos: Vec3

说明:

TODO

public GameTestSequence walkTo(Mob mob, BlockPos targetPos, float speedModifier) @ L293

  • 方法名:walkTo
  • 源码定位:L293
  • 返回类型:GameTestSequence
  • 修饰符:public

参数:

  • mob: Mob
  • targetPos: BlockPos
  • speedModifier: float

说明:

TODO

public void pressButton(int x, int y, int z) @ L300

  • 方法名:pressButton
  • 源码定位:L300
  • 返回类型:void
  • 修饰符:public

参数:

  • x: int
  • y: int
  • z: int

说明:

TODO

public void pressButton(BlockPos buttonPos) @ L304

  • 方法名:pressButton
  • 源码定位:L304
  • 返回类型:void
  • 修饰符:public

参数:

  • buttonPos: BlockPos

说明:

TODO

public void useBlock(BlockPos relativePos) @ L312

  • 方法名:useBlock
  • 源码定位:L312
  • 返回类型:void
  • 修饰符:public

参数:

  • relativePos: BlockPos

说明:

TODO

public void useBlock(BlockPos relativePos, Player player) @ L316

  • 方法名:useBlock
  • 源码定位:L316
  • 返回类型:void
  • 修饰符:public

参数:

  • relativePos: BlockPos
  • player: Player

说明:

TODO

public void useBlock(BlockPos relativePos, Player player, BlockHitResult hitResult) @ L321

  • 方法名:useBlock
  • 源码定位:L321
  • 返回类型:void
  • 修饰符:public

参数:

  • relativePos: BlockPos
  • player: Player
  • hitResult: BlockHitResult

说明:

TODO

public LivingEntity makeAboutToDrown(LivingEntity entity) @ L335

  • 方法名:makeAboutToDrown
  • 源码定位:L335
  • 返回类型:LivingEntity
  • 修饰符:public

参数:

  • entity: LivingEntity

说明:

TODO

public LivingEntity withLowHealth(LivingEntity entity) @ L341

  • 方法名:withLowHealth
  • 源码定位:L341
  • 返回类型:LivingEntity
  • 修饰符:public

参数:

  • entity: LivingEntity

说明:

TODO

public Player makeMockPlayer(GameType gameType) @ L346

  • 方法名:makeMockPlayer
  • 源码定位:L346
  • 返回类型:Player
  • 修饰符:public

参数:

  • gameType: GameType

说明:

TODO

public ServerPlayer makeMockServerPlayerInLevel() @ L364

  • 方法名:makeMockServerPlayerInLevel
  • 源码定位:L364
  • 返回类型:ServerPlayer
  • 修饰符:public

参数:

说明:

TODO

public void pullLever(int x, int y, int z) @ L383

  • 方法名:pullLever
  • 源码定位:L383
  • 返回类型:void
  • 修饰符:public

参数:

  • x: int
  • y: int
  • z: int

说明:

TODO

public void pullLever(BlockPos leverPos) @ L387

  • 方法名:pullLever
  • 源码定位:L387
  • 返回类型:void
  • 修饰符:public

参数:

  • leverPos: BlockPos

说明:

TODO

public void placeBlock(BlockPos relativePos, Block block, Direction relativePlaceDirection) @ L395

  • 方法名:placeBlock
  • 源码定位:L395
  • 返回类型:void
  • 修饰符:public

参数:

  • relativePos: BlockPos
  • block: Block
  • relativePlaceDirection: Direction

说明:

TODO

public void placeBlock(int x, int y, int z, Block block, Direction placeDirection) @ L410

  • 方法名:placeBlock
  • 源码定位:L410
  • 返回类型:void
  • 修饰符:public

参数:

  • x: int
  • y: int
  • z: int
  • block: Block
  • placeDirection: Direction

说明:

TODO

public void pulseRedstone(BlockPos pos, long duration) @ L414

  • 方法名:pulseRedstone
  • 源码定位:L414
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos
  • duration: long

说明:

TODO

public void destroyBlock(BlockPos pos) @ L419

  • 方法名:destroyBlock
  • 源码定位:L419
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public void setBlock(int x, int y, int z, Block block) @ L423

  • 方法名:setBlock
  • 源码定位:L423
  • 返回类型:void
  • 修饰符:public

参数:

  • x: int
  • y: int
  • z: int
  • block: Block

说明:

TODO

public void setBlock(int x, int y, int z, BlockState state) @ L427

  • 方法名:setBlock
  • 源码定位:L427
  • 返回类型:void
  • 修饰符:public

参数:

  • x: int
  • y: int
  • z: int
  • state: BlockState

说明:

TODO

public void setBlock(BlockPos blockPos, Block block) @ L431

  • 方法名:setBlock
  • 源码定位:L431
  • 返回类型:void
  • 修饰符:public

参数:

  • blockPos: BlockPos
  • block: Block

说明:

TODO

public void setBlock(BlockPos blockPos, BlockState state) @ L435

  • 方法名:setBlock
  • 源码定位:L435
  • 返回类型:void
  • 修饰符:public

参数:

  • blockPos: BlockPos
  • state: BlockState

说明:

TODO

public void setBlock(BlockPos blockPos, Block block, Direction direction) @ L439

  • 方法名:setBlock
  • 源码定位:L439
  • 返回类型:void
  • 修饰符:public

参数:

  • blockPos: BlockPos
  • block: Block
  • direction: Direction

说明:

TODO

public void setBlock(BlockPos blockPos, BlockState blockState, Direction direction) @ L443

  • 方法名:setBlock
  • 源码定位:L443
  • 返回类型:void
  • 修饰符:public

参数:

  • blockPos: BlockPos
  • blockState: BlockState
  • direction: Direction

说明:

TODO

public void assertBlockPresent(Block blockType, int x, int y, int z) @ L456

  • 方法名:assertBlockPresent
  • 源码定位:L456
  • 返回类型:void
  • 修饰符:public

参数:

  • blockType: Block
  • x: int
  • y: int
  • z: int

说明:

TODO

public void assertBlockPresent(Block blockType, BlockPos pos) @ L460

  • 方法名:assertBlockPresent
  • 源码定位:L460
  • 返回类型:void
  • 修饰符:public

参数:

  • blockType: Block
  • pos: BlockPos

说明:

TODO

public void assertBlockPresent(Block blockType) @ L465

  • 方法名:assertBlockPresent
  • 源码定位:L465
  • 返回类型:void
  • 修饰符:public

参数:

  • blockType: Block

说明:

TODO

public void assertBlockNotPresent(Block blockType, int x, int y, int z) @ L473

  • 方法名:assertBlockNotPresent
  • 源码定位:L473
  • 返回类型:void
  • 修饰符:public

参数:

  • blockType: Block
  • x: int
  • y: int
  • z: int

说明:

TODO

public void assertBlockNotPresent(Block blockType, BlockPos pos) @ L477

  • 方法名:assertBlockNotPresent
  • 源码定位:L477
  • 返回类型:void
  • 修饰符:public

参数:

  • blockType: Block
  • pos: BlockPos

说明:

TODO

public void assertBlockTag(TagKey<Block> tag, BlockPos pos) @ L483

  • 方法名:assertBlockTag
  • 源码定位:L483
  • 返回类型:void
  • 修饰符:public

参数:

  • tag: TagKey
  • pos: BlockPos

说明:

TODO

public void succeedWhenBlockPresent(Block block, int x, int y, int z) @ L491

  • 方法名:succeedWhenBlockPresent
  • 源码定位:L491
  • 返回类型:void
  • 修饰符:public

参数:

  • block: Block
  • x: int
  • y: int
  • z: int

说明:

TODO

public void succeedWhenBlockPresent(Block block, BlockPos pos) @ L495

  • 方法名:succeedWhenBlockPresent
  • 源码定位:L495
  • 返回类型:void
  • 修饰符:public

参数:

  • block: Block
  • pos: BlockPos

说明:

TODO

public void assertBlock(BlockPos pos, Predicate<Block> predicate, Function<Block,Component> errorMessage) @ L499

  • 方法名:assertBlock
  • 源码定位:L499
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos
  • predicate: Predicate
  • errorMessage: Function<Block,Component>

说明:

TODO

public <T extends Comparable<T>> void assertBlockProperty(BlockPos pos, Property<T> property, T value) @ L503

  • 方法名:assertBlockProperty
  • 源码定位:L503
  • 返回类型:<T extends Comparable> void
  • 修饰符:public

参数:

  • pos: BlockPos
  • property: Property
  • value: T

说明:

TODO

public <T extends Comparable<T>> void assertBlockProperty(BlockPos pos, Property<T> property, Predicate<T> predicate, Component errorMessage) @ L513

  • 方法名:assertBlockProperty
  • 源码定位:L513
  • 返回类型:<T extends Comparable> void
  • 修饰符:public

参数:

  • pos: BlockPos
  • property: Property
  • predicate: Predicate
  • errorMessage: Component

说明:

TODO

public void assertBlockState(BlockPos pos, BlockState expected) @ L524

  • 方法名:assertBlockState
  • 源码定位:L524
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos
  • expected: BlockState

说明:

TODO

public void assertBlockState(BlockPos pos, Predicate<BlockState> predicate, Function<BlockState,Component> errorMessage) @ L531

  • 方法名:assertBlockState
  • 源码定位:L531
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos
  • predicate: Predicate
  • errorMessage: Function<BlockState,Component>

说明:

TODO

public <T extends BlockEntity> void assertBlockEntityData(BlockPos pos, Class<T> type, Predicate<T> predicate, Supplier<Component> errorMessage) @ L538

  • 方法名:assertBlockEntityData
  • 源码定位:L538
  • 返回类型: void
  • 修饰符:public

参数:

  • pos: BlockPos
  • type: Class
  • predicate: Predicate
  • errorMessage: Supplier

说明:

TODO

public void assertRedstoneSignal(BlockPos pos, Direction direction, IntPredicate levelPredicate, Supplier<Component> errorMessage) @ L545

  • 方法名:assertRedstoneSignal
  • 源码定位:L545
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos
  • direction: Direction
  • levelPredicate: IntPredicate
  • errorMessage: Supplier

说明:

TODO

public void assertEntityPresent(EntityType<?> entityType) @ L555

  • 方法名:assertEntityPresent
  • 源码定位:L555
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>

说明:

TODO

public void assertEntityPresent(EntityType<?> entityType, int x, int y, int z) @ L561

  • 方法名:assertEntityPresent
  • 源码定位:L561
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • x: int
  • y: int
  • z: int

说明:

TODO

public void assertEntityPresent(EntityType<?> entityType, BlockPos pos) @ L565

  • 方法名:assertEntityPresent
  • 源码定位:L565
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • pos: BlockPos

说明:

TODO

public void assertEntityPresent(EntityType<?> entityType, AABB relativeAABB) @ L572

  • 方法名:assertEntityPresent
  • 源码定位:L572
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • relativeAABB: AABB

说明:

TODO

public void assertEntityPresent(EntityType<?> entityType, AABB relativeAABB, Component message) @ L579

  • 方法名:assertEntityPresent
  • 源码定位:L579
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • relativeAABB: AABB
  • message: Component

说明:

TODO

public void assertEntitiesPresent(EntityType<?> entityType, int expectedEntities) @ L586

  • 方法名:assertEntitiesPresent
  • 源码定位:L586
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • expectedEntities: int

说明:

TODO

public void assertEntitiesPresent(EntityType<?> entityType, BlockPos pos, int numOfExpectedEntities, double distance) @ L593

  • 方法名:assertEntitiesPresent
  • 源码定位:L593
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • pos: BlockPos
  • numOfExpectedEntities: int
  • distance: double

说明:

TODO

public void assertEntityPresent(EntityType<?> entityType, BlockPos pos, double distance) @ L601

  • 方法名:assertEntityPresent
  • 源码定位:L601
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • pos: BlockPos
  • distance: double

说明:

TODO

public <T extends Entity> List<T> getEntities(EntityType<T> entityType, BlockPos pos, double distance) @ L609

  • 方法名:getEntities
  • 源码定位:L609
  • 返回类型: List
  • 修饰符:public

参数:

  • entityType: EntityType
  • pos: BlockPos
  • distance: double

说明:

TODO

public <T extends Entity> List<T> getEntities(EntityType<T> entityType) @ L614

  • 方法名:getEntities
  • 源码定位:L614
  • 返回类型: List
  • 修饰符:public

参数:

  • entityType: EntityType

说明:

TODO

public void assertEntityInstancePresent(Entity entity, int x, int y, int z) @ L618

  • 方法名:assertEntityInstancePresent
  • 源码定位:L618
  • 返回类型:void
  • 修饰符:public

参数:

  • entity: Entity
  • x: int
  • y: int
  • z: int

说明:

TODO

public void assertEntityInstancePresent(Entity entity, BlockPos pos) @ L622

  • 方法名:assertEntityInstancePresent
  • 源码定位:L622
  • 返回类型:void
  • 修饰符:public

参数:

  • entity: Entity
  • pos: BlockPos

说明:

TODO

public void assertEntityInstancePresent(Entity entity, BlockPos pos, double inflate) @ L626

  • 方法名:assertEntityInstancePresent
  • 源码定位:L626
  • 返回类型:void
  • 修饰符:public

参数:

  • entity: Entity
  • pos: BlockPos
  • inflate: double

说明:

TODO

public void assertItemEntityCountIs(Item itemType, BlockPos pos, double distance, int count) @ L635

  • 方法名:assertItemEntityCountIs
  • 源码定位:L635
  • 返回类型:void
  • 修饰符:public

参数:

  • itemType: Item
  • pos: BlockPos
  • distance: double
  • count: int

说明:

TODO

public void assertItemEntityPresent(Item itemType, BlockPos pos, double distance) @ L652

  • 方法名:assertItemEntityPresent
  • 源码定位:L652
  • 返回类型:void
  • 修饰符:public

参数:

  • itemType: Item
  • pos: BlockPos
  • distance: double

说明:

TODO

public void assertItemEntityNotPresent(Item itemType, BlockPos pos, double distance) @ L660

  • 方法名:assertItemEntityNotPresent
  • 源码定位:L660
  • 返回类型:void
  • 修饰符:public

参数:

  • itemType: Item
  • pos: BlockPos
  • distance: double

说明:

TODO

public void assertItemEntityPresent(Item itemType) @ L668

  • 方法名:assertItemEntityPresent
  • 源码定位:L668
  • 返回类型:void
  • 修饰符:public

参数:

  • itemType: Item

说明:

TODO

public void assertItemEntityNotPresent(Item itemType) @ L675

  • 方法名:assertItemEntityNotPresent
  • 源码定位:L675
  • 返回类型:void
  • 修饰符:public

参数:

  • itemType: Item

说明:

TODO

public void assertEntityNotPresent(EntityType<?> entityType) @ L682

  • 方法名:assertEntityNotPresent
  • 源码定位:L682
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>

说明:

TODO

public void assertEntityNotPresent(EntityType<?> entityType, int x, int y, int z) @ L689

  • 方法名:assertEntityNotPresent
  • 源码定位:L689
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • x: int
  • y: int
  • z: int

说明:

TODO

public void assertEntityNotPresent(EntityType<?> entityType, BlockPos pos) @ L693

  • 方法名:assertEntityNotPresent
  • 源码定位:L693
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • pos: BlockPos

说明:

TODO

public void assertEntityNotPresent(EntityType<?> entityType, AABB relativeAABB) @ L700

  • 方法名:assertEntityNotPresent
  • 源码定位:L700
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • relativeAABB: AABB

说明:

TODO

public void assertEntityTouching(EntityType<?> entityType, double x, double y, double z) @ L708

  • 方法名:assertEntityTouching
  • 源码定位:L708
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • x: double
  • y: double
  • z: double

说明:

TODO

public void assertEntityNotTouching(EntityType<?> entityType, double x, double y, double z) @ L719

  • 方法名:assertEntityNotTouching
  • 源码定位:L719
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • x: double
  • y: double
  • z: double

说明:

TODO

public <E extends Entity,T> void assertEntityData(BlockPos pos, EntityType<E> entityType, Predicate<E> test) @ L730

  • 方法名:assertEntityData
  • 源码定位:L730
  • 返回类型:<E extends Entity,T> void
  • 修饰符:public

参数:

  • pos: BlockPos
  • entityType: EntityType
  • test: Predicate

说明:

TODO

public <E extends Entity,T> void assertEntityData(BlockPos pos, EntityType<E> entityType, Function<?super E,T> dataAccessor, T data) @ L744

  • 方法名:assertEntityData
  • 源码定位:L744
  • 返回类型:<E extends Entity,T> void
  • 修饰符:public

参数:

  • pos: BlockPos
  • entityType: EntityType
  • dataAccessor: Function<?super E,T>
  • data: T

说明:

TODO

public <E extends Entity,T> void assertEntityData(AABB box, EntityType<E> entityType, Function<?super E,T> dataAccessor, T data) @ L748

  • 方法名:assertEntityData
  • 源码定位:L748
  • 返回类型:<E extends Entity,T> void
  • 修饰符:public

参数:

  • box: AABB
  • entityType: EntityType
  • dataAccessor: Function<?super E,T>
  • data: T

说明:

TODO

public <E extends LivingEntity> void assertEntityIsHolding(BlockPos pos, EntityType<E> entityType, Item item) @ L762

  • 方法名:assertEntityIsHolding
  • 源码定位:L762
  • 返回类型: void
  • 修饰符:public

参数:

  • pos: BlockPos
  • entityType: EntityType
  • item: Item

说明:

TODO

public <E extends Entity &InventoryCarrier> void assertEntityInventoryContains(BlockPos pos, EntityType<E> entityType, Item item) @ L778

  • 方法名:assertEntityInventoryContains
  • 源码定位:L778
  • 返回类型:<E extends Entity &InventoryCarrier> void
  • 修饰符:public

参数:

  • pos: BlockPos
  • entityType: EntityType
  • item: Item

说明:

TODO

public void assertContainerEmpty(BlockPos pos) @ L794

  • 方法名:assertContainerEmpty
  • 源码定位:L794
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public void assertContainerContainsSingle(BlockPos pos, Item item) @ L801

  • 方法名:assertContainerContainsSingle
  • 源码定位:L801
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos
  • item: Item

说明:

TODO

public void assertContainerContains(BlockPos pos, Item item) @ L808

  • 方法名:assertContainerContains
  • 源码定位:L808
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos
  • item: Item

说明:

TODO

public void assertSameBlockStates(BoundingBox sourceBoundingBox, BlockPos targetBoundingBoxCorner) @ L815

  • 方法名:assertSameBlockStates
  • 源码定位:L815
  • 返回类型:void
  • 修饰符:public

参数:

  • sourceBoundingBox: BoundingBox
  • targetBoundingBoxCorner: BlockPos

说明:

TODO

public void assertSameBlockState(BlockPos sourcePos, BlockPos targetPos) @ L827

  • 方法名:assertSameBlockState
  • 源码定位:L827
  • 返回类型:void
  • 修饰符:public

参数:

  • sourcePos: BlockPos
  • targetPos: BlockPos

说明:

TODO

public void assertAtTickTimeContainerContains(long time, BlockPos pos, Item item) @ L835

  • 方法名:assertAtTickTimeContainerContains
  • 源码定位:L835
  • 返回类型:void
  • 修饰符:public

参数:

  • time: long
  • pos: BlockPos
  • item: Item

说明:

TODO

public void assertAtTickTimeContainerEmpty(long time, BlockPos pos) @ L839

  • 方法名:assertAtTickTimeContainerEmpty
  • 源码定位:L839
  • 返回类型:void
  • 修饰符:public

参数:

  • time: long
  • pos: BlockPos

说明:

TODO

public <E extends Entity,T> void succeedWhenEntityData(BlockPos pos, EntityType<E> entityType, Function<E,T> dataAccessor, T data) @ L843

  • 方法名:succeedWhenEntityData
  • 源码定位:L843
  • 返回类型:<E extends Entity,T> void
  • 修饰符:public

参数:

  • pos: BlockPos
  • entityType: EntityType
  • dataAccessor: Function<E,T>
  • data: T

说明:

TODO

public <E extends Entity> void assertEntityProperty(E entity, Predicate<E> test, Component description) @ L847

  • 方法名:assertEntityProperty
  • 源码定位:L847
  • 返回类型: void
  • 修饰符:public

参数:

  • entity: E
  • test: Predicate
  • description: Component

说明:

TODO

public <E extends Entity,T> void assertEntityProperty(E entity, Function<E,T> test, T expected, Component description) @ L853

  • 方法名:assertEntityProperty
  • 源码定位:L853
  • 返回类型:<E extends Entity,T> void
  • 修饰符:public

参数:

  • entity: E
  • test: Function<E,T>
  • expected: T
  • description: Component

说明:

TODO

public void assertLivingEntityHasMobEffect(LivingEntity entity, Holder<MobEffect> mobEffect, int amplifier) @ L860

  • 方法名:assertLivingEntityHasMobEffect
  • 源码定位:L860
  • 返回类型:void
  • 修饰符:public

参数:

  • entity: LivingEntity
  • mobEffect: Holder
  • amplifier: int

说明:

TODO

public void succeedWhenEntityPresent(EntityType<?> entityType, int x, int y, int z) @ L867

  • 方法名:succeedWhenEntityPresent
  • 源码定位:L867
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • x: int
  • y: int
  • z: int

说明:

TODO

public void succeedWhenEntityPresent(EntityType<?> entityType, BlockPos pos) @ L871

  • 方法名:succeedWhenEntityPresent
  • 源码定位:L871
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • pos: BlockPos

说明:

TODO

public void succeedWhenEntityNotPresent(EntityType<?> entityType, int x, int y, int z) @ L875

  • 方法名:succeedWhenEntityNotPresent
  • 源码定位:L875
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • x: int
  • y: int
  • z: int

说明:

TODO

public void succeedWhenEntityNotPresent(EntityType<?> entityType, BlockPos pos) @ L879

  • 方法名:succeedWhenEntityNotPresent
  • 源码定位:L879
  • 返回类型:void
  • 修饰符:public

参数:

  • entityType: EntityType<?>
  • pos: BlockPos

说明:

TODO

public void succeed() @ L883

  • 方法名:succeed
  • 源码定位:L883
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

private void ensureSingleFinalCheck() @ L887

  • 方法名:ensureSingleFinalCheck
  • 源码定位:L887
  • 返回类型:void
  • 修饰符:private

参数:

说明:

TODO

public void succeedIf(Runnable asserter) @ L895

  • 方法名:succeedIf
  • 源码定位:L895
  • 返回类型:void
  • 修饰符:public

参数:

  • asserter: Runnable

说明:

TODO

public void succeedWhen(Runnable asserter) @ L900

  • 方法名:succeedWhen
  • 源码定位:L900
  • 返回类型:void
  • 修饰符:public

参数:

  • asserter: Runnable

说明:

TODO

public void succeedOnTickWhen(int tick, Runnable asserter) @ L905

  • 方法名:succeedOnTickWhen
  • 源码定位:L905
  • 返回类型:void
  • 修饰符:public

参数:

  • tick: int
  • asserter: Runnable

说明:

TODO

public void runAtTickTime(long time, Runnable asserter) @ L910

  • 方法名:runAtTickTime
  • 源码定位:L910
  • 返回类型:void
  • 修饰符:public

参数:

  • time: long
  • asserter: Runnable

说明:

TODO

public void runBeforeTestEnd(Runnable asserter) @ L914

  • 方法名:runBeforeTestEnd
  • 源码定位:L914
  • 返回类型:void
  • 修饰符:public

参数:

  • asserter: Runnable

说明:

TODO

public void runAfterDelay(long ticksToDelay, Runnable whatToRun) @ L918

  • 方法名:runAfterDelay
  • 源码定位:L918
  • 返回类型:void
  • 修饰符:public

参数:

  • ticksToDelay: long
  • whatToRun: Runnable

说明:

TODO

public void setTime(long ticks) @ L922

  • 方法名:setTime
  • 源码定位:L922
  • 返回类型:void
  • 修饰符:public

参数:

  • ticks: long

说明:

TODO

public void randomTick(BlockPos pos) @ L928

  • 方法名:randomTick
  • 源码定位:L928
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public void tickBlock(BlockPos pos) @ L934

  • 方法名:tickBlock
  • 源码定位:L934
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public void tickPrecipitation(BlockPos pos) @ L940

  • 方法名:tickPrecipitation
  • 源码定位:L940
  • 返回类型:void
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public void tickPrecipitation() @ L946

  • 方法名:tickPrecipitation
  • 源码定位:L946
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

public int getHeight(Heightmap.Types heightmap, int x, int z) @ L959

  • 方法名:getHeight
  • 源码定位:L959
  • 返回类型:int
  • 修饰符:public

参数:

  • heightmap: Heightmap.Types
  • x: int
  • z: int

说明:

TODO

public void fail(Component message, BlockPos pos) @ L964

  • 方法名:fail
  • 源码定位:L964
  • 返回类型:void
  • 修饰符:public

参数:

  • message: Component
  • pos: BlockPos

说明:

TODO

public void fail(Component message, Entity entity) @ L968

  • 方法名:fail
  • 源码定位:L968
  • 返回类型:void
  • 修饰符:public

参数:

  • message: Component
  • entity: Entity

说明:

TODO

public void fail(Component message) @ L972

  • 方法名:fail
  • 源码定位:L972
  • 返回类型:void
  • 修饰符:public

参数:

  • message: Component

说明:

TODO

public void fail(String message) @ L976

  • 方法名:fail
  • 源码定位:L976
  • 返回类型:void
  • 修饰符:public

参数:

  • message: String

说明:

TODO

public void failIf(Runnable asserter) @ L980

  • 方法名:failIf
  • 源码定位:L980
  • 返回类型:void
  • 修饰符:public

参数:

  • asserter: Runnable

说明:

TODO

public void failIfEver(Runnable asserter) @ L984

  • 方法名:failIfEver
  • 源码定位:L984
  • 返回类型:void
  • 修饰符:public

参数:

  • asserter: Runnable

说明:

TODO

public GameTestSequence startSequence() @ L988

  • 方法名:startSequence
  • 源码定位:L988
  • 返回类型:GameTestSequence
  • 修饰符:public

参数:

说明:

TODO

public BlockPos absolutePos(BlockPos relativePos) @ L992

  • 方法名:absolutePos
  • 源码定位:L992
  • 返回类型:BlockPos
  • 修饰符:public

参数:

  • relativePos: BlockPos

说明:

TODO

public BlockPos relativePos(BlockPos absolutePos) @ L998

  • 方法名:relativePos
  • 源码定位:L998
  • 返回类型:BlockPos
  • 修饰符:public

参数:

  • absolutePos: BlockPos

说明:

TODO

public AABB absoluteAABB(AABB relativeAABB) @ L1005

  • 方法名:absoluteAABB
  • 源码定位:L1005
  • 返回类型:AABB
  • 修饰符:public

参数:

  • relativeAABB: AABB

说明:

TODO

public AABB relativeAABB(AABB absoluteAABB) @ L1011

  • 方法名:relativeAABB
  • 源码定位:L1011
  • 返回类型:AABB
  • 修饰符:public

参数:

  • absoluteAABB: AABB

说明:

TODO

public Vec3 absoluteVec(Vec3 relativeVec) @ L1017

  • 方法名:absoluteVec
  • 源码定位:L1017
  • 返回类型:Vec3
  • 修饰符:public

参数:

  • relativeVec: Vec3

说明:

TODO

public Vec3 relativeVec(Vec3 absoluteVec) @ L1022

  • 方法名:relativeVec
  • 源码定位:L1022
  • 返回类型:Vec3
  • 修饰符:public

参数:

  • absoluteVec: Vec3

说明:

TODO

public Rotation getTestRotation() @ L1027

  • 方法名:getTestRotation
  • 源码定位:L1027
  • 返回类型:Rotation
  • 修饰符:public

参数:

说明:

TODO

public Direction getTestDirection() @ L1031

  • 方法名:getTestDirection
  • 源码定位:L1031
  • 返回类型:Direction
  • 修饰符:public

参数:

说明:

TODO

public Direction getAbsoluteDirection(Direction direction) @ L1035

  • 方法名:getAbsoluteDirection
  • 源码定位:L1035
  • 返回类型:Direction
  • 修饰符:public

参数:

  • direction: Direction

说明:

TODO

public void assertTrue(boolean condition, Component errorMessage) @ L1039

  • 方法名:assertTrue
  • 源码定位:L1039
  • 返回类型:void
  • 修饰符:public

参数:

  • condition: boolean
  • errorMessage: Component

说明:

TODO

public void assertTrue(boolean condition, String errorMessage) @ L1045

  • 方法名:assertTrue
  • 源码定位:L1045
  • 返回类型:void
  • 修饰符:public

参数:

  • condition: boolean
  • errorMessage: String

说明:

TODO

public <N> void assertValueEqual(N value, N expected, String valueName) @ L1049

  • 方法名:assertValueEqual
  • 源码定位:L1049
  • 返回类型: void
  • 修饰符:public

参数:

  • value: N
  • expected: N
  • valueName: String

说明:

TODO

public <N> void assertValueEqual(N value, N expected, Component valueName) @ L1053

  • 方法名:assertValueEqual
  • 源码定位:L1053
  • 返回类型: void
  • 修饰符:public

参数:

  • value: N
  • expected: N
  • valueName: Component

说明:

TODO

public void assertFalse(boolean condition, Component errorMessage) @ L1059

  • 方法名:assertFalse
  • 源码定位:L1059
  • 返回类型:void
  • 修饰符:public

参数:

  • condition: boolean
  • errorMessage: Component

说明:

TODO

public void assertFalse(boolean condition, String errorMessage) @ L1063

  • 方法名:assertFalse
  • 源码定位:L1063
  • 返回类型:void
  • 修饰符:public

参数:

  • condition: boolean
  • errorMessage: String

说明:

TODO

public long getTick() @ L1067

  • 方法名:getTick
  • 源码定位:L1067
  • 返回类型:long
  • 修饰符:public

参数:

说明:

TODO

public AABB getBounds() @ L1071

  • 方法名:getBounds
  • 源码定位:L1071
  • 返回类型:AABB
  • 修饰符:public

参数:

说明:

TODO

public AABB getBoundsWithPadding() @ L1075

  • 方法名:getBoundsWithPadding
  • 源码定位:L1075
  • 返回类型:AABB
  • 修饰符:public

参数:

说明:

TODO

public AABB getRelativeBounds() @ L1079

  • 方法名:getRelativeBounds
  • 源码定位:L1079
  • 返回类型:AABB
  • 修饰符:public

参数:

说明:

TODO

public void forEveryBlockInStructure(Consumer<BlockPos> forBlock) @ L1091

  • 方法名:forEveryBlockInStructure
  • 源码定位:L1091
  • 返回类型:void
  • 修饰符:public

参数:

  • forBlock: Consumer

说明:

TODO

public void onEachTick(Runnable action) @ L1096

  • 方法名:onEachTick
  • 源码定位:L1096
  • 返回类型:void
  • 修饰符:public

参数:

  • action: Runnable

说明:

TODO

public void placeAt(Player player, ItemStack blockStack, BlockPos pos, Direction face) @ L1100

  • 方法名:placeAt
  • 源码定位:L1100
  • 返回类型:void
  • 修饰符:public

参数:

  • player: Player
  • blockStack: ItemStack
  • pos: BlockPos
  • face: Direction

说明:

TODO

public void setBiome(ResourceKey<Biome> biome) @ L1107

  • 方法名:setBiome
  • 源码定位:L1107
  • 返回类型:void
  • 修饰符:public

参数:

  • biome: ResourceKey

说明:

TODO

private static Component getItemName(Item itemType) @ L1119

  • 方法名:getItemName
  • 源码定位:L1119
  • 返回类型:Component
  • 修饰符:private static

参数:

  • itemType: Item

说明:

TODO

代码

public class GameTestHelper {
    private final GameTestInfo testInfo;
    private boolean finalCheckAdded;
 
    public GameTestHelper(GameTestInfo testInfo) {
        this.testInfo = testInfo;
    }
 
    public GameTestAssertException assertionException(Component description) {
        return new GameTestAssertException(description, this.testInfo.getTick());
    }
 
    public GameTestAssertException assertionException(String descriptionId, Object... arguments) {
        return this.assertionException(Component.translatableEscape(descriptionId, arguments));
    }
 
    public GameTestAssertPosException assertionException(BlockPos pos, Component description) {
        return new GameTestAssertPosException(description, this.absolutePos(pos), pos, this.testInfo.getTick());
    }
 
    public GameTestAssertPosException assertionException(BlockPos pos, String descriptionId, Object... arguments) {
        return this.assertionException(pos, Component.translatableEscape(descriptionId, arguments));
    }
 
    public ServerLevel getLevel() {
        return this.testInfo.getLevel();
    }
 
    public BlockState getBlockState(BlockPos pos) {
        return this.getLevel().getBlockState(this.absolutePos(pos));
    }
 
    public <T extends BlockEntity> T getBlockEntity(BlockPos pos, Class<T> type) {
        BlockEntity blockEntity = this.getLevel().getBlockEntity(this.absolutePos(pos));
        if (blockEntity == null) {
            throw this.assertionException(pos, "test.error.missing_block_entity");
        } else if (type.isInstance(blockEntity)) {
            return type.cast(blockEntity);
        } else {
            throw this.assertionException(pos, "test.error.wrong_block_entity", blockEntity.typeHolder().getRegisteredName());
        }
    }
 
    public void killAllEntities() {
        this.killAllEntitiesOfClass(Entity.class);
    }
 
    public void killAllEntitiesOfClass(Class<? extends Entity> baseClass) {
        AABB bounds = this.getBounds();
        List<? extends Entity> entities = this.getLevel().getEntitiesOfClass(baseClass, bounds.inflate(1.0), mob -> !(mob instanceof Player));
        entities.forEach(entity -> entity.kill(this.getLevel()));
    }
 
    public ItemEntity spawnItem(Item item, Vec3 pos) {
        ServerLevel level = this.getLevel();
        Vec3 absoluteVec = this.absoluteVec(pos);
        ItemEntity itemEntity = new ItemEntity(level, absoluteVec.x, absoluteVec.y, absoluteVec.z, new ItemStack(item, 1));
        itemEntity.setDeltaMovement(0.0, 0.0, 0.0);
        level.addFreshEntity(itemEntity);
        return itemEntity;
    }
 
    public ItemEntity spawnItem(Item item, float x, float y, float z) {
        return this.spawnItem(item, new Vec3(x, y, z));
    }
 
    public ItemEntity spawnItem(Item item, BlockPos pos) {
        return this.spawnItem(item, pos.getX(), pos.getY(), pos.getZ());
    }
 
    public void despawnItem(BlockPos pos, double distance) {
        BlockPos absolutePos = this.absolutePos(pos);
 
        for (ItemEntity entity : this.getLevel().getEntities(EntityType.ITEM, new AABB(absolutePos).inflate(distance), Entity::isAlive)) {
            entity.remove(Entity.RemovalReason.KILLED);
        }
    }
 
    public <E extends Entity> E spawn(EntityType<E> entityType, BlockPos pos) {
        return this.spawn(entityType, Vec3.atBottomCenterOf(pos));
    }
 
    public <E extends Entity> List<E> spawn(EntityType<E> entityType, BlockPos pos, int amount) {
        return this.spawn(entityType, Vec3.atBottomCenterOf(pos), amount);
    }
 
    public <E extends Entity> List<E> spawn(EntityType<E> entityType, Vec3 pos, int amount) {
        List<E> entities = new ArrayList<>();
 
        for (int i = 0; i < amount; i++) {
            entities.add(this.spawn(entityType, pos));
        }
 
        return entities;
    }
 
    public <E extends Entity> E spawn(EntityType<E> entityType, Vec3 pos) {
        return this.spawn(entityType, pos, null);
    }
 
    public <E extends Entity> E spawn(EntityType<E> entityType, Vec3 pos, @Nullable EntitySpawnReason spawnReason) {
        ServerLevel level = this.getLevel();
        E entity = entityType.create(level, EntitySpawnReason.STRUCTURE);
        if (entity == null) {
            throw this.assertionException(BlockPos.containing(pos), "test.error.spawn_failure", entityType.builtInRegistryHolder().getRegisteredName());
        } else {
            if (entity instanceof Mob mob) {
                mob.setPersistenceRequired();
            }
 
            Vec3 absoluteVec = this.absoluteVec(pos);
            float yRot = entity.rotate(this.getTestRotation());
            entity.snapTo(absoluteVec.x, absoluteVec.y, absoluteVec.z, yRot, entity.getXRot());
            entity.setYBodyRot(yRot);
            entity.setYHeadRot(yRot);
            if (spawnReason != null && entity instanceof Mob mob) {
                mob.finalizeSpawn(this.getLevel(), this.getLevel().getCurrentDifficultyAt(mob.blockPosition()), spawnReason, null);
            }
 
            level.addFreshEntityWithPassengers(entity);
            return entity;
        }
    }
 
    public <E extends Mob> E spawn(EntityType<E> entityType, int x, int y, int z, EntitySpawnReason entitySpawnReason) {
        return this.spawn(entityType, new Vec3(x, y, z), entitySpawnReason);
    }
 
    public void hurt(Entity entity, DamageSource source, float damage) {
        entity.hurtServer(this.getLevel(), source, damage);
    }
 
    public void kill(Entity entity) {
        entity.kill(this.getLevel());
    }
 
    public void discard(Entity entity) {
        entity.discard();
    }
 
    public <E extends Entity> E findOneEntity(EntityType<E> entityType) {
        return this.findClosestEntity(entityType, 0, 0, 0, 2.147483647E9);
    }
 
    public <E extends Entity> E findClosestEntity(EntityType<E> entityType, int x, int y, int z, double distance) {
        List<E> entities = this.findEntities(entityType, x, y, z, distance);
        if (entities.isEmpty()) {
            throw this.assertionException("test.error.expected_entity_around", entityType.getDescription(), x, y, z);
        } else if (entities.size() > 1) {
            throw this.assertionException("test.error.too_many_entities", entityType.toShortString(), x, y, z, entities.size());
        } else {
            Vec3 center = this.absoluteVec(new Vec3(x, y, z));
            entities.sort((e1, e2) -> {
                double d1 = e1.position().distanceTo(center);
                double d2 = e2.position().distanceTo(center);
                return Double.compare(d1, d2);
            });
            return entities.get(0);
        }
    }
 
    public <E extends Entity> List<E> findEntities(EntityType<E> entityType, int x, int y, int z, double distance) {
        return this.findEntities(entityType, Vec3.atBottomCenterOf(new BlockPos(x, y, z)), distance);
    }
 
    public <E extends Entity> List<E> findEntities(EntityType<E> entityType, Vec3 pos, double distance) {
        ServerLevel level = this.getLevel();
        Vec3 absoluteVec = this.absoluteVec(pos);
        AABB structureBounds = this.testInfo.getStructureBounds();
        AABB containedBounds = new AABB(absoluteVec.add(-distance, -distance, -distance), absoluteVec.add(distance, distance, distance));
        return level.getEntities(entityType, structureBounds, e -> e.getBoundingBox().intersects(containedBounds) && e.isAlive());
    }
 
    public <E extends Entity> E spawn(EntityType<E> entityType, int x, int y, int z) {
        return this.spawn(entityType, new BlockPos(x, y, z));
    }
 
    public <E extends Entity> E spawn(EntityType<E> entityType, float x, float y, float z) {
        return this.spawn(entityType, new Vec3(x, y, z));
    }
 
    public <E extends Mob> E spawnWithNoFreeWill(EntityType<E> entityType, BlockPos pos) {
        E entity = (E)this.spawn(entityType, pos);
        entity.removeFreeWill();
        return entity;
    }
 
    public <E extends Mob> E spawnWithNoFreeWill(EntityType<E> entityType, int x, int y, int z) {
        return this.spawnWithNoFreeWill(entityType, new BlockPos(x, y, z));
    }
 
    public <E extends Mob> E spawnWithNoFreeWill(EntityType<E> entityType, Vec3 pos) {
        E entity = (E)this.spawn(entityType, pos);
        entity.removeFreeWill();
        return entity;
    }
 
    public <E extends Mob> E spawnWithNoFreeWill(EntityType<E> entityType, float x, float y, float z) {
        return this.spawnWithNoFreeWill(entityType, new Vec3(x, y, z));
    }
 
    public void moveTo(Mob mob, float x, float y, float z) {
        this.moveTo(mob, new Vec3(x, y, z));
    }
 
    public void moveTo(Mob mob, BlockPos pos) {
        this.moveTo(mob, pos.getBottomCenter());
    }
 
    public void moveTo(Mob mob, Vec3 pos) {
        Vec3 absoluteVec = this.absoluteVec(pos);
        mob.snapTo(absoluteVec.x, absoluteVec.y, absoluteVec.z, mob.getYRot(), mob.getXRot());
    }
 
    public GameTestSequence walkTo(Mob mob, BlockPos targetPos, float speedModifier) {
        return this.startSequence().thenExecuteAfter(2, () -> {
            Path path = mob.getNavigation().createPath(this.absolutePos(targetPos), 0);
            mob.getNavigation().moveTo(path, (double)speedModifier);
        });
    }
 
    public void pressButton(int x, int y, int z) {
        this.pressButton(new BlockPos(x, y, z));
    }
 
    public void pressButton(BlockPos buttonPos) {
        this.assertBlockTag(BlockTags.BUTTONS, buttonPos);
        BlockPos absolutePos = this.absolutePos(buttonPos);
        BlockState blockState = this.getLevel().getBlockState(absolutePos);
        ButtonBlock buttonBlock = (ButtonBlock)blockState.getBlock();
        buttonBlock.press(blockState, this.getLevel(), absolutePos, null);
    }
 
    public void useBlock(BlockPos relativePos) {
        this.useBlock(relativePos, this.makeMockPlayer(GameType.CREATIVE));
    }
 
    public void useBlock(BlockPos relativePos, Player player) {
        BlockPos absolutePos = this.absolutePos(relativePos);
        this.useBlock(relativePos, player, new BlockHitResult(Vec3.atCenterOf(absolutePos), Direction.NORTH, absolutePos, true));
    }
 
    public void useBlock(BlockPos relativePos, Player player, BlockHitResult hitResult) {
        BlockPos absolutePos = this.absolutePos(relativePos);
        BlockState blockState = this.getLevel().getBlockState(absolutePos);
        InteractionHand hand = InteractionHand.MAIN_HAND;
        InteractionResult itemInteractionResult = blockState.useItemOn(player.getItemInHand(hand), this.getLevel(), player, hand, hitResult);
        if (!itemInteractionResult.consumesAction()) {
            if (!(itemInteractionResult instanceof InteractionResult.TryEmptyHandInteraction)
                || !blockState.useWithoutItem(this.getLevel(), player, hitResult).consumesAction()) {
                UseOnContext context = new UseOnContext(player, hand, hitResult);
                player.getItemInHand(hand).useOn(context);
            }
        }
    }
 
    public LivingEntity makeAboutToDrown(LivingEntity entity) {
        entity.setAirSupply(0);
        entity.setHealth(0.25F);
        return entity;
    }
 
    public LivingEntity withLowHealth(LivingEntity entity) {
        entity.setHealth(0.25F);
        return entity;
    }
 
    public Player makeMockPlayer(GameType gameType) {
        return new Player(this.getLevel(), new GameProfile(UUID.randomUUID(), "test-mock-player")) {
            {
                Objects.requireNonNull(GameTestHelper.this);
            }
 
            @Override
            public GameType gameMode() {
                return gameType;
            }
 
            @Override
            public boolean isClientAuthoritative() {
                return false;
            }
        };
    }
 
    @Deprecated(forRemoval = true)
    public ServerPlayer makeMockServerPlayerInLevel() {
        CommonListenerCookie cookie = CommonListenerCookie.createInitial(new GameProfile(UUID.randomUUID(), "test-mock-player"), false);
        ServerPlayer player = new ServerPlayer(this.getLevel().getServer(), this.getLevel(), cookie.gameProfile(), cookie.clientInformation()) {
            {
                Objects.requireNonNull(GameTestHelper.this);
            }
 
            @Override
            public GameType gameMode() {
                return GameType.CREATIVE;
            }
        };
        Connection connection = new Connection(PacketFlow.SERVERBOUND);
        new EmbeddedChannel(connection);
        this.getLevel().getServer().getPlayerList().placeNewPlayer(connection, player, cookie);
        return player;
    }
 
    public void pullLever(int x, int y, int z) {
        this.pullLever(new BlockPos(x, y, z));
    }
 
    public void pullLever(BlockPos leverPos) {
        this.assertBlockPresent(Blocks.LEVER, leverPos);
        BlockPos absolutePos = this.absolutePos(leverPos);
        BlockState blockState = this.getLevel().getBlockState(absolutePos);
        LeverBlock leverBlock = (LeverBlock)blockState.getBlock();
        leverBlock.pull(blockState, this.getLevel(), absolutePos, null);
    }
 
    public void placeBlock(BlockPos relativePos, Block block, Direction relativePlaceDirection) {
        BlockPos pos = this.absolutePos(relativePos);
        Direction placeDirection = this.getAbsoluteDirection(relativePlaceDirection);
        Item item = block.asItem();
        if (item instanceof BlockItem blockItem) {
            BlockHitResult hitResult = new BlockHitResult(Vec3.atCenterOf(pos), Direction.DOWN, pos, true);
            BlockPlaceContext context = new GameTestHelper.TestBlockPlaceContext(
                this.getLevel(), InteractionHand.MAIN_HAND, item.getDefaultInstance(), hitResult, placeDirection
            );
            blockItem.place(context);
        } else {
            this.fail(Component.translatable("test.error.not_a_block_item"));
        }
    }
 
    public void placeBlock(int x, int y, int z, Block block, Direction placeDirection) {
        this.placeBlock(new BlockPos(x, y, z), block, placeDirection);
    }
 
    public void pulseRedstone(BlockPos pos, long duration) {
        this.setBlock(pos, Blocks.REDSTONE_BLOCK);
        this.runAfterDelay(duration, () -> this.setBlock(pos, Blocks.AIR));
    }
 
    public void destroyBlock(BlockPos pos) {
        this.getLevel().destroyBlock(this.absolutePos(pos), false, null);
    }
 
    public void setBlock(int x, int y, int z, Block block) {
        this.setBlock(new BlockPos(x, y, z), block);
    }
 
    public void setBlock(int x, int y, int z, BlockState state) {
        this.setBlock(new BlockPos(x, y, z), state);
    }
 
    public void setBlock(BlockPos blockPos, Block block) {
        this.setBlock(blockPos, block.defaultBlockState());
    }
 
    public void setBlock(BlockPos blockPos, BlockState state) {
        this.getLevel().setBlock(this.absolutePos(blockPos), state, 3);
    }
 
    public void setBlock(BlockPos blockPos, Block block, Direction direction) {
        this.setBlock(blockPos, block.defaultBlockState(), direction);
    }
 
    public void setBlock(BlockPos blockPos, BlockState blockState, Direction direction) {
        BlockState state = blockState;
        if (blockState.hasProperty(HorizontalDirectionalBlock.FACING)) {
            state = blockState.setValue(HorizontalDirectionalBlock.FACING, direction);
        }
 
        if (blockState.hasProperty(BlockStateProperties.FACING)) {
            state = blockState.setValue(BlockStateProperties.FACING, direction);
        }
 
        this.getLevel().setBlock(this.absolutePos(blockPos), state, 3);
    }
 
    public void assertBlockPresent(Block blockType, int x, int y, int z) {
        this.assertBlockPresent(blockType, new BlockPos(x, y, z));
    }
 
    public void assertBlockPresent(Block blockType, BlockPos pos) {
        BlockState state = this.getBlockState(pos);
        this.assertBlock(pos, block -> state.is(blockType), block -> Component.translatable("test.error.expected_block", blockType.getName(), block.getName()));
    }
 
    public void assertBlockPresent(Block blockType) {
        AABB aabb = this.getRelativeBounds().contract(1.0, 1.0, 1.0);
        boolean foundBlock = BlockPos.MutableBlockPos.betweenClosedStream(aabb).anyMatch(blockPos -> this.getBlockState(blockPos).is(blockType));
        if (!foundBlock) {
            throw this.assertionException(Component.translatable("test.error.expected_block_present", blockType.getName()));
        }
    }
 
    public void assertBlockNotPresent(Block blockType, int x, int y, int z) {
        this.assertBlockNotPresent(blockType, new BlockPos(x, y, z));
    }
 
    public void assertBlockNotPresent(Block blockType, BlockPos pos) {
        this.assertBlock(
            pos, block -> !this.getBlockState(pos).is(blockType), block -> Component.translatable("test.error.unexpected_block", blockType.getName())
        );
    }
 
    public void assertBlockTag(TagKey<Block> tag, BlockPos pos) {
        this.assertBlockState(
            pos,
            state -> state.is(tag),
            state -> Component.translatable("test.error.expected_block_tag", Component.translationArg(tag.location()), state.getBlock().getName())
        );
    }
 
    public void succeedWhenBlockPresent(Block block, int x, int y, int z) {
        this.succeedWhenBlockPresent(block, new BlockPos(x, y, z));
    }
 
    public void succeedWhenBlockPresent(Block block, BlockPos pos) {
        this.succeedWhen(() -> this.assertBlockPresent(block, pos));
    }
 
    public void assertBlock(BlockPos pos, Predicate<Block> predicate, Function<Block, Component> errorMessage) {
        this.assertBlockState(pos, blockState -> predicate.test(blockState.getBlock()), state -> errorMessage.apply(state.getBlock()));
    }
 
    public <T extends Comparable<T>> void assertBlockProperty(BlockPos pos, Property<T> property, T value) {
        BlockState blockState = this.getBlockState(pos);
        boolean hasProperty = blockState.hasProperty(property);
        if (!hasProperty) {
            throw this.assertionException(pos, "test.error.block_property_missing", property.getName(), value);
        } else if (!blockState.<T>getValue(property).equals(value)) {
            throw this.assertionException(pos, "test.error.block_property_mismatch", property.getName(), value, blockState.getValue(property));
        }
    }
 
    public <T extends Comparable<T>> void assertBlockProperty(BlockPos pos, Property<T> property, Predicate<T> predicate, Component errorMessage) {
        this.assertBlockState(pos, blockState -> {
            if (!blockState.hasProperty(property)) {
                return false;
            } else {
                T value = blockState.getValue(property);
                return predicate.test(value);
            }
        }, state -> errorMessage);
    }
 
    public void assertBlockState(BlockPos pos, BlockState expected) {
        BlockState blockState = this.getBlockState(pos);
        if (!blockState.equals(expected)) {
            throw this.assertionException(pos, "test.error.state_not_equal", expected, blockState);
        }
    }
 
    public void assertBlockState(BlockPos pos, Predicate<BlockState> predicate, Function<BlockState, Component> errorMessage) {
        BlockState blockState = this.getBlockState(pos);
        if (!predicate.test(blockState)) {
            throw this.assertionException(pos, errorMessage.apply(blockState));
        }
    }
 
    public <T extends BlockEntity> void assertBlockEntityData(BlockPos pos, Class<T> type, Predicate<T> predicate, Supplier<Component> errorMessage) {
        T blockEntity = this.getBlockEntity(pos, type);
        if (!predicate.test(blockEntity)) {
            throw this.assertionException(pos, errorMessage.get());
        }
    }
 
    public void assertRedstoneSignal(BlockPos pos, Direction direction, IntPredicate levelPredicate, Supplier<Component> errorMessage) {
        BlockPos blockPos = this.absolutePos(pos);
        ServerLevel level = this.getLevel();
        BlockState blockState = level.getBlockState(blockPos);
        int signal = blockState.getSignal(level, blockPos, direction);
        if (!levelPredicate.test(signal)) {
            throw this.assertionException(pos, errorMessage.get());
        }
    }
 
    public void assertEntityPresent(EntityType<?> entityType) {
        if (!this.getLevel().hasEntities(entityType, this.getBounds(), Entity::isAlive)) {
            throw this.assertionException("test.error.expected_entity_in_test", entityType.getDescription());
        }
    }
 
    public void assertEntityPresent(EntityType<?> entityType, int x, int y, int z) {
        this.assertEntityPresent(entityType, new BlockPos(x, y, z));
    }
 
    public void assertEntityPresent(EntityType<?> entityType, BlockPos pos) {
        BlockPos absolutePos = this.absolutePos(pos);
        if (!this.getLevel().hasEntities(entityType, new AABB(absolutePos), Entity::isAlive)) {
            throw this.assertionException(pos, "test.error.expected_entity", entityType.getDescription());
        }
    }
 
    public void assertEntityPresent(EntityType<?> entityType, AABB relativeAABB) {
        AABB absoluteAABB = this.absoluteAABB(relativeAABB);
        if (!this.getLevel().hasEntities(entityType, absoluteAABB, Entity::isAlive)) {
            throw this.assertionException(BlockPos.containing(relativeAABB.getCenter()), "test.error.expected_entity", entityType.getDescription());
        }
    }
 
    public void assertEntityPresent(EntityType<?> entityType, AABB relativeAABB, Component message) {
        AABB absoluteAABB = this.absoluteAABB(relativeAABB);
        if (!this.getLevel().hasEntities(entityType, absoluteAABB, Entity::isAlive)) {
            throw this.assertionException(BlockPos.containing(relativeAABB.getCenter()), message);
        }
    }
 
    public void assertEntitiesPresent(EntityType<?> entityType, int expectedEntities) {
        List<? extends Entity> entities = this.getLevel().getEntities(entityType, this.getBounds(), Entity::isAlive);
        if (entities.size() != expectedEntities) {
            throw this.assertionException("test.error.expected_entity_count", expectedEntities, entityType.getDescription(), entities.size());
        }
    }
 
    public void assertEntitiesPresent(EntityType<?> entityType, BlockPos pos, int numOfExpectedEntities, double distance) {
        BlockPos absolutePos = this.absolutePos(pos);
        List<? extends Entity> entities = this.getEntities((EntityType<? extends Entity>)entityType, pos, distance);
        if (entities.size() != numOfExpectedEntities) {
            throw this.assertionException(pos, "test.error.expected_entity_count", numOfExpectedEntities, entityType.getDescription(), entities.size());
        }
    }
 
    public void assertEntityPresent(EntityType<?> entityType, BlockPos pos, double distance) {
        List<? extends Entity> entities = this.getEntities((EntityType<? extends Entity>)entityType, pos, distance);
        if (entities.isEmpty()) {
            BlockPos absolutePos = this.absolutePos(pos);
            throw this.assertionException(pos, "test.error.expected_entity", entityType.getDescription());
        }
    }
 
    public <T extends Entity> List<T> getEntities(EntityType<T> entityType, BlockPos pos, double distance) {
        BlockPos absolutePos = this.absolutePos(pos);
        return this.getLevel().getEntities(entityType, new AABB(absolutePos).inflate(distance), Entity::isAlive);
    }
 
    public <T extends Entity> List<T> getEntities(EntityType<T> entityType) {
        return this.getLevel().getEntities(entityType, this.getBounds(), Entity::isAlive);
    }
 
    public void assertEntityInstancePresent(Entity entity, int x, int y, int z) {
        this.assertEntityInstancePresent(entity, new BlockPos(x, y, z));
    }
 
    public void assertEntityInstancePresent(Entity entity, BlockPos pos) {
        this.assertEntityInstancePresent(entity, pos, 0.0);
    }
 
    public void assertEntityInstancePresent(Entity entity, BlockPos pos, double inflate) {
        BlockPos absolutePos = this.absolutePos(pos);
        List<? extends Entity> entities = this.getLevel().getEntities(entity.getType(), new AABB(absolutePos).inflate(inflate), Entity::isAlive);
        entities.stream()
            .filter(it -> it == entity)
            .findFirst()
            .orElseThrow(() -> this.assertionException(pos, "test.error.expected_entity", entity.getType().getDescription()));
    }
 
    public void assertItemEntityCountIs(Item itemType, BlockPos pos, double distance, int count) {
        BlockPos absolutePos = this.absolutePos(pos);
        List<ItemEntity> entities = this.getLevel().getEntities(EntityType.ITEM, new AABB(absolutePos).inflate(distance), Entity::isAlive);
        int num = 0;
 
        for (ItemEntity entity : entities) {
            ItemStack itemStack = entity.getItem();
            if (itemStack.is(itemType)) {
                num += itemStack.getCount();
            }
        }
 
        if (num != count) {
            throw this.assertionException(pos, "test.error.expected_items_count", count, getItemName(itemType), num);
        }
    }
 
    public void assertItemEntityPresent(Item itemType, BlockPos pos, double distance) {
        BlockPos absolutePos = this.absolutePos(pos);
        Predicate<ItemEntity> isSameItem = entity -> entity.isAlive() && entity.getItem().is(itemType);
        if (!this.getLevel().hasEntities(EntityType.ITEM, new AABB(absolutePos).inflate(distance), isSameItem)) {
            throw this.assertionException(pos, "test.error.expected_item", getItemName(itemType));
        }
    }
 
    public void assertItemEntityNotPresent(Item itemType, BlockPos pos, double distance) {
        BlockPos absolutePos = this.absolutePos(pos);
        Predicate<ItemEntity> isSameItem = entity -> entity.isAlive() && entity.getItem().is(itemType);
        if (this.getLevel().hasEntities(EntityType.ITEM, new AABB(absolutePos).inflate(distance), isSameItem)) {
            throw this.assertionException(pos, "test.error.unexpected_item", getItemName(itemType));
        }
    }
 
    public void assertItemEntityPresent(Item itemType) {
        Predicate<ItemEntity> isSameItem = entity -> entity.isAlive() && entity.getItem().is(itemType);
        if (!this.getLevel().hasEntities(EntityType.ITEM, this.getBounds(), isSameItem)) {
            throw this.assertionException("test.error.expected_item", getItemName(itemType));
        }
    }
 
    public void assertItemEntityNotPresent(Item itemType) {
        Predicate<ItemEntity> isSameItem = entity -> entity.isAlive() && entity.getItem().is(itemType);
        if (this.getLevel().hasEntities(EntityType.ITEM, this.getBounds(), isSameItem)) {
            throw this.assertionException("test.error.unexpected_item", getItemName(itemType));
        }
    }
 
    public void assertEntityNotPresent(EntityType<?> entityType) {
        List<? extends Entity> entities = this.getLevel().getEntities(entityType, this.getBounds(), Entity::isAlive);
        if (!entities.isEmpty()) {
            throw this.assertionException(entities.getFirst().blockPosition(), "test.error.unexpected_entity", entityType.getDescription());
        }
    }
 
    public void assertEntityNotPresent(EntityType<?> entityType, int x, int y, int z) {
        this.assertEntityNotPresent(entityType, new BlockPos(x, y, z));
    }
 
    public void assertEntityNotPresent(EntityType<?> entityType, BlockPos pos) {
        BlockPos absolutePos = this.absolutePos(pos);
        if (this.getLevel().hasEntities(entityType, new AABB(absolutePos), Entity::isAlive)) {
            throw this.assertionException(pos, "test.error.unexpected_entity", entityType.getDescription());
        }
    }
 
    public void assertEntityNotPresent(EntityType<?> entityType, AABB relativeAABB) {
        AABB absoluteAABB = this.absoluteAABB(relativeAABB);
        List<? extends Entity> entities = this.getLevel().getEntities(entityType, absoluteAABB, Entity::isAlive);
        if (!entities.isEmpty()) {
            throw this.assertionException(entities.getFirst().blockPosition(), "test.error.unexpected_entity", entityType.getDescription());
        }
    }
 
    public void assertEntityTouching(EntityType<?> entityType, double x, double y, double z) {
        Vec3 vec = new Vec3(x, y, z);
        Vec3 absoluteVec = this.absoluteVec(vec);
        Predicate<? super Entity> predicate = e -> e.getBoundingBox().intersects(absoluteVec, absoluteVec);
        if (!this.getLevel().hasEntities(entityType, this.getBounds(), predicate)) {
            throw this.assertionException(
                "test.error.expected_entity_touching", entityType.getDescription(), absoluteVec.x(), absoluteVec.y(), absoluteVec.z(), x, y, z
            );
        }
    }
 
    public void assertEntityNotTouching(EntityType<?> entityType, double x, double y, double z) {
        Vec3 vec = new Vec3(x, y, z);
        Vec3 absoluteVec = this.absoluteVec(vec);
        Predicate<? super Entity> predicate = e -> !e.getBoundingBox().intersects(absoluteVec, absoluteVec);
        if (!this.getLevel().hasEntities(entityType, this.getBounds(), predicate)) {
            throw this.assertionException(
                "test.error.expected_entity_not_touching", entityType.getDescription(), absoluteVec.x(), absoluteVec.y(), absoluteVec.z(), x, y, z
            );
        }
    }
 
    public <E extends Entity, T> void assertEntityData(BlockPos pos, EntityType<E> entityType, Predicate<E> test) {
        BlockPos absolutePos = this.absolutePos(pos);
        List<E> entities = this.getLevel().getEntities(entityType, new AABB(absolutePos), Entity::isAlive);
        if (entities.isEmpty()) {
            throw this.assertionException(pos, "test.error.expected_entity", entityType.getDescription());
        } else {
            for (E entity : entities) {
                if (!test.test(entity)) {
                    throw this.assertionException(entity.blockPosition(), "test.error.expected_entity_data_predicate", entity.getName());
                }
            }
        }
    }
 
    public <E extends Entity, T> void assertEntityData(BlockPos pos, EntityType<E> entityType, Function<? super E, T> dataAccessor, @Nullable T data) {
        this.assertEntityData(new AABB(pos), entityType, dataAccessor, data);
    }
 
    public <E extends Entity, T> void assertEntityData(AABB box, EntityType<E> entityType, Function<? super E, T> dataAccessor, @Nullable T data) {
        List<E> entities = this.getLevel().getEntities(entityType, this.absoluteAABB(box), Entity::isAlive);
        if (entities.isEmpty()) {
            throw this.assertionException(BlockPos.containing(box.getBottomCenter()), "test.error.expected_entity", entityType.getDescription());
        } else {
            for (E entity : entities) {
                T actual = dataAccessor.apply(entity);
                if (!Objects.equals(actual, data)) {
                    throw this.assertionException(BlockPos.containing(box.getBottomCenter()), "test.error.expected_entity_data", data, actual);
                }
            }
        }
    }
 
    public <E extends LivingEntity> void assertEntityIsHolding(BlockPos pos, EntityType<E> entityType, Item item) {
        BlockPos absolutePos = this.absolutePos(pos);
        List<E> entities = this.getLevel().getEntities(entityType, new AABB(absolutePos), Entity::isAlive);
        if (entities.isEmpty()) {
            throw this.assertionException(pos, "test.error.expected_entity", entityType.getDescription());
        } else {
            for (E entity : entities) {
                if (entity.isHolding(item)) {
                    return;
                }
            }
 
            throw this.assertionException(pos, "test.error.expected_entity_holding", getItemName(item));
        }
    }
 
    public <E extends Entity & InventoryCarrier> void assertEntityInventoryContains(BlockPos pos, EntityType<E> entityType, Item item) {
        BlockPos absolutePos = this.absolutePos(pos);
        List<E> entities = this.getLevel().getEntities(entityType, new AABB(absolutePos), rec$ -> rec$.isAlive());
        if (entities.isEmpty()) {
            throw this.assertionException(pos, "test.error.expected_entity", entityType.getDescription());
        } else {
            for (E entity : entities) {
                if (entity.getInventory().hasAnyMatching(itemStack -> itemStack.is(item))) {
                    return;
                }
            }
 
            throw this.assertionException(pos, "test.error.expected_entity_having", getItemName(item));
        }
    }
 
    public void assertContainerEmpty(BlockPos pos) {
        BaseContainerBlockEntity container = this.getBlockEntity(pos, BaseContainerBlockEntity.class);
        if (!container.isEmpty()) {
            throw this.assertionException(pos, "test.error.expected_empty_container");
        }
    }
 
    public void assertContainerContainsSingle(BlockPos pos, Item item) {
        BaseContainerBlockEntity container = this.getBlockEntity(pos, BaseContainerBlockEntity.class);
        if (container.countItem(item) != 1) {
            throw this.assertionException(pos, "test.error.expected_container_contents_single", getItemName(item));
        }
    }
 
    public void assertContainerContains(BlockPos pos, Item item) {
        BaseContainerBlockEntity container = this.getBlockEntity(pos, BaseContainerBlockEntity.class);
        if (container.countItem(item) == 0) {
            throw this.assertionException(pos, "test.error.expected_container_contents", getItemName(item));
        }
    }
 
    public void assertSameBlockStates(BoundingBox sourceBoundingBox, BlockPos targetBoundingBoxCorner) {
        BlockPos.betweenClosedStream(sourceBoundingBox)
            .forEach(
                sourcePos -> {
                    BlockPos targetPos = targetBoundingBoxCorner.offset(
                        sourcePos.getX() - sourceBoundingBox.minX(), sourcePos.getY() - sourceBoundingBox.minY(), sourcePos.getZ() - sourceBoundingBox.minZ()
                    );
                    this.assertSameBlockState(sourcePos, targetPos);
                }
            );
    }
 
    public void assertSameBlockState(BlockPos sourcePos, BlockPos targetPos) {
        BlockState sourceState = this.getBlockState(sourcePos);
        BlockState targetState = this.getBlockState(targetPos);
        if (sourceState != targetState) {
            throw this.assertionException(sourcePos, "test.error.state_not_equal", targetState, sourceState);
        }
    }
 
    public void assertAtTickTimeContainerContains(long time, BlockPos pos, Item item) {
        this.runAtTickTime(time, () -> this.assertContainerContainsSingle(pos, item));
    }
 
    public void assertAtTickTimeContainerEmpty(long time, BlockPos pos) {
        this.runAtTickTime(time, () -> this.assertContainerEmpty(pos));
    }
 
    public <E extends Entity, T> void succeedWhenEntityData(BlockPos pos, EntityType<E> entityType, Function<E, T> dataAccessor, T data) {
        this.succeedWhen(() -> this.assertEntityData(pos, entityType, dataAccessor, data));
    }
 
    public <E extends Entity> void assertEntityProperty(E entity, Predicate<E> test, Component description) {
        if (!test.test(entity)) {
            throw this.assertionException(entity.blockPosition(), "test.error.entity_property", entity.getName(), description);
        }
    }
 
    public <E extends Entity, T> void assertEntityProperty(E entity, Function<E, T> test, T expected, Component description) {
        T actual = test.apply(entity);
        if (!actual.equals(expected)) {
            throw this.assertionException(entity.blockPosition(), "test.error.entity_property_details", entity.getName(), description, actual, expected);
        }
    }
 
    public void assertLivingEntityHasMobEffect(LivingEntity entity, Holder<MobEffect> mobEffect, int amplifier) {
        MobEffectInstance mobEffectInstance = entity.getEffect(mobEffect);
        if (mobEffectInstance == null || mobEffectInstance.getAmplifier() != amplifier) {
            throw this.assertionException("test.error.expected_entity_effect", entity.getName(), PotionContents.getPotionDescription(mobEffect, amplifier));
        }
    }
 
    public void succeedWhenEntityPresent(EntityType<?> entityType, int x, int y, int z) {
        this.succeedWhenEntityPresent(entityType, new BlockPos(x, y, z));
    }
 
    public void succeedWhenEntityPresent(EntityType<?> entityType, BlockPos pos) {
        this.succeedWhen(() -> this.assertEntityPresent(entityType, pos));
    }
 
    public void succeedWhenEntityNotPresent(EntityType<?> entityType, int x, int y, int z) {
        this.succeedWhenEntityNotPresent(entityType, new BlockPos(x, y, z));
    }
 
    public void succeedWhenEntityNotPresent(EntityType<?> entityType, BlockPos pos) {
        this.succeedWhen(() -> this.assertEntityNotPresent(entityType, pos));
    }
 
    public void succeed() {
        this.testInfo.succeed();
    }
 
    private void ensureSingleFinalCheck() {
        if (this.finalCheckAdded) {
            throw new IllegalStateException("This test already has final clause");
        } else {
            this.finalCheckAdded = true;
        }
    }
 
    public void succeedIf(Runnable asserter) {
        this.ensureSingleFinalCheck();
        this.testInfo.createSequence().thenWaitUntil(0L, asserter).thenSucceed();
    }
 
    public void succeedWhen(Runnable asserter) {
        this.ensureSingleFinalCheck();
        this.testInfo.createSequence().thenWaitUntil(asserter).thenSucceed();
    }
 
    public void succeedOnTickWhen(int tick, Runnable asserter) {
        this.ensureSingleFinalCheck();
        this.testInfo.createSequence().thenWaitUntil(tick, asserter).thenSucceed();
    }
 
    public void runAtTickTime(long time, Runnable asserter) {
        this.testInfo.setRunAtTickTime(time, asserter);
    }
 
    public void runBeforeTestEnd(Runnable asserter) {
        this.runAtTickTime(this.testInfo.getTimeoutTicks() - 1, asserter);
    }
 
    public void runAfterDelay(long ticksToDelay, Runnable whatToRun) {
        this.runAtTickTime(this.testInfo.getTick() + ticksToDelay, whatToRun);
    }
 
    public void setTime(long ticks) {
        ServerLevel level = this.getLevel();
        Holder<WorldClock> clock = level.dimensionType().defaultClock().orElseThrow();
        level.clockManager().setTotalTicks(clock, ticks);
    }
 
    public void randomTick(BlockPos pos) {
        BlockPos absolutePos = this.absolutePos(pos);
        ServerLevel level = this.getLevel();
        level.getBlockState(absolutePos).randomTick(level, absolutePos, level.getRandom());
    }
 
    public void tickBlock(BlockPos pos) {
        BlockPos absolutePos = this.absolutePos(pos);
        ServerLevel level = this.getLevel();
        level.getBlockState(absolutePos).tick(level, absolutePos, level.getRandom());
    }
 
    public void tickPrecipitation(BlockPos pos) {
        BlockPos absolutePos = this.absolutePos(pos);
        ServerLevel level = this.getLevel();
        level.tickPrecipitation(absolutePos);
    }
 
    public void tickPrecipitation() {
        AABB aabb = this.getRelativeBounds();
        int maxX = (int)Math.floor(aabb.maxX);
        int maxZ = (int)Math.floor(aabb.maxZ);
        int maxY = (int)Math.floor(aabb.maxY);
 
        for (int x = (int)Math.floor(aabb.minX); x < maxX; x++) {
            for (int z = (int)Math.floor(aabb.minZ); z < maxZ; z++) {
                this.tickPrecipitation(new BlockPos(x, maxY, z));
            }
        }
    }
 
    public int getHeight(Heightmap.Types heightmap, int x, int z) {
        BlockPos absolutePos = this.absolutePos(new BlockPos(x, 0, z));
        return this.relativePos(this.getLevel().getHeightmapPos(heightmap, absolutePos)).getY();
    }
 
    public void fail(Component message, BlockPos pos) {
        throw this.assertionException(pos, message);
    }
 
    public void fail(Component message, Entity entity) {
        throw this.assertionException(entity.blockPosition(), message);
    }
 
    public void fail(Component message) {
        throw this.assertionException(message);
    }
 
    public void fail(String message) {
        throw this.assertionException(Component.literal(message));
    }
 
    public void failIf(Runnable asserter) {
        this.testInfo.createSequence().thenWaitUntil(asserter).thenFail(() -> this.assertionException("test.error.fail"));
    }
 
    public void failIfEver(Runnable asserter) {
        LongStream.range(this.testInfo.getTick(), this.testInfo.getTimeoutTicks()).forEach(i -> this.testInfo.setRunAtTickTime(i, asserter::run));
    }
 
    public GameTestSequence startSequence() {
        return this.testInfo.createSequence();
    }
 
    public BlockPos absolutePos(BlockPos relativePos) {
        BlockPos testPos = this.testInfo.getTestOrigin();
        BlockPos absolutePosBeforeTransform = testPos.offset(relativePos);
        return StructureTemplate.transform(absolutePosBeforeTransform, Mirror.NONE, this.testInfo.getRotation(), testPos);
    }
 
    public BlockPos relativePos(BlockPos absolutePos) {
        BlockPos testPos = this.testInfo.getTestOrigin();
        Rotation inverseRotation = this.testInfo.getRotation().getRotated(Rotation.CLOCKWISE_180);
        BlockPos absolutePosBeforeTransform = StructureTemplate.transform(absolutePos, Mirror.NONE, inverseRotation, testPos);
        return absolutePosBeforeTransform.subtract(testPos);
    }
 
    public AABB absoluteAABB(AABB relativeAABB) {
        Vec3 min = this.absoluteVec(relativeAABB.getMinPosition());
        Vec3 max = this.absoluteVec(relativeAABB.getMaxPosition());
        return new AABB(min, max);
    }
 
    public AABB relativeAABB(AABB absoluteAABB) {
        Vec3 min = this.relativeVec(absoluteAABB.getMinPosition());
        Vec3 max = this.relativeVec(absoluteAABB.getMaxPosition());
        return new AABB(min, max);
    }
 
    public Vec3 absoluteVec(Vec3 relativeVec) {
        Vec3 testPosVec = Vec3.atLowerCornerOf(this.testInfo.getTestOrigin());
        return StructureTemplate.transform(testPosVec.add(relativeVec), Mirror.NONE, this.testInfo.getRotation(), this.testInfo.getTestOrigin());
    }
 
    public Vec3 relativeVec(Vec3 absoluteVec) {
        Vec3 testPosVec = Vec3.atLowerCornerOf(this.testInfo.getTestOrigin());
        return StructureTemplate.transform(absoluteVec.subtract(testPosVec), Mirror.NONE, this.testInfo.getRotation(), this.testInfo.getTestOrigin());
    }
 
    public Rotation getTestRotation() {
        return this.testInfo.getRotation();
    }
 
    public Direction getTestDirection() {
        return this.testInfo.getRotation().rotate(Direction.SOUTH);
    }
 
    public Direction getAbsoluteDirection(Direction direction) {
        return this.getTestRotation().rotate(direction);
    }
 
    public void assertTrue(boolean condition, Component errorMessage) {
        if (!condition) {
            throw this.assertionException(errorMessage);
        }
    }
 
    public void assertTrue(boolean condition, String errorMessage) {
        this.assertTrue(condition, Component.literal(errorMessage));
    }
 
    public <N> void assertValueEqual(N value, N expected, String valueName) {
        this.assertValueEqual(value, expected, Component.literal(valueName));
    }
 
    public <N> void assertValueEqual(N value, N expected, Component valueName) {
        if (!value.equals(expected)) {
            throw this.assertionException("test.error.value_not_equal", valueName, value, expected);
        }
    }
 
    public void assertFalse(boolean condition, Component errorMessage) {
        this.assertTrue(!condition, errorMessage);
    }
 
    public void assertFalse(boolean condition, String errorMessage) {
        this.assertFalse(condition, Component.literal(errorMessage));
    }
 
    public long getTick() {
        return this.testInfo.getTick();
    }
 
    public AABB getBounds() {
        return this.testInfo.getStructureBounds();
    }
 
    public AABB getBoundsWithPadding() {
        return this.getBounds().inflate(this.testInfo.getTest().padding());
    }
 
    public AABB getRelativeBounds() {
        AABB absolute = this.testInfo.getStructureBounds();
        Rotation rotation = this.testInfo.getRotation();
        switch (rotation) {
            case COUNTERCLOCKWISE_90:
            case CLOCKWISE_90:
                return new AABB(0.0, 0.0, 0.0, absolute.getZsize(), absolute.getYsize(), absolute.getXsize());
            default:
                return new AABB(0.0, 0.0, 0.0, absolute.getXsize(), absolute.getYsize(), absolute.getZsize());
        }
    }
 
    public void forEveryBlockInStructure(Consumer<BlockPos> forBlock) {
        AABB aabb = this.getRelativeBounds().contract(1.0, 1.0, 1.0);
        BlockPos.MutableBlockPos.betweenClosedStream(aabb).forEach(forBlock);
    }
 
    public void onEachTick(Runnable action) {
        LongStream.range(this.testInfo.getTick(), this.testInfo.getTimeoutTicks()).forEach(i -> this.testInfo.setRunAtTickTime(i, action::run));
    }
 
    public void placeAt(Player player, ItemStack blockStack, BlockPos pos, Direction face) {
        BlockPos absolute = this.absolutePos(pos.relative(face));
        BlockHitResult hitResult = new BlockHitResult(Vec3.atCenterOf(absolute), face, absolute, false);
        UseOnContext context = new UseOnContext(player, InteractionHand.MAIN_HAND, hitResult);
        blockStack.useOn(context);
    }
 
    public void setBiome(ResourceKey<Biome> biome) {
        AABB bounds = this.getBoundsWithPadding();
        BlockPos low = BlockPos.containing(bounds.minX, bounds.minY, bounds.minZ);
        BlockPos high = BlockPos.containing(bounds.maxX, bounds.maxY, bounds.maxZ);
        Either<Integer, CommandSyntaxException> result = FillBiomeCommand.fill(
            this.getLevel(), low, high, this.getLevel().registryAccess().lookupOrThrow(Registries.BIOME).getOrThrow(biome)
        );
        if (result.right().isPresent()) {
            throw this.assertionException("test.error.set_biome");
        }
    }
 
    private static Component getItemName(Item itemType) {
        return itemType.components().getOrDefault(DataComponents.ITEM_NAME, CommonComponents.EMPTY);
    }
 
    private class TestBlockPlaceContext extends BlockPlaceContext {
        private final Direction placeDirection;
 
        public TestBlockPlaceContext(Level level, InteractionHand hand, ItemStack itemStackInHand, BlockHitResult hitResult, Direction placeDirection) {
            Objects.requireNonNull(GameTestHelper.this);
            super(level, null, hand, itemStackInHand, hitResult);
            this.placeDirection = placeDirection;
        }
 
        @Override
        public Direction getNearestLookingDirection() {
            return this.placeDirection;
        }
 
        @Override
        public Direction[] getNearestLookingDirections() {
            Direction[] directions = Direction.values();
            Arrays.sort(directions, Comparator.comparingDouble(d -> d.getUnitVec3().distanceTo(this.placeDirection.getUnitVec3())));
            return directions;
        }
    }
}

引用的其他类

  • BlockPos

    • 引用位置: 参数/方法调用/构造调用/返回值
    • 关联成员: BlockPos(), BlockPos.MutableBlockPos.betweenClosedStream(), BlockPos.betweenClosedStream(), BlockPos.containing()
  • Direction

    • 引用位置: 参数/方法调用/返回值
    • 关联成员: Direction.values()
  • Holder

    • 引用位置: 参数
  • GameTestAssertException

    • 引用位置: 构造调用/返回值
    • 关联成员: GameTestAssertException()
  • GameTestAssertPosException

    • 引用位置: 构造调用/返回值
    • 关联成员: GameTestAssertPosException()
  • GameTestInfo

    • 引用位置: 参数/字段
  • GameTestSequence

    • 引用位置: 返回值
  • Connection

    • 引用位置: 构造调用
    • 关联成员: Connection()
  • Component

    • 引用位置: 参数/方法调用/返回值
    • 关联成员: Component.literal(), Component.translatable(), Component.translatableEscape(), Component.translationArg()
  • ResourceKey

    • 引用位置: 参数
  • FillBiomeCommand

    • 引用位置: 方法调用
    • 关联成员: FillBiomeCommand.fill()
  • ServerLevel

    • 引用位置: 返回值
  • ServerPlayer

    • 引用位置: 构造调用/返回值
    • 关联成员: ServerPlayer()
  • CommonListenerCookie

    • 引用位置: 方法调用
    • 关联成员: CommonListenerCookie.createInitial()
  • TagKey

    • 引用位置: 参数
  • DamageSource

    • 引用位置: 参数
  • MobEffect

    • 引用位置: 参数
  • Entity

    • 引用位置: 参数/返回值
  • EntitySpawnReason

    • 引用位置: 参数
  • EntityType

    • 引用位置: 参数
  • LivingEntity

    • 引用位置: 参数/返回值
  • Mob

    • 引用位置: 参数/返回值
  • ItemEntity

    • 引用位置: 构造调用/返回值
    • 关联成员: ItemEntity()
  • InventoryCarrier

    • 引用位置: 返回值
  • Player

    • 引用位置: 参数/构造调用/返回值
    • 关联成员: Player()
  • Item

    • 引用位置: 参数
  • ItemStack

    • 引用位置: 参数/构造调用
    • 关联成员: ItemStack()
  • PotionContents

    • 引用位置: 方法调用
    • 关联成员: PotionContents.getPotionDescription()
  • UseOnContext

    • 引用位置: 构造调用
    • 关联成员: UseOnContext()
  • GameType

    • 引用位置: 参数
  • Biome

    • 引用位置: 参数
  • Block

    • 引用位置: 参数
  • Rotation

    • 引用位置: 返回值
  • BlockEntity

    • 引用位置: 返回值
  • BlockState

    • 引用位置: 参数/返回值
  • Property

    • 引用位置: 参数
  • Heightmap

    • 引用位置: 参数
  • BoundingBox

    • 引用位置: 参数
  • StructureTemplate

    • 引用位置: 方法调用
    • 关联成员: StructureTemplate.transform()
  • AABB

    • 引用位置: 参数/构造调用/返回值
    • 关联成员: AABB()
  • BlockHitResult

    • 引用位置: 参数/构造调用
    • 关联成员: BlockHitResult()
  • Vec3

    • 引用位置: 参数/方法调用/构造调用/返回值
    • 关联成员: Vec3(), Vec3.atBottomCenterOf(), Vec3.atCenterOf(), Vec3.atLowerCornerOf()