Class GTNHGameTestHelper

java.lang.Object
com.gtnewhorizons.horizonqa.api.gt.GTNHGameTestHelper

public class GTNHGameTestHelper extends Object
GT-specific test helper returned by GameTestHelper.gtnh().

All TestPos arguments use test-local (relative) coordinates — the same convention as the int-coordinate overloads on GameTestHelper. Internally they are converted to world-absolute coordinates via GameTestHelper.absolute(int, int, int).

Time-warping (fastForwardTicks(int)/runUntilMachineIdle(com.gtnewhorizons.horizonqa.api.TestPos, int)) is fully synchronous: GT tile entities in the test region are force-ticked without advancing global server time, so recipe completion tests finish in milliseconds of wall-clock time.

  • Constructor Summary

    Constructors
    Constructor
    Description
    GTNHGameTestHelper(GameTestHelper base, net.minecraft.world.WorldServer world, int originX, int originY, int originZ)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Adapter used to read GT-internal state through one quarantined seam.
    void
    assertCleanroomStatus(TestPos relPos, int expectedEfficiency)
    Assert that the cleanroom controller at relPos has an efficiency of at least expectedEfficiency (0–10000, representing 0–100.00 %).
    void
    assertEUStored(TestPos relPos, long expectedEU)
    Assert that the GT tile entity at relPos has at least expectedEU stored EU.
    void
    assertFluidInHatch(TestPos relPos, String fluidName, int amount)
    Assert that the fluid hatch at relPos contains at least amount mB of the named fluid.
    void
    assertItemInBus(TestPos relPos, String registryName, int meta, int count)
    Assert that the output bus / inventory at relPos contains at least count items of registryName at the given metadata value.
    void
    assertItemInBus(TestPos relPos, net.minecraft.item.ItemStack itemStack)
     
    void
    Assert that the block at relPos is no longer a GT tile entity — i.e.
    void
    Assert that the multiblock controller at relPos reports a fully formed structure (mMachine == true).
    void
    Assert that the multiblock at relPos currently has all of the given maintenance issues active (i.e.
    void
    assertPollutionEmitted(long expectedPollution)
    Assert that at least expectedPollution units of pollution were emitted in the origin chunk since this helper was created (i.e.
    void
    fastForwardTicks(int ticks)
    Force-tick every GT tile entity in the test region for the given number of simulated ticks without advancing global server time.
    void
    fastForwardTicks(int ticks, List<TestPos> watchedControllersAbs)
    Same as fastForwardTicks(int) but registers watchedControllersAbs (world-absolute positions) with the warp differ so per-tick recipe / formation / maintenance / explosion transitions are emitted as TestEvents into the per-test recorder.
    void
    fillHatch(TestPos relPos, String fluidName, int amount)
    Fill the fluid hatch at relPos with amount mB of the named fluid.
    void
    fillHatch(TestPos relPos, net.minecraftforge.fluids.FluidStack fluidStack)
    Fill the fluid hatch at relPos with the given FluidStack.
    void
    Fix all maintenance issues on the multiblock at relPos by calling MTEMultiBlockBase.fixAllIssues().
    gregtech.api.interfaces.tileentity.IGregTechTileEntity
    gtTile(TestPos relPos)
    Low-level escape hatch: the GregTech tile entity at relPos.
    void
    insertProgrammedCircuit(TestPos relPos, int config)
    Configure the programmed circuit slot of the input bus at relPos to config (1–24).
    gregtech.api.interfaces.metatileentity.IMetaTileEntity
    Low-level escape hatch: the meta tile entity at relPos.
    Controller at relPos (test-local coordinates).
    gregtech.api.metatileentity.implementations.MTEMultiBlockBase
    Low-level escape hatch: the multiblock controller meta tile entity at relPos.
    static void
    rotateStructureTileNbt(net.minecraft.nbt.NBTTagCompound nbt, int rotation)
     
    void
    runUntilMachineIdle(TestPos relPos, int timeoutTicks)
    Fast-forward the test region until the machine at relPos reports isActive() == false, or until timeoutTicks simulated ticks have elapsed.
    void
    supplyEU(TestPos relPos, long voltage, long amperage, int durationTicks)
    Register a virtual EU supply job.
    void
    withTestRecipe(Multiblock multi, gregtech.api.util.GTRecipe recipe)
    Inject a synthetic GTRecipe into the multiblock's recipemap for the rest of the test.
    void
    withTestRecipe(Multiblock multi, gregtech.api.util.GTRecipeBuilder builder)
    Builds builder and injects the result into the multiblock's recipemap for the rest of the test.
    withWarpRange(int blocks)
    Override the default 32-block fast-forward region.

    Methods inherited from class java.lang.Object

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

    • GTNHGameTestHelper

      public GTNHGameTestHelper(GameTestHelper base, net.minecraft.world.WorldServer world, int originX, int originY, int originZ)
  • Method Details

    • adapter

      public GTAdapter adapter()
      Adapter used to read GT-internal state through one quarantined seam.
    • gtTile

      public gregtech.api.interfaces.tileentity.IGregTechTileEntity gtTile(TestPos relPos)
      Low-level escape hatch: the GregTech tile entity at relPos.

      Prefer role-based helpers such as multiblock(TestPos), Multiblock.inputBus(int), and Multiblock.energyHatch(int) when they cover the case under test.

    • metaTileEntity

      public gregtech.api.interfaces.metatileentity.IMetaTileEntity metaTileEntity(TestPos relPos)
      Low-level escape hatch: the meta tile entity at relPos.

      Prefer role-based helpers when possible. This is useful for exotic hatch paths or direct fixture setup that the facade does not model yet.

    • multiBlockController

      public gregtech.api.metatileentity.implementations.MTEMultiBlockBase multiBlockController(TestPos relPos)
      Low-level escape hatch: the multiblock controller meta tile entity at relPos.

      Prefer multiblock(TestPos) for normal tests.

    • rotateStructureTileNbt

      public static void rotateStructureTileNbt(net.minecraft.nbt.NBTTagCompound nbt, int rotation)
    • withWarpRange

      public GTNHGameTestHelper withWarpRange(int blocks)
      Override the default 32-block fast-forward region. Increase for very large multiblocks (e.g. Fusion Reactors) whose hatches extend far from the controller.
    • assertMachineFormed

      public void assertMachineFormed(TestPos relPos)
      Assert that the multiblock controller at relPos reports a fully formed structure (mMachine == true). If the flag is false, MTEMultiBlockBase.checkStructure(boolean, gregtech.api.interfaces.tileentity.IGregTechTileEntity) is called with forceReset=true before failing, to handle cases where the structure placer did not trigger a block-update chain.
      See Also:
    • fixAllMaintenanceIssues

      public void fixAllMaintenanceIssues(TestPos relPos)
      Fix all maintenance issues on the multiblock at relPos by calling MTEMultiBlockBase.fixAllIssues(). Equivalent to using every maintenance tool on the machine, setting all six flags to true.
      See Also:
    • assertMachineHasIssues

      public void assertMachineHasIssues(TestPos relPos, MaintenanceType... expected)
      Assert that the multiblock at relPos currently has all of the given maintenance issues active (i.e. the corresponding tool flag is false).
    • fastForwardTicks

      public void fastForwardTicks(int ticks)
      Force-tick every GT tile entity in the test region for the given number of simulated ticks without advancing global server time. EU supply jobs (from supplyEU(com.gtnewhorizons.horizonqa.api.TestPos, long, long, int)) are processed once per simulated tick before the GT TE pass.
    • fastForwardTicks

      public void fastForwardTicks(int ticks, List<TestPos> watchedControllersAbs)
      Same as fastForwardTicks(int) but registers watchedControllersAbs (world-absolute positions) with the warp differ so per-tick recipe / formation / maintenance / explosion transitions are emitted as TestEvents into the per-test recorder.
    • runUntilMachineIdle

      public void runUntilMachineIdle(TestPos relPos, int timeoutTicks)
      Fast-forward the test region until the machine at relPos reports isActive() == false, or until timeoutTicks simulated ticks have elapsed. Throws GameTestAssertException if the machine is still active at timeout.
    • supplyEU

      public void supplyEU(TestPos relPos, long voltage, long amperage, int durationTicks)
      Register a virtual EU supply job. Starting from the next call to fastForwardTicks(int)/runUntilMachineIdle(com.gtnewhorizons.horizonqa.api.TestPos, int), the energy hatch at relPos will receive voltage × amperage EU added to its buffer per simulated tick for durationTicks ticks.
      Parameters:
      relPos - test-local position of the energy hatch
      voltage - EU per packet (e.g. 1920 for EV)
      amperage - amps per tick
      durationTicks - number of simulated ticks to sustain the supply
    • assertEUStored

      public void assertEUStored(TestPos relPos, long expectedEU)
      Assert that the GT tile entity at relPos has at least expectedEU stored EU.
    • assertMachineExploded

      public void assertMachineExploded(TestPos relPos)
      Assert that the block at relPos is no longer a GT tile entity — i.e. the machine exploded and was replaced by air or debris.
    • fillHatch

      public void fillHatch(TestPos relPos, String fluidName, int amount)
      Fill the fluid hatch at relPos with amount mB of the named fluid.

      For GT tile entities the fill is applied directly on the IMetaTileEntity to bypass the mTickTimer > 5 guard in BaseMetaTileEntity, which would return 0 when called before the hatch has been ticked (e.g. during test setup).

      Parameters:
      relPos - test-local position of the fluid hatch
      fluidName - Forge registry fluid name (e.g. "nitrogen")
      amount - mB to fill
    • fillHatch

      public void fillHatch(TestPos relPos, net.minecraftforge.fluids.FluidStack fluidStack)
      Fill the fluid hatch at relPos with the given FluidStack.

      For GT tile entities the fill is applied directly on the IMetaTileEntity to bypass the mTickTimer > 5 guard in BaseMetaTileEntity.

    • assertFluidInHatch

      public void assertFluidInHatch(TestPos relPos, String fluidName, int amount)
      Assert that the fluid hatch at relPos contains at least amount mB of the named fluid.

      For GT tile entities the drain-peek is applied directly on the IMetaTileEntity to bypass the mTickTimer > 5 guard in BaseMetaTileEntity.

    • insertProgrammedCircuit

      public void insertProgrammedCircuit(TestPos relPos, int config)
      Configure the programmed circuit slot of the input bus at relPos to config (1–24). The circuit is written directly into IConfigurationCircuitSupport.getCircuitSlot() on the IMetaTileEntity, bypassing normal inventory insertion which explicitly skips that slot (isValidSlot returns false for it).
      Throws:
      IllegalArgumentException - if config is out of range or the item is unavailable
      GameTestAssertException - if the tile at relPos is not a GT input bus
    • assertItemInBus

      public void assertItemInBus(TestPos relPos, String registryName, int meta, int count)
      Assert that the output bus / inventory at relPos contains at least count items of registryName at the given metadata value.
      Parameters:
      relPos - test-local position of the output bus
      registryName - Forge registry name, e.g. "gregtech:gt.metaitem.01"
      meta - item damage/meta value
      count - minimum stack size to find
    • assertItemInBus

      public void assertItemInBus(TestPos relPos, net.minecraft.item.ItemStack itemStack)
    • assertPollutionEmitted

      public void assertPollutionEmitted(long expectedPollution)
      Assert that at least expectedPollution units of pollution were emitted in the origin chunk since this helper was created (i.e. since GameTestHelper.gtnh() was first called).
    • assertCleanroomStatus

      public void assertCleanroomStatus(TestPos relPos, int expectedEfficiency)
      Assert that the cleanroom controller at relPos has an efficiency of at least expectedEfficiency (0–10000, representing 0–100.00 %).
    • multiblock

      public Multiblock multiblock(TestPos relPos)
      Controller at relPos (test-local coordinates). Multiblock reads hatch lists from the live tile each time.
    • withTestRecipe

      public void withTestRecipe(Multiblock multi, gregtech.api.util.GTRecipe recipe)
      Inject a synthetic GTRecipe into the multiblock's recipemap for the rest of the test. The recipe (and its backend caches) is automatically removed when the test ends.
      Throws:
      GameTestAssertException - if the controller does not expose a RecipeMap
    • withTestRecipe

      public void withTestRecipe(Multiblock multi, gregtech.api.util.GTRecipeBuilder builder)
      Builds builder and injects the result into the multiblock's recipemap for the rest of the test. The recipe is automatically removed when the test ends. Fails the test immediately if the builder produces no recipe.
      Throws:
      GameTestAssertException - if the builder produces no recipe or the controller does not expose a RecipeMap