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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intFields inherited from class net.minecraft.gametest.framework.GameTestHelper
testInfo -
Method Summary
Modifier and TypeMethodDescriptionvoidassertAnyContained(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.voidassertCloseEnoughTo(double value, double expected) Assert that a number is less than 1 away from its expected valuevoidassertContainerContains(@NotNull net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.item.Item item) voidassertContainerContains(net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack item) Assert that the inventory holds at least the given ItemStack.voidassertContainerContains(net.minecraft.core.BlockPos pos, net.minecraft.world.level.ItemLike item) voidassertContainerEmpty(@NotNull net.minecraft.core.BlockPos pos) Assert that the given inventory holds no items.voidassertContainersEmpty(List<net.minecraft.core.BlockPos> positions) Assert that all the given inventories hold no items.voidassertContentPresent(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.voidassertFluidPresent(net.neoforged.neoforge.fluids.FluidStack fluid, net.minecraft.core.BlockPos pos) Assert that the given fluid stack is present in the given tank.voidassertInRange(double value, double min, double max) voidassertNixiePower(net.minecraft.core.BlockPos pos, int strength) voidassertSecondsPassed(int seconds) Fail unless the desired number seconds have passed since test start.voidassertSpeedometerSpeed(net.minecraft.core.BlockPos speedometer, float value) voidassertStressometerCapacity(net.minecraft.core.BlockPos stressometer, float value) voidassertTankEmpty(net.minecraft.core.BlockPos pos) Assert that the given tank holds no fluid.voidassertTanksEmpty(net.minecraft.core.BlockPos... tanks) voidvoidflipBlock(net.minecraft.core.BlockPos pos) Flip the direction of any block with theBlockStateProperties.FACINGproperty.net.neoforged.neoforge.fluids.capability.IFluidHandlerfluidStorageAt(net.minecraft.core.BlockPos pos) <T extends BlockEntityBehaviour>
TgetBehavior(net.minecraft.core.BlockPos pos, BehaviourType<T> type) Get the expectedBlockEntityBehaviourfrom the given position, failing if not present.<T extends net.minecraft.world.level.block.entity.BlockEntity>
TgetBlockEntity(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>
TgetControllerBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<T> type, net.minecraft.core.BlockPos anySegment) Given any segment of anIMultiBlockEntityContainer, 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>
TgetFirstEntity(net.minecraft.world.entity.EntityType<T> type, net.minecraft.core.BlockPos pos) Get the first entity found at the given position.longgetFluidInTanks(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.longgetTankCapacity(net.minecraft.core.BlockPos pos) Get the total capacity of a tank at the given position.net.neoforged.neoforge.fluids.FluidStackgetTankContents(net.minecraft.core.BlockPos tank) Get the content of the tank at the pos.longgetTotalItems(net.minecraft.core.BlockPos pos) Get the combined total of all ItemStacks inside the inventory.net.neoforged.neoforge.items.IItemHandleritemStorageAt(net.minecraft.core.BlockPos pos) static CreateGameTestHelperof(net.minecraft.gametest.framework.GameTestHelper original) voidpowerLever(net.minecraft.core.BlockPos pos) Turn off a lever.longGet the total number of seconds that have passed since test start.voidsetTunnelMode(net.minecraft.core.BlockPos pos, BrassTunnelBlockEntity.SelectionMode mode) Set theBrassTunnelBlockEntity.SelectionModeof a belt tunnel at the given position.net.minecraft.world.entity.item.ItemEntityspawnItem(net.minecraft.core.BlockPos pos, net.minecraft.world.item.ItemStack stack) Spawn an item entity at the given position with no velocity.voidspawnItems(net.minecraft.core.BlockPos pos, net.minecraft.world.item.Item item, int amount) Spawn item entities given an item and amount.voidtoggleActorsOfType(Contraption contraption, net.minecraft.world.level.ItemLike item) voidunpowerLever(net.minecraft.core.BlockPos pos) Turn on a lever.voidwhenSecondsPassed(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
-
Field Details
-
TICKS_PER_SECOND
public static final int TICKS_PER_SECOND- See Also:
-
TEN_SECONDS
public static final int TEN_SECONDS- See Also:
-
FIFTEEN_SECONDS
public static final int FIFTEEN_SECONDS- See Also:
-
TWENTY_SECONDS
public static final int TWENTY_SECONDS- See Also:
-
-
Method Details
-
of
-
flipBlock
public void flipBlock(net.minecraft.core.BlockPos pos) Flip the direction of any block with theBlockStateProperties.FACINGproperty. -
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 theBrassTunnelBlockEntity.SelectionModeof 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
-
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 anIMultiBlockEntityContainer, get the controller for it. -
getBehavior
public <T extends BlockEntityBehaviour> T getBehavior(net.minecraft.core.BlockPos pos, BehaviourType<T> type) Get the expectedBlockEntityBehaviourfrom 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
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:
assertContainerEmptyin classnet.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:
assertContainerContainsin classnet.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
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
- Overrides:
failin classnet.minecraft.gametest.framework.GameTestHelper
-