Class GameTestHelper
@GameTest method. Provides world interaction, assertions, and the fluent
sequence API.
Coordinate-based methods use test-local positions and provide parallel overloads for raw
coordinates, TestPos, and structure-label strings. Label overloads resolve through
pos(String), including structure rotation, and throw LabelResolutionException when
the fixture has no matching label.
-
Constructor Summary
ConstructorsConstructorDescriptionGameTestHelper(GameTestInstance instance, net.minecraft.world.WorldServer world, int originX, int originY, int originZ) -
Method Summary
Modifier and TypeMethodDescriptionabsolute(int x, int y, int z) Convert test-local block coordinates to an absoluteTestPosin world space.Convert a test-local block position to an absoluteTestPosin world space.Resolve a named coordinate label to world-absolute coordinates.voidRegistercallbackto run once when this test ends, regardless of outcome.voidassertBlockAbsent(net.minecraft.block.Block unexpected, int x, int y, int z) Assert that the block at test-local position(x, y, z)is NOTunexpected.voidassertBlockAbsent(net.minecraft.block.Block unexpected, TestPos pos) Assert that the block at test-local positionposis NOTunexpected.voidassertBlockAbsent(net.minecraft.block.Block unexpected, String label) Assert that the block at the named structure position is NOTunexpected.voidassertBlockPresent(net.minecraft.block.Block expected, int x, int y, int z) Assert that the block at test-local position(x, y, z)isexpected.voidassertBlockPresent(net.minecraft.block.Block expected, int meta, int x, int y, int z) Assert that the block at test-local position isexpectedwith the given metadata.voidassertBlockPresent(net.minecraft.block.Block expected, int meta, TestPos pos) Assert that the block atposisexpectedwith the given metadata.voidassertBlockPresent(net.minecraft.block.Block expected, int meta, String label) Assert that the block at the named structure position isexpectedwith the given metadata.voidassertBlockPresent(net.minecraft.block.Block expected, TestPos pos) Assert that the block at test-local positionposisexpected.voidassertBlockPresent(net.minecraft.block.Block expected, String label) Assert that the block at the named structure position isexpected.voidassertEntityAbsent(int x, int y, int z) Assert that no live entity exists in the single test-local block at(x, y, z).voidAssert that no live entity exists in the single test-local block atpos.voidassertEntityAbsent(Class<? extends net.minecraft.entity.Entity> type, int x, int y, int z) Assert that no live entity oftypeexists in the single test-local block at(x, y, z).voidassertEntityAbsent(Class<? extends net.minecraft.entity.Entity> type, TestPos pos) Assert that no live entity oftypeexists in the single test-local block atpos.voidassertEntityAbsent(Class<? extends net.minecraft.entity.Entity> type, String label) Assert that no live entity oftypeexists at the named structure position.voidassertEntityAbsent(String label) Assert that no live entity exists at the named structure position.voidassertEntityCount(int expectedCount, int x, int y, int z) Assert that exactlyexpectedCountlive entities exist in the single test-local block at(x, y, z).voidassertEntityCount(int expectedCount, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Assert that exactlyexpectedCountlive entities exist in the inclusive test-local block range.voidassertEntityCount(int expectedCount, TestPos pos) Assert the live entity count in the single test-local block atpos.voidassertEntityCount(int expectedCount, TestPos min, TestPos max) Assert the live entity count in the inclusive test-local block range.voidassertEntityCount(int expectedCount, String label) Assert the live entity count at the named structure position.voidassertEntityCount(int expectedCount, String minLabel, String maxLabel) Assert the live entity count in the inclusive range between two structure labels.voidassertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, int x, int y, int z) Assert that exactlyexpectedCountlive entities oftypeexist in the single test-local block at(x, y, z).voidassertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Assert that exactlyexpectedCountlive entities oftypeexist in the inclusive test-local block range.voidassertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, TestPos pos) Assert the live entity count oftypein the single test-local block atpos.voidassertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, TestPos min, TestPos max) Assert the live entity count oftypein the inclusive test-local block range.voidassertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, String label) Assert the live entity count oftypeat the named structure position.voidassertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, String minLabel, String maxLabel) Assert the live entity count oftypein the inclusive range between two structure labels.voidassertEntityNBT(net.minecraft.entity.Entity entity, net.minecraft.nbt.NBTTagCompound expectedSubset) Assert that the entity's NBT contains all keys/values fromexpectedSubset.voidassertEntityNBTPath(net.minecraft.entity.Entity entity, String path, String expectedValue) Assert a specific value at a dotted NBT path on an entity (e.g.net.minecraft.entity.EntityassertEntityPresent(int x, int y, int z) Assert that at least one live entity exists in the single test-local block at(x, y, z).net.minecraft.entity.EntityAssert that at least one live entity exists in the single test-local block atpos.<T extends net.minecraft.entity.Entity>
TassertEntityPresent(Class<T> type, int x, int y, int z) Assert that at least one live entity oftypeexists in the single test-local block at(x, y, z).<T extends net.minecraft.entity.Entity>
TassertEntityPresent(Class<T> type, TestPos pos) Assert that at least one live entity oftypeexists in the block atpos.<T extends net.minecraft.entity.Entity>
TassertEntityPresent(Class<T> type, String label) Assert that at least one live entity oftypeexists at the named structure position.net.minecraft.entity.EntityassertEntityPresent(String label) Assert that at least one live entity exists at the named structure position.voidassertEquals(double expected, double actual, double delta) Fail if|expected - actual| > delta.voidassertEquals(double expected, double actual, double delta, String message) Fail if|expected - actual| > delta.voidassertEquals(long expected, long actual) Fail ifexpected != actual.voidassertEquals(long expected, long actual, String message) Fail ifexpected != actual.voidassertEquals(Object expected, Object actual) voidassertEquals(Object expected, Object actual, String message) voidassertFalse(boolean condition) Fail ifconditionistrue.voidassertFalse(boolean condition, String message) Fail ifconditionistrue.voidassertFluidTank(int x, int y, int z, net.minecraftforge.fluids.FluidStack expected) Assert that the fluid handler at test-local position contains at leastexpected.amountmB of the expected fluid.voidassertFluidTank(TestPos pos, net.minecraftforge.fluids.FluidStack expected) Assert that the fluid handler at the test-local position contains at leastexpected.voidassertFluidTank(String label, net.minecraftforge.fluids.FluidStack expected) Assert that the fluid handler at the named structure position contains at leastexpected.voidassertFluidTankEmpty(int x, int y, int z) Assert that the fluid handler at test-local position has no fluid.voidAssert that the fluid handler at the test-local position has no fluid.voidassertFluidTankEmpty(String label) Assert that the fluid handler at the named structure position has no fluid.<T> TassertInstanceOf(Class<T> type, Object actual) Fail ifactualis not an instance oftype.<T> TassertInstanceOf(Class<T> type, Object actual, String message) Fail ifactualis not an instance oftype.voidassertInventoryContains(int x, int y, int z, net.minecraft.item.ItemStack expected) Assert that the inventory at test-local position contains at least the given stack (item, damage, NBT match; stack size is minimum).voidassertInventoryContains(TestPos pos, net.minecraft.item.ItemStack expected) Assert that the inventory at test-local (relative) TestPos contains at least the given stack.voidassertInventoryContains(String label, net.minecraft.item.ItemStack expected) Assert that the inventory at the named structure position contains at leastexpected.voidassertInventoryCount(int x, int y, int z, net.minecraft.item.ItemStack template, long expectedCount) Assert that exactlyexpectedCountitems matchingtemplateexist across the inventory at test-local position.voidassertInventoryCount(TestPos pos, net.minecraft.item.ItemStack template, long expectedCount) Assert an exact matching item count across the inventory at a test-local (relative) TestPos.voidassertInventoryCount(String label, net.minecraft.item.ItemStack template, long expectedCount) Assert an exact matching item count in the inventory at the named structure position.voidassertInventoryEmpty(int x, int y, int z) Assert that every slot of the inventory at test-local position is empty.voidAssert that every slot of the inventory at the test-local position is empty.voidassertInventoryEmpty(String label) Assert that every slot of the inventory at the named structure position is empty.voidassertItemEqual(net.minecraft.item.ItemStack expected, net.minecraft.item.ItemStack actual) Fail ifexpectedandactualdiffer by item, damage, stack size, or NBT.voidassertItemEqual(net.minecraft.item.ItemStack expected, net.minecraft.item.ItemStack actual, String message) Fail ifexpectedandactualdiffer by item, damage, stack size, or NBT.voidassertIterableEquals(Iterable<?> expected, Iterable<?> actual) Assert that two iterables contain equal elements in the same order.voidassertIterableEquals(Iterable<?> expected, Iterable<?> actual, String message) Assert that two iterables contain equal elements in the same order (deep equality viaObjects.equals(java.lang.Object, java.lang.Object)).voidassertLinesMatch(List<String> expectedLines, List<String> actualLines) voidAssert thatactualLinesmatchesexpectedLinesline by line.voidassertNotEquals(double unexpected, double actual, double delta) Fail if|unexpected - actual| <= delta.voidassertNotEquals(double unexpected, double actual, double delta, String message) Fail if|unexpected - actual| <= delta.voidassertNotEquals(long unexpected, long actual) Fail ifunexpected == actual.voidassertNotEquals(long unexpected, long actual, String message) Fail ifunexpected == actual.voidassertNotEquals(Object unexpected, Object actual) voidassertNotEquals(Object unexpected, Object actual, String message) voidassertNotNull(Object actual) Fail ifactualisnull.voidassertNotNull(Object actual, String message) Fail ifactualisnull.voidassertNotSame(Object unexpected, Object actual) Fail ifunexpectedandactualare the same object reference (==).voidassertNotSame(Object unexpected, Object actual, String message) Fail ifunexpectedandactualare the same object reference (==).voidassertNull(Object actual) Fail ifactualis notnull.voidassertNull(Object actual, String message) Fail ifactualis notnull.voidassertRedstonePower(int x, int y, int z, int minPower) Assert that the block at test-local position is receiving at leastminPowerredstone power.voidassertRedstonePower(TestPos pos, int minPower) Assert the minimum redstone power at the test-local position.voidassertRedstonePower(String label, int minPower) Assert the minimum redstone power at the named structure position.voidassertSame(Object expected, Object actual) Fail ifexpectedandactualare not the same object reference (==).voidassertSame(Object expected, Object actual, String message) Fail ifexpectedandactualare not the same object reference (==).voidassertSlot(int x, int y, int z, int slot, net.minecraft.item.ItemStack expected) Assert that a specific slot contains the given stack (exact item + damage + NBT + size).voidassertSlot(TestPos pos, int slot, net.minecraft.item.ItemStack expected) Assert the contents of a specific inventory slot at the test-local position.voidassertSlot(String label, int slot, net.minecraft.item.ItemStack expected) Assert the contents of a specific inventory slot at the named structure position.<T extends Throwable>
TassertThrows(Class<T> expectedType, Runnable action) Assert thatactionthrows an exception of exactly typeexpectedType.<T extends Throwable>
TassertThrows(Class<T> expectedType, Runnable action, String message) Assert thatactionthrows an exception of exactly typeexpectedType.net.minecraft.tileentity.TileEntityassertTileEntityPresent(int x, int y, int z) Assert that a TileEntity exists at test-local position(x, y, z).net.minecraft.tileentity.TileEntityAssert that a TileEntity exists at the test-local position and return it.<T extends net.minecraft.tileentity.TileEntity>
TassertTileEntityPresent(Class<T> type, int x, int y, int z) Assert that a TileEntity of a specific type exists at test-local position.<T extends net.minecraft.tileentity.TileEntity>
TassertTileEntityPresent(Class<T> type, TestPos pos) Assert that a TileEntity oftypeexists at the test-local position and return it.<T extends net.minecraft.tileentity.TileEntity>
TassertTileEntityPresent(Class<T> type, String label) Assert that a TileEntity oftypeexists at the named structure position and return it.net.minecraft.tileentity.TileEntityassertTileEntityPresent(String label) Assert that a TileEntity exists at the named structure position and return it.voidassertTileNBT(int x, int y, int z, net.minecraft.nbt.NBTTagCompound expectedSubset) Assert that the TileEntity NBT at test-local position contains all keys/values fromexpectedSubset.voidassertTileNBT(TestPos pos, net.minecraft.nbt.NBTTagCompound expectedSubset) Assert that the TileEntity NBT at the test-local position containsexpectedSubset.voidassertTileNBT(String label, net.minecraft.nbt.NBTTagCompound expectedSubset) Assert that the TileEntity NBT at the named structure position containsexpectedSubset.voidassertTileNBTPath(int x, int y, int z, String path, String expectedValue) Assert a specific value at a dotted NBT path (e.g.voidassertTileNBTPath(TestPos pos, String path, String expectedValue) Assert a value at a dotted NBT path on the TileEntity at the test-local position.voidassertTileNBTPath(String label, String path, String expectedValue) Assert a value at a dotted NBT path on the TileEntity at the named structure position.voidassertTrue(boolean condition) Fail ifconditionisfalse.voidassertTrue(boolean condition, String message) Fail ifconditionisfalse.voidassumeFalse(boolean condition, String reason) Skip this test whenconditionistrue.voidassumeTrue(boolean condition, String reason) Skip this test whenconditionisfalse.voidclearSlot(int x, int y, int z, int slot) Directly clear an inventory slot at test-local position, bypassing normal extraction rules, then mark the inventory dirty.voidDirectly clear an inventory slot at a test-local (relative) TestPos.voidDirectly clear an inventory slot at the named structure position.longcountItems(int x, int y, int z, net.minecraft.item.ItemStack template) Count all items matchingtemplate(item, damage, and NBT) in the inventory at test-local position.longcountItems(TestPos pos, net.minecraft.item.ItemStack template) Count all items matchingtemplatein the inventory at a test-local (relative) TestPos.longcountItems(String label, net.minecraft.item.ItemStack template) Count all matching items in the inventory at the named structure position.voiddestroyBlock(int x, int y, int z) Destroy the block at test-local position (replace with air).voiddestroyBlock(TestPos pos) Destroy the block at the test-local position.voiddestroyBlock(String label) Destroy the block at the named structure position.voidDisable random block ticks in this world (e.g.intextractItem(int x, int y, int z, net.minecraft.item.ItemStack template, int maxAmount) Extract up tomaxAmountitems matchingtemplatefrom the inventory.intextractItem(TestPos pos, net.minecraft.item.ItemStack template, int maxAmount) Extract matching items from the inventory at the test-local position.intextractItem(String label, net.minecraft.item.ItemStack template, int maxAmount) Extract matching items from the inventory at the named structure position.voidfail()Immediately fail this test with no message.voidImmediately fail this test withmessage.voidfixWorldTime(long ticks) Fix the world time to a specific value and disable the daylight cycle.<T extends net.minecraft.entity.Entity>
List<T>getEntities(Class<T> type, int x, int y, int z) Return live entities oftypewhose bounding boxes intersect the single test-local block at(x, y, z).<T extends net.minecraft.entity.Entity>
List<T>getEntities(Class<T> type, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Return live entities oftypewhose bounding boxes intersect the inclusive test-local block range.<T extends net.minecraft.entity.Entity>
List<T>getEntities(Class<T> type, TestPos pos) Return live entities oftypeintersecting the single test-local block atpos.<T extends net.minecraft.entity.Entity>
List<T>getEntities(Class<T> type, TestPos min, TestPos max) Return live entities oftypeintersecting the inclusive test-local block range.<T extends net.minecraft.entity.Entity>
List<T>getEntities(Class<T> type, String label) Return live entities oftypeintersecting the single block at the named structure position.<T extends net.minecraft.entity.Entity>
List<T>getEntities(Class<T> type, String minLabel, String maxLabel) Return live entities oftypeintersecting the inclusive range between two structure labels.net.minecraft.nbt.NBTTagCompoundgetEntityNBT(net.minecraft.entity.Entity entity) Return a deep copy of an entity's serialized NBT.intintintEvent log for this test instance.net.minecraft.nbt.NBTTagCompoundgetTileNBT(int x, int y, int z) Return a deep copy of the TileEntity's serialized NBT at test-local position.net.minecraft.nbt.NBTTagCompoundgetTileNBT(TestPos pos) Return a deep copy of the TileEntity's serialized NBT at the test-local position.net.minecraft.nbt.NBTTagCompoundgetTileNBT(String label) Return a deep copy of the TileEntity's serialized NBT at the named structure position.net.minecraft.world.WorldServergetWorld()gtnh()Return the GTNH-specific helper that provides GregTech machine assertions, EU supply, time-warp, and fluid-hatch utilities.voidinsertFluid(int x, int y, int z, net.minecraftforge.fluids.FluidStack fluid) Insert a FluidStack into the fluid handler at test-local position.voidinsertFluid(TestPos pos, net.minecraftforge.fluids.FluidStack fluid) Insert a FluidStack into the fluid handler at the test-local position.voidinsertFluid(String label, net.minecraftforge.fluids.FluidStack fluid) Insert a FluidStack into the fluid handler at the named structure position.voidinsertItem(int x, int y, int z, net.minecraft.item.ItemStack stack) Insert an ItemStack into the inventory at test-local position.voidinsertItem(TestPos pos, net.minecraft.item.ItemStack stack) Insert an ItemStack into the inventory at a test-local (relative) TestPos.voidinsertItem(String label, net.minecraft.item.ItemStack stack) Insert an ItemStack into the inventory at the named structure position.onEachTick(Runnable callback) Deprecated.onEachTick(String name, Runnable callback) Register a named, initially enabled callback that runs once per test tick until the test ends.onEachTickDisabled(String name, Runnable callback) Register a named, initially disabled per-tick callback.Resolve a named coordinate label from this test's structure template.voidpulseRedstone(int x, int y, int z, int durationTicks) Place a redstone block at the given test-local position fordurationTicks, then remove it.voidpulseRedstone(TestPos pos, int durationTicks) Pulse a redstone block at the test-local position.voidpulseRedstone(String label, int durationTicks) Pulse a redstone block at the named structure position.voidsetBlock(int x, int y, int z, net.minecraft.block.Block block) voidsetBlock(int x, int y, int z, net.minecraft.block.Block block, int meta) Place a block at test-local position.voidPlace a block at the test-local position.voidPlace a block with metadata at the test-local position.voidPlace a block at the named structure position.voidPlace a block with metadata at the named structure position.voidsetRedstoneInput(int x, int y, int z, int strength) Set a redstone signal source (repeater-like) at test-local position by placing a redstone block (strength = 15) or air (strength = 0).voidsetRedstoneInput(TestPos pos, int strength) Set a redstone signal source at the test-local position.voidsetRedstoneInput(String label, int strength) Set a redstone signal source at the named structure position.voidsetSlot(int x, int y, int z, int slot, net.minecraft.item.ItemStack stack) Directly set an inventory slot at test-local position to a copy ofstack, bypassing normal insertion rules, then mark the inventory dirty.voidDirectly set an inventory slot at a test-local (relative) TestPos.voidDirectly set an inventory slot at the named structure position.voidsetTile(int x, int y, int z, net.minecraft.nbt.NBTTagCompound nbt) Apply an NBT compound to the TileEntity at test-local position.voidApply an NBT compound to the TileEntity at the test-local position.voidApply an NBT compound to the TileEntity at the named structure position.voidsetWeather(Weather weather) Apply a weather preset and lock it for the duration of the test.voidsimulateLeftClick(int x, int y, int z, net.minecraftforge.common.util.FakePlayer player) Simulate a left-click (block punch) at test-local position.voidsimulateLeftClick(TestPos pos, net.minecraftforge.common.util.FakePlayer player) Simulate a left-click on the block at the test-local position.voidsimulateLeftClick(String label, net.minecraftforge.common.util.FakePlayer player) Simulate a left-click on the block at the named structure position.booleansimulateRightClick(int x, int y, int z, net.minecraftforge.common.util.FakePlayer player, net.minecraft.item.ItemStack heldItem) Simulate a right-click on the block at test-local position using the given player and held item.booleansimulateRightClick(TestPos pos, net.minecraftforge.common.util.FakePlayer player, net.minecraft.item.ItemStack heldItem) Simulate a right-click on the block at the test-local position.booleansimulateRightClick(String label, net.minecraftforge.common.util.FakePlayer player, net.minecraft.item.ItemStack heldItem) Simulate a right-click on the block at the named structure position.net.minecraft.entity.EntityspawnEntity(String entityId, double x, double y, double z) Create an entity by NBT entity id, spawn it at the test-local position, and return it.net.minecraft.entity.EntityspawnEntity(String entityId, TestPos pos) Create an entity by NBT entity id and spawn it at the test-local block position.net.minecraft.entity.EntityspawnEntity(String entityId, String label) Create an entity by NBT entity id and spawn it at the named structure position.<T extends net.minecraft.entity.Entity>
TspawnEntity(T entity, double x, double y, double z) Spawnentityat the test-local position and return it.<T extends net.minecraft.entity.Entity>
TspawnEntity(T entity, TestPos pos) Spawnentityat the test-local block position and return it.<T extends net.minecraft.entity.Entity>
TspawnEntity(T entity, String label) Spawnentityat the named structure position and return it.net.minecraftforge.common.util.FakePlayerspawnFakePlayer(String profileName) Spawn a fake player with the given profile name, positioned at the test's origin.Create and attach a newGameTestSequenceto this test.voidsucceed()Immediately mark this test as passed.voidPass at the end oftimeoutTicksafter the final tick's callbacks and sequence actions have run.voidsucceedWhen(BooleanSupplier predicate) Pollspredicateeach tick; passes on the firsttrue.
-
Constructor Details
-
GameTestHelper
public GameTestHelper(GameTestInstance instance, net.minecraft.world.WorldServer world, int originX, int originY, int originZ)
-
-
Method Details
-
absolute
Convert test-local block coordinates to an absoluteTestPosin world space. -
absolute
Convert a test-local block position to an absoluteTestPosin world space. -
pos
Resolve a named coordinate label from this test's structure template. Returned coordinates are test-local and include the test's@GameTest(rotation = ...)transform.- Throws:
LabelResolutionException- if this test has no such label
-
absolute
Resolve a named coordinate label to world-absolute coordinates. The label is first resolved withpos(String), so test rotation is applied.- Throws:
LabelResolutionException- if this test has no such label
-
startSequence
Create and attach a newGameTestSequenceto this test. Must be called at most once per test method. Returns the sequence so the caller can chain step methods. -
succeed
public void succeed()Immediately mark this test as passed. Equivalent tostartSequence().thenSucceed()but without the one-tick delay. -
succeedWhen
Pollspredicateeach tick; passes on the firsttrue. At most once per test. -
succeedAtTimeout
public void succeedAtTimeout()Pass at the end oftimeoutTicksafter the final tick's callbacks and sequence actions have run. -
onEachTick
Register a named, initially enabled callback that runs once per test tick until the test ends. Useful for negative assertions that must hold continuously.The returned handle is initially enabled and can temporarily disable or permanently remove the callback. Per-tick callbacks run in registration order during the END phase, before
succeedWhen, END-phase sequence actions, and timeout evaluation. A callback registered while per-tick callbacks are running begins on the next tick. If the callback fails,nameis included in reports. UseonEachTickDisabled(String, Runnable)when a sequence enables the callback later.- Parameters:
name- non-blank diagnostic name for this callbackcallback- action invoked during each enabled END phase- Returns:
- a handle that controls this callback registration
-
onEachTick
Deprecated.UseonEachTick(String, Runnable)so failures identify the callback.Register an initially enabled callback without a diagnostic name. -
onEachTickDisabled
Register a named, initially disabled per-tick callback. Enable the returned handle from a sequence action when its observation window begins.- Parameters:
name- non-blank diagnostic name for this callbackcallback- action invoked during each enabled END phase- Returns:
- a disabled handle that controls this callback registration
-
afterTest
Registercallbackto run once when this test ends, regardless of outcome. -
assumeTrue
Skip this test whenconditionisfalse. The reason is included in machine-readable reports. Like assertion helpers, a failed assumption aborts the current test callback immediately. -
assumeFalse
Skip this test whenconditionistrue. The reason is included in machine-readable reports. Like assertion helpers, a failed assumption aborts the current test callback immediately. -
fail
Immediately fail this test withmessage. ThrowsGameTestAssertExceptionso that any enclosingthenExecutelambda propagates the failure correctly. -
fail
public void fail()Immediately fail this test with no message. -
assertTrue
Fail ifconditionisfalse. -
assertTrue
public void assertTrue(boolean condition) Fail ifconditionisfalse. -
assertFalse
Fail ifconditionistrue. -
assertFalse
public void assertFalse(boolean condition) Fail ifconditionistrue. -
assertNull
Fail ifactualis notnull. -
assertNull
Fail ifactualis notnull. -
assertNotNull
Fail ifactualisnull. -
assertNotNull
Fail ifactualisnull. -
assertEquals
-
assertEquals
-
assertItemEqual
public void assertItemEqual(net.minecraft.item.ItemStack expected, net.minecraft.item.ItemStack actual, String message) Fail ifexpectedandactualdiffer by item, damage, stack size, or NBT. The failure message prints all four fields for both stacks. Twonullstacks compare equal. -
assertItemEqual
public void assertItemEqual(net.minecraft.item.ItemStack expected, net.minecraft.item.ItemStack actual) Fail ifexpectedandactualdiffer by item, damage, stack size, or NBT. The failure message prints all four fields for both stacks. Twonullstacks compare equal. -
assertEquals
Fail ifexpected != actual. -
assertEquals
public void assertEquals(long expected, long actual) Fail ifexpected != actual. -
assertEquals
Fail if|expected - actual| > delta. -
assertEquals
public void assertEquals(double expected, double actual, double delta) Fail if|expected - actual| > delta. -
assertNotEquals
-
assertNotEquals
-
assertNotEquals
Fail ifunexpected == actual. -
assertNotEquals
public void assertNotEquals(long unexpected, long actual) Fail ifunexpected == actual. -
assertNotEquals
Fail if|unexpected - actual| <= delta. -
assertNotEquals
public void assertNotEquals(double unexpected, double actual, double delta) Fail if|unexpected - actual| <= delta. -
assertSame
Fail ifexpectedandactualare not the same object reference (==). -
assertSame
Fail ifexpectedandactualare not the same object reference (==). -
assertNotSame
Fail ifunexpectedandactualare the same object reference (==). -
assertNotSame
Fail ifunexpectedandactualare the same object reference (==). -
assertInstanceOf
Fail ifactualis not an instance oftype. Returnsactualcast toT. -
assertInstanceOf
Fail ifactualis not an instance oftype. Returnsactualcast toT. -
assertThrows
Assert thatactionthrows an exception of exactly typeexpectedType. Returns the thrown exception for further inspection. Fails if nothing is thrown or the wrong type is thrown. -
assertThrows
Assert thatactionthrows an exception of exactly typeexpectedType. Returns the thrown exception for further inspection. -
assertIterableEquals
Assert that two iterables contain equal elements in the same order (deep equality viaObjects.equals(java.lang.Object, java.lang.Object)). -
assertIterableEquals
Assert that two iterables contain equal elements in the same order. -
assertLinesMatch
Assert thatactualLinesmatchesexpectedLinesline by line. Each expected line is first compared verbatim; on mismatch it is tried as aregex. Use">>"to skip all remaining actual lines, or">> N >>"to skip exactly N lines. -
assertLinesMatch
-
getWorld
public net.minecraft.world.WorldServer getWorld() -
getRecorder
Event log for this test instance. Events are appended in emit order; filter withsnapshot().stream()to query specific event types. -
getOriginX
public int getOriginX() -
getOriginY
public int getOriginY() -
getOriginZ
public int getOriginZ() -
assertBlockPresent
public void assertBlockPresent(net.minecraft.block.Block expected, int x, int y, int z) Assert that the block at test-local position(x, y, z)isexpected. Optionally checks metadata whenmeta >= 0. -
assertBlockPresent
Assert that the block at test-local positionposisexpected. -
assertBlockPresent
Assert that the block at the named structure position isexpected. -
assertBlockPresent
public void assertBlockPresent(net.minecraft.block.Block expected, int meta, int x, int y, int z) Assert that the block at test-local position isexpectedwith the given metadata. Passmeta < 0to skip the meta check. -
assertBlockPresent
Assert that the block atposisexpectedwith the given metadata. -
assertBlockPresent
Assert that the block at the named structure position isexpectedwith the given metadata. -
assertBlockAbsent
public void assertBlockAbsent(net.minecraft.block.Block unexpected, int x, int y, int z) Assert that the block at test-local position(x, y, z)is NOTunexpected. -
assertBlockAbsent
Assert that the block at test-local positionposis NOTunexpected. -
assertBlockAbsent
Assert that the block at the named structure position is NOTunexpected. -
assertTileEntityPresent
public net.minecraft.tileentity.TileEntity assertTileEntityPresent(int x, int y, int z) Assert that a TileEntity exists at test-local position(x, y, z). Returns the TileEntity for further inspection. -
assertTileEntityPresent
Assert that a TileEntity exists at the test-local position and return it. -
assertTileEntityPresent
Assert that a TileEntity exists at the named structure position and return it. -
assertTileEntityPresent
public <T extends net.minecraft.tileentity.TileEntity> T assertTileEntityPresent(Class<T> type, int x, int y, int z) Assert that a TileEntity of a specific type exists at test-local position. Returns the TileEntity cast to the requested type. -
assertTileEntityPresent
public <T extends net.minecraft.tileentity.TileEntity> T assertTileEntityPresent(Class<T> type, TestPos pos) Assert that a TileEntity oftypeexists at the test-local position and return it. -
assertTileEntityPresent
public <T extends net.minecraft.tileentity.TileEntity> T assertTileEntityPresent(Class<T> type, String label) Assert that a TileEntity oftypeexists at the named structure position and return it. -
assertTileNBT
public void assertTileNBT(int x, int y, int z, net.minecraft.nbt.NBTTagCompound expectedSubset) Assert that the TileEntity NBT at test-local position contains all keys/values fromexpectedSubset. Only the keys present inexpectedSubsetare checked. -
assertTileNBT
Assert that the TileEntity NBT at the test-local position containsexpectedSubset. -
assertTileNBT
Assert that the TileEntity NBT at the named structure position containsexpectedSubset. -
assertTileNBTPath
Assert a specific value at a dotted NBT path (e.g."mInventory.0.id"). Comparison is done via the tag's string representation. -
assertTileNBTPath
Assert a value at a dotted NBT path on the TileEntity at the test-local position. -
assertTileNBTPath
Assert a value at a dotted NBT path on the TileEntity at the named structure position. -
getTileNBT
public net.minecraft.nbt.NBTTagCompound getTileNBT(int x, int y, int z) Return a deep copy of the TileEntity's serialized NBT at test-local position. -
getTileNBT
Return a deep copy of the TileEntity's serialized NBT at the test-local position. -
getTileNBT
Return a deep copy of the TileEntity's serialized NBT at the named structure position. -
getEntities
public <T extends net.minecraft.entity.Entity> List<T> getEntities(Class<T> type, int x, int y, int z) Return live entities oftypewhose bounding boxes intersect the single test-local block at(x, y, z). -
getEntities
Return live entities oftypeintersecting the single test-local block atpos. -
getEntities
Return live entities oftypeintersecting the single block at the named structure position. -
getEntities
public <T extends net.minecraft.entity.Entity> List<T> getEntities(Class<T> type, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Return live entities oftypewhose bounding boxes intersect the inclusive test-local block range. -
getEntities
public <T extends net.minecraft.entity.Entity> List<T> getEntities(Class<T> type, TestPos min, TestPos max) Return live entities oftypeintersecting the inclusive test-local block range. -
getEntities
public <T extends net.minecraft.entity.Entity> List<T> getEntities(Class<T> type, String minLabel, String maxLabel) Return live entities oftypeintersecting the inclusive range between two structure labels. -
assertEntityPresent
public net.minecraft.entity.Entity assertEntityPresent(int x, int y, int z) Assert that at least one live entity exists in the single test-local block at(x, y, z). Returns the first matching entity for further inspection. -
assertEntityPresent
Assert that at least one live entity exists in the single test-local block atpos. -
assertEntityPresent
Assert that at least one live entity exists at the named structure position. -
assertEntityPresent
public <T extends net.minecraft.entity.Entity> T assertEntityPresent(Class<T> type, int x, int y, int z) Assert that at least one live entity oftypeexists in the single test-local block at(x, y, z). Returns the first matching entity for further inspection. -
assertEntityPresent
Assert that at least one live entity oftypeexists in the block atpos. -
assertEntityPresent
Assert that at least one live entity oftypeexists at the named structure position. -
assertEntityAbsent
public void assertEntityAbsent(int x, int y, int z) Assert that no live entity exists in the single test-local block at(x, y, z). -
assertEntityAbsent
Assert that no live entity exists in the single test-local block atpos. -
assertEntityAbsent
Assert that no live entity exists at the named structure position. -
assertEntityAbsent
public void assertEntityAbsent(Class<? extends net.minecraft.entity.Entity> type, int x, int y, int z) Assert that no live entity oftypeexists in the single test-local block at(x, y, z). -
assertEntityAbsent
Assert that no live entity oftypeexists in the single test-local block atpos. -
assertEntityAbsent
Assert that no live entity oftypeexists at the named structure position. -
assertEntityCount
public void assertEntityCount(int expectedCount, int x, int y, int z) Assert that exactlyexpectedCountlive entities exist in the single test-local block at(x, y, z). -
assertEntityCount
Assert the live entity count in the single test-local block atpos. -
assertEntityCount
Assert the live entity count at the named structure position. -
assertEntityCount
public void assertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, int x, int y, int z) Assert that exactlyexpectedCountlive entities oftypeexist in the single test-local block at(x, y, z). -
assertEntityCount
public void assertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, TestPos pos) Assert the live entity count oftypein the single test-local block atpos. -
assertEntityCount
public void assertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, String label) Assert the live entity count oftypeat the named structure position. -
assertEntityCount
public void assertEntityCount(int expectedCount, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Assert that exactlyexpectedCountlive entities exist in the inclusive test-local block range. -
assertEntityCount
Assert the live entity count in the inclusive test-local block range. -
assertEntityCount
Assert the live entity count in the inclusive range between two structure labels. -
assertEntityCount
public void assertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Assert that exactlyexpectedCountlive entities oftypeexist in the inclusive test-local block range. -
assertEntityCount
public void assertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, TestPos min, TestPos max) Assert the live entity count oftypein the inclusive test-local block range. -
assertEntityCount
public void assertEntityCount(Class<? extends net.minecraft.entity.Entity> type, int expectedCount, String minLabel, String maxLabel) Assert the live entity count oftypein the inclusive range between two structure labels. -
spawnEntity
public <T extends net.minecraft.entity.Entity> T spawnEntity(T entity, double x, double y, double z) Spawnentityat the test-local position and return it.- Throws:
GameTestAssertException- if the world refuses to spawn the entity
-
spawnEntity
Spawnentityat the test-local block position and return it. -
spawnEntity
Spawnentityat the named structure position and return it. -
spawnEntity
Create an entity by NBT entity id, spawn it at the test-local position, and return it. -
spawnEntity
Create an entity by NBT entity id and spawn it at the test-local block position. -
spawnEntity
Create an entity by NBT entity id and spawn it at the named structure position. -
assertEntityNBT
public void assertEntityNBT(net.minecraft.entity.Entity entity, net.minecraft.nbt.NBTTagCompound expectedSubset) Assert that the entity's NBT contains all keys/values fromexpectedSubset. Only the keys present inexpectedSubsetare checked. -
assertEntityNBTPath
public void assertEntityNBTPath(net.minecraft.entity.Entity entity, String path, String expectedValue) Assert a specific value at a dotted NBT path on an entity (e.g."Pos.0"). Comparison is done via the tag's string representation. -
getEntityNBT
public net.minecraft.nbt.NBTTagCompound getEntityNBT(net.minecraft.entity.Entity entity) Return a deep copy of an entity's serialized NBT. -
insertItem
public void insertItem(int x, int y, int z, net.minecraft.item.ItemStack stack) Insert an ItemStack into the inventory at test-local position. Auto-detectsISidedInventoryvs plainIInventory.- Throws:
GameTestAssertException- if no inventory exists or the stack couldn't be fully inserted
-
insertItem
Insert an ItemStack into the inventory at a test-local (relative) TestPos. -
insertItem
Insert an ItemStack into the inventory at the named structure position. -
assertInventoryContains
public void assertInventoryContains(int x, int y, int z, net.minecraft.item.ItemStack expected) Assert that the inventory at test-local position contains at least the given stack (item, damage, NBT match; stack size is minimum). -
assertInventoryContains
Assert that the inventory at test-local (relative) TestPos contains at least the given stack. -
assertInventoryContains
Assert that the inventory at the named structure position contains at leastexpected. -
countItems
public long countItems(int x, int y, int z, net.minecraft.item.ItemStack template) Count all items matchingtemplate(item, damage, and NBT) in the inventory at test-local position. The template's stack size is ignored. -
countItems
Count all items matchingtemplatein the inventory at a test-local (relative) TestPos. -
countItems
Count all matching items in the inventory at the named structure position. -
assertInventoryCount
public void assertInventoryCount(int x, int y, int z, net.minecraft.item.ItemStack template, long expectedCount) Assert that exactlyexpectedCountitems matchingtemplateexist across the inventory at test-local position. The template's stack size is ignored andexpectedCountmay be zero. -
assertInventoryCount
public void assertInventoryCount(TestPos pos, net.minecraft.item.ItemStack template, long expectedCount) Assert an exact matching item count across the inventory at a test-local (relative) TestPos. -
assertInventoryCount
public void assertInventoryCount(String label, net.minecraft.item.ItemStack template, long expectedCount) Assert an exact matching item count in the inventory at the named structure position. -
assertInventoryEmpty
public void assertInventoryEmpty(int x, int y, int z) Assert that every slot of the inventory at test-local position is empty. -
assertInventoryEmpty
Assert that every slot of the inventory at the test-local position is empty. -
assertInventoryEmpty
Assert that every slot of the inventory at the named structure position is empty. -
assertSlot
public void assertSlot(int x, int y, int z, int slot, net.minecraft.item.ItemStack expected) Assert that a specific slot contains the given stack (exact item + damage + NBT + size). -
assertSlot
Assert the contents of a specific inventory slot at the test-local position. -
assertSlot
Assert the contents of a specific inventory slot at the named structure position. -
setSlot
public void setSlot(int x, int y, int z, int slot, net.minecraft.item.ItemStack stack) Directly set an inventory slot at test-local position to a copy ofstack, bypassing normal insertion rules, then mark the inventory dirty. -
setSlot
Directly set an inventory slot at a test-local (relative) TestPos. -
setSlot
Directly set an inventory slot at the named structure position. -
clearSlot
public void clearSlot(int x, int y, int z, int slot) Directly clear an inventory slot at test-local position, bypassing normal extraction rules, then mark the inventory dirty. -
clearSlot
Directly clear an inventory slot at a test-local (relative) TestPos. -
clearSlot
Directly clear an inventory slot at the named structure position. -
extractItem
public int extractItem(int x, int y, int z, net.minecraft.item.ItemStack template, int maxAmount) Extract up tomaxAmountitems matchingtemplatefrom the inventory. Returns the actual amount extracted. -
extractItem
Extract matching items from the inventory at the test-local position. -
extractItem
Extract matching items from the inventory at the named structure position. -
insertFluid
public void insertFluid(int x, int y, int z, net.minecraftforge.fluids.FluidStack fluid) Insert a FluidStack into the fluid handler at test-local position.- Throws:
GameTestAssertException- if no fluid handler exists or the fluid couldn't be fully inserted
-
insertFluid
Insert a FluidStack into the fluid handler at the test-local position. -
insertFluid
Insert a FluidStack into the fluid handler at the named structure position. -
assertFluidTank
public void assertFluidTank(int x, int y, int z, net.minecraftforge.fluids.FluidStack expected) Assert that the fluid handler at test-local position contains at leastexpected.amountmB of the expected fluid. -
assertFluidTank
Assert that the fluid handler at the test-local position contains at leastexpected. -
assertFluidTank
Assert that the fluid handler at the named structure position contains at leastexpected. -
assertFluidTankEmpty
public void assertFluidTankEmpty(int x, int y, int z) Assert that the fluid handler at test-local position has no fluid. -
assertFluidTankEmpty
Assert that the fluid handler at the test-local position has no fluid. -
assertFluidTankEmpty
Assert that the fluid handler at the named structure position has no fluid. -
setBlock
public void setBlock(int x, int y, int z, net.minecraft.block.Block block, int meta) Place a block at test-local position. Uses flag 3 (notify + send to client). -
setBlock
Place a block with metadata at the test-local position. -
setBlock
Place a block with metadata at the named structure position. -
setBlock
public void setBlock(int x, int y, int z, net.minecraft.block.Block block) -
setBlock
Place a block at the test-local position. -
setBlock
Place a block at the named structure position. -
destroyBlock
public void destroyBlock(int x, int y, int z) Destroy the block at test-local position (replace with air). Drops are not spawned. -
destroyBlock
Destroy the block at the test-local position. -
destroyBlock
Destroy the block at the named structure position. -
setTile
public void setTile(int x, int y, int z, net.minecraft.nbt.NBTTagCompound nbt) Apply an NBT compound to the TileEntity at test-local position. The x/y/z keys in the compound are overwritten with the absolute position so the TE doesn't teleport. -
setTile
Apply an NBT compound to the TileEntity at the test-local position. -
setTile
Apply an NBT compound to the TileEntity at the named structure position. -
pulseRedstone
public void pulseRedstone(int x, int y, int z, int durationTicks) Place a redstone block at the given test-local position fordurationTicks, then remove it. Uses a delayed sequence event on the test instance. -
pulseRedstone
Pulse a redstone block at the test-local position. -
pulseRedstone
Pulse a redstone block at the named structure position. -
setRedstoneInput
public void setRedstoneInput(int x, int y, int z, int strength) Set a redstone signal source (repeater-like) at test-local position by placing a redstone block (strength = 15) or air (strength = 0).- Parameters:
strength- 0 to clear, any positive value places a redstone block (full signal 15)
-
setRedstoneInput
Set a redstone signal source at the test-local position. -
setRedstoneInput
Set a redstone signal source at the named structure position. -
assertRedstonePower
public void assertRedstonePower(int x, int y, int z, int minPower) Assert that the block at test-local position is receiving at leastminPowerredstone power. -
assertRedstonePower
Assert the minimum redstone power at the test-local position. -
assertRedstonePower
Assert the minimum redstone power at the named structure position. -
disableRandomTicks
public void disableRandomTicks()Disable random block ticks in this world (e.g. crop growth, leaf decay) for deterministic tests. The originalrandomTickSpeedvalue is automatically restored after the test. -
fixWorldTime
public void fixWorldTime(long ticks) Fix the world time to a specific value and disable the daylight cycle. The original time anddoDaylightCyclevalue are automatically restored after the test. -
setWeather
Apply a weather preset and lock it for the duration of the test. The original weather state is automatically restored after the test. -
spawnFakePlayer
Spawn a fake player with the given profile name, positioned at the test's origin. -
simulateRightClick
public boolean simulateRightClick(int x, int y, int z, net.minecraftforge.common.util.FakePlayer player, net.minecraft.item.ItemStack heldItem) Simulate a right-click on the block at test-local position using the given player and held item. Returns true if the activation was handled. -
simulateRightClick
public boolean simulateRightClick(TestPos pos, net.minecraftforge.common.util.FakePlayer player, net.minecraft.item.ItemStack heldItem) Simulate a right-click on the block at the test-local position. -
simulateRightClick
public boolean simulateRightClick(String label, net.minecraftforge.common.util.FakePlayer player, net.minecraft.item.ItemStack heldItem) Simulate a right-click on the block at the named structure position. -
simulateLeftClick
public void simulateLeftClick(int x, int y, int z, net.minecraftforge.common.util.FakePlayer player) Simulate a left-click (block punch) at test-local position. -
simulateLeftClick
Simulate a left-click on the block at the test-local position. -
simulateLeftClick
Simulate a left-click on the block at the named structure position. -
gtnh
Return the GTNH-specific helper that provides GregTech machine assertions, EU supply, time-warp, and fluid-hatch utilities. The helper is created lazily on first call and reused on subsequent calls within the same test instance.- Throws:
IllegalStateException- if GT5-Unofficial (mod IDgregtech) is not loaded
-
onEachTick(String, Runnable)so failures identify the callback.