Class CreateGameTestHelper

java.lang.Object
net.minecraft.gametest.framework.GameTestHelper
com.simibubi.create.infrastructure.gametest.CreateGameTestHelper

public class CreateGameTestHelper extends net.minecraft.gametest.framework.GameTestHelper
A helper class expanding the functionality of GameTestHelper. This class may replace the default helper parameter if a test is registered through CreateTestFunction.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     

    Fields inherited from class net.minecraft.gametest.framework.GameTestHelper

    testInfo
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    assertAnyContained(net.minecraft.core.BlockPos pos, net.minecraft.world.item.Item... items)
    Of the provided items, assert that at least one is present in the given inventory.
    void
    assertCloseEnoughTo(double value, double expected)
    Assert that a number is less than 1 away from its expected value
    void
    assertContainerContains(@NotNull net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.item.Item item)
     
    void
    assertContainerContains(net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack item)
    Assert that the inventory holds at least the given ItemStack.
    void
    assertContainerContains(net.minecraft.core.BlockPos pos, net.minecraft.world.level.ItemLike item)
     
    void
    assertContainerEmpty(@NotNull net.minecraft.core.BlockPos pos)
    Assert that the given inventory holds no items.
    void
    assertContainersEmpty(List<net.minecraft.core.BlockPos> positions)
    Assert that all the given inventories hold no items.
    void
    assertContentPresent(it.unimi.dsi.fastutil.objects.Object2LongMap<net.minecraft.world.item.Item> content, net.minecraft.core.BlockPos pos)
    Assert that the inventory contains all the provided content.
    void
    assertFluidPresent(net.neoforged.neoforge.fluids.FluidStack fluid, net.minecraft.core.BlockPos pos)
    Assert that the given fluid stack is present in the given tank.
    void
    assertInRange(double value, double min, double max)
     
    void
    assertNixiePower(net.minecraft.core.BlockPos pos, int strength)
     
    void
    assertSecondsPassed(int seconds)
    Fail unless the desired number seconds have passed since test start.
    void
    assertSpeedometerSpeed(net.minecraft.core.BlockPos speedometer, float value)
     
    void
    assertStressometerCapacity(net.minecraft.core.BlockPos stressometer, float value)
     
    void
    assertTankEmpty(net.minecraft.core.BlockPos pos)
    Assert that the given tank holds no fluid.
    void
    assertTanksEmpty(net.minecraft.core.BlockPos... tanks)
     
    void
    fail(@NotNull String exceptionMessage)
     
    void
    flipBlock(net.minecraft.core.BlockPos pos)
    Flip the direction of any block with the BlockStateProperties.FACING property.
    net.neoforged.neoforge.fluids.capability.IFluidHandler
    fluidStorageAt(net.minecraft.core.BlockPos pos)
     
    getBehavior(net.minecraft.core.BlockPos pos, BehaviourType<T> type)
    Get the expected BlockEntityBehaviour from the given position, failing if not present.
    <T extends net.minecraft.world.level.block.entity.BlockEntity>
    T
    getBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<T> type, net.minecraft.core.BlockPos pos)
    Get the block entity of the expected type.
    <T extends net.minecraft.world.level.block.entity.BlockEntity & IMultiBlockEntityContainer>
    T
    getControllerBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<T> type, net.minecraft.core.BlockPos anySegment)
    Given any segment of an IMultiBlockEntityContainer, get the controller for it.
    <T extends net.minecraft.world.entity.Entity>
    List<T>
    getEntitiesBetween(net.minecraft.world.entity.EntityType<T> type, net.minecraft.core.BlockPos pos1, net.minecraft.core.BlockPos pos2)
    Get a list of all entities between two positions, inclusive.
    <T extends net.minecraft.world.entity.Entity>
    T
    getFirstEntity(net.minecraft.world.entity.EntityType<T> type, net.minecraft.core.BlockPos pos)
    Get the first entity found at the given position.
    long
    getFluidInTanks(net.minecraft.core.BlockPos... tanks)
    Get the total fluid amount across all fluid tanks at the given positions.
    it.unimi.dsi.fastutil.objects.Object2LongMap<net.minecraft.world.item.Item>
    getItemContent(net.minecraft.core.BlockPos pos)
    Get a map of contained items to their amounts.
    long
    getTankCapacity(net.minecraft.core.BlockPos pos)
    Get the total capacity of a tank at the given position.
    net.neoforged.neoforge.fluids.FluidStack
    getTankContents(net.minecraft.core.BlockPos tank)
    Get the content of the tank at the pos.
    long
    getTotalItems(net.minecraft.core.BlockPos pos)
    Get the combined total of all ItemStacks inside the inventory.
    net.neoforged.neoforge.items.IItemHandler
    itemStorageAt(net.minecraft.core.BlockPos pos)
     
    of(net.minecraft.gametest.framework.GameTestHelper original)
     
    void
    powerLever(net.minecraft.core.BlockPos pos)
    Turn off a lever.
    long
    Get the total number of seconds that have passed since test start.
    void
    setTunnelMode(net.minecraft.core.BlockPos pos, BrassTunnelBlockEntity.SelectionMode mode)
    Set the BrassTunnelBlockEntity.SelectionMode of a belt tunnel at the given position.
    net.minecraft.world.entity.item.ItemEntity
    spawnItem(net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack stack)
    Spawn an item entity at the given position with no velocity.
    void
    spawnItems(net.minecraft.core.BlockPos pos, net.minecraft.world.item.Item item, int amount)
    Spawn item entities given an item and amount.
    void
    toggleActorsOfType(Contraption contraption, net.minecraft.world.level.ItemLike item)
     
    void
    unpowerLever(net.minecraft.core.BlockPos pos)
    Turn on a lever.
    void
    whenSecondsPassed(int seconds, Runnable run)
    Run an action later, once enough time has passed.

    Methods inherited from class net.minecraft.gametest.framework.GameTestHelper

    absolutePos, absoluteVec, assertAtTickTimeContainerContains, assertAtTickTimeContainerEmpty, assertBlock, assertBlock, assertBlockEntityData, assertBlockNotPresent, assertBlockNotPresent, assertBlockPresent, assertBlockPresent, assertBlockProperty, assertBlockProperty, assertBlockState, assertEntitiesPresent, assertEntitiesPresent, assertEntityData, assertEntityInstancePresent, assertEntityInstancePresent, assertEntityInventoryContains, assertEntityIsHolding, assertEntityNotPresent, assertEntityNotPresent, assertEntityNotPresent, assertEntityNotPresent, assertEntityNotTouching, assertEntityPosition, assertEntityPresent, assertEntityPresent, assertEntityPresent, assertEntityPresent, assertEntityPresent, assertEntityProperty, assertEntityProperty, assertEntityTouching, assertFalse, assertItemEntityCountIs, assertItemEntityNotPresent, assertItemEntityNotPresent, assertItemEntityPresent, assertItemEntityPresent, assertLivingEntityHasMobEffect, assertRedstoneSignal, assertSameBlockState, assertSameBlockStates, assertTrue, assertValueEqual, destroyBlock, fail, fail, failIf, failIfEver, findClosestEntity, findEntities, findEntities, findOneEntity, forEveryBlockInStructure, getBlockEntity, getBlockState, getBounds, getEntities, getEntities, getHeight, getLevel, getTestRotation, getTick, killAllEntities, killAllEntitiesOfClass, makeAboutToDrown, makeMockPlayer, makeMockServerPlayerInLevel, moveTo, onEachTick, placeAt, pressButton, pressButton, pullLever, pullLever, pulseRedstone, randomTick, relativePos, relativeVec, runAfterDelay, runAtTickTime, setBiome, setBlock, setBlock, setBlock, setBlock, setDayTime, setNight, spawn, spawn, spawn, spawn, spawnItem, spawnItem, spawnItem, spawnWithNoFreeWill, spawnWithNoFreeWill, spawnWithNoFreeWill, spawnWithNoFreeWill, startSequence, succeed, succeedIf, succeedOnTickWhen, succeedWhen, succeedWhenBlockPresent, succeedWhenBlockPresent, succeedWhenEntityData, succeedWhenEntityNotPresent, succeedWhenEntityNotPresent, succeedWhenEntityPresent, succeedWhenEntityPresent, tickPrecipitation, tickPrecipitation, useBlock, useBlock, useBlock, walkTo, withLowHealth

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • of

      public static CreateGameTestHelper of(net.minecraft.gametest.framework.GameTestHelper original)
    • flipBlock

      public void flipBlock(net.minecraft.core.BlockPos pos)
      Flip the direction of any block with the BlockStateProperties.FACING property.
    • assertNixiePower

      public void assertNixiePower(net.minecraft.core.BlockPos pos, int strength)
    • powerLever

      public void powerLever(net.minecraft.core.BlockPos pos)
      Turn off a lever.
    • unpowerLever

      public void unpowerLever(net.minecraft.core.BlockPos pos)
      Turn on a lever.
    • setTunnelMode

      public void setTunnelMode(net.minecraft.core.BlockPos pos, BrassTunnelBlockEntity.SelectionMode mode)
      Set the BrassTunnelBlockEntity.SelectionMode of a belt tunnel at the given position.
      Parameters:
      pos -
      mode -
    • assertSpeedometerSpeed

      public void assertSpeedometerSpeed(net.minecraft.core.BlockPos speedometer, float value)
    • assertStressometerCapacity

      public void assertStressometerCapacity(net.minecraft.core.BlockPos stressometer, float value)
    • toggleActorsOfType

      public void toggleActorsOfType(Contraption contraption, net.minecraft.world.level.ItemLike item)
    • getBlockEntity

      public <T extends net.minecraft.world.level.block.entity.BlockEntity> T getBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<T> type, net.minecraft.core.BlockPos pos)
      Get the block entity of the expected type. If the type does not match, this fails the test.
    • getControllerBlockEntity

      public <T extends net.minecraft.world.level.block.entity.BlockEntity & IMultiBlockEntityContainer> T getControllerBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<T> type, net.minecraft.core.BlockPos anySegment)
      Given any segment of an IMultiBlockEntityContainer, get the controller for it.
    • getBehavior

      public <T extends BlockEntityBehaviour> T getBehavior(net.minecraft.core.BlockPos pos, BehaviourType<T> type)
      Get the expected BlockEntityBehaviour from the given position, failing if not present.
    • spawnItem

      public net.minecraft.world.entity.item.ItemEntity spawnItem(net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack stack)
      Spawn an item entity at the given position with no velocity.
    • spawnItems

      public void spawnItems(net.minecraft.core.BlockPos pos, net.minecraft.world.item.Item item, int amount)
      Spawn item entities given an item and amount. The amount will be split into multiple entities if larger than the item's max stack size.
    • getFirstEntity

      public <T extends net.minecraft.world.entity.Entity> T getFirstEntity(net.minecraft.world.entity.EntityType<T> type, net.minecraft.core.BlockPos pos)
      Get the first entity found at the given position.
    • getEntitiesBetween

      public <T extends net.minecraft.world.entity.Entity> List<T> getEntitiesBetween(net.minecraft.world.entity.EntityType<T> type, net.minecraft.core.BlockPos pos1, net.minecraft.core.BlockPos pos2)
      Get a list of all entities between two positions, inclusive.
    • fluidStorageAt

      public net.neoforged.neoforge.fluids.capability.IFluidHandler fluidStorageAt(net.minecraft.core.BlockPos pos)
    • getTankContents

      public net.neoforged.neoforge.fluids.FluidStack getTankContents(net.minecraft.core.BlockPos tank)
      Get the content of the tank at the pos. content is determined by what the tank allows to be extracted.
    • getTankCapacity

      public long getTankCapacity(net.minecraft.core.BlockPos pos)
      Get the total capacity of a tank at the given position.
    • getFluidInTanks

      public long getFluidInTanks(net.minecraft.core.BlockPos... tanks)
      Get the total fluid amount across all fluid tanks at the given positions.
    • assertFluidPresent

      public void assertFluidPresent(net.neoforged.neoforge.fluids.FluidStack fluid, net.minecraft.core.BlockPos pos)
      Assert that the given fluid stack is present in the given tank. The tank might also hold more than the fluid.
    • assertTankEmpty

      public void assertTankEmpty(net.minecraft.core.BlockPos pos)
      Assert that the given tank holds no fluid.
    • assertTanksEmpty

      public void assertTanksEmpty(net.minecraft.core.BlockPos... tanks)
    • itemStorageAt

      public net.neoforged.neoforge.items.IItemHandler itemStorageAt(net.minecraft.core.BlockPos pos)
    • getItemContent

      public it.unimi.dsi.fastutil.objects.Object2LongMap<net.minecraft.world.item.Item> getItemContent(net.minecraft.core.BlockPos pos)
      Get a map of contained items to their amounts. This is not safe for NBT!
    • getTotalItems

      public long getTotalItems(net.minecraft.core.BlockPos pos)
      Get the combined total of all ItemStacks inside the inventory.
    • assertAnyContained

      public void assertAnyContained(net.minecraft.core.BlockPos pos, net.minecraft.world.item.Item... items)
      Of the provided items, assert that at least one is present in the given inventory.
    • assertContentPresent

      public void assertContentPresent(it.unimi.dsi.fastutil.objects.Object2LongMap<net.minecraft.world.item.Item> content, net.minecraft.core.BlockPos pos)
      Assert that the inventory contains all the provided content.
    • assertContainersEmpty

      public void assertContainersEmpty(List<net.minecraft.core.BlockPos> positions)
      Assert that all the given inventories hold no items.
    • assertContainerEmpty

      public void assertContainerEmpty(@NotNull @NotNull net.minecraft.core.BlockPos pos)
      Assert that the given inventory holds no items.
      Overrides:
      assertContainerEmpty in class net.minecraft.gametest.framework.GameTestHelper
    • assertContainerContains

      public void assertContainerContains(net.minecraft.core.BlockPos pos, net.minecraft.world.level.ItemLike item)
      See Also:
    • assertContainerContains

      public void assertContainerContains(@NotNull @NotNull net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.world.item.Item item)
      Overrides:
      assertContainerContains in class net.minecraft.gametest.framework.GameTestHelper
      See Also:
    • assertContainerContains

      public void assertContainerContains(net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack item)
      Assert that the inventory holds at least the given ItemStack. It may also hold more than the stack.
    • assertSecondsPassed

      public void assertSecondsPassed(int seconds)
      Fail unless the desired number seconds have passed since test start.
    • secondsPassed

      public long secondsPassed()
      Get the total number of seconds that have passed since test start.
    • whenSecondsPassed

      public void whenSecondsPassed(int seconds, Runnable run)
      Run an action later, once enough time has passed.
    • assertCloseEnoughTo

      public void assertCloseEnoughTo(double value, double expected)
      Assert that a number is less than 1 away from its expected value
    • assertInRange

      public void assertInRange(double value, double min, double max)
    • fail

      @Contract("_->fail") public void fail(@NotNull @NotNull String exceptionMessage)
      Overrides:
      fail in class net.minecraft.gametest.framework.GameTestHelper