Skip to content

feat: capability-lookup wrapper (Phase 1) + public GameTest assertions - #12

Merged
KP2048 merged 2 commits into
1.21.xfrom
feature-capability-lookup
Aug 8, 2026
Merged

feat: capability-lookup wrapper (Phase 1) + public GameTest assertions#12
KP2048 merged 2 commits into
1.21.xfrom
feature-capability-lookup

Conversation

@KP2048

@KP2048 KP2048 commented Aug 7, 2026

Copy link
Copy Markdown
Member

Phase 1 of the pre-release storage/GUI plan: capability-lookup wrapper

Wraps Common Storage Lib's ItemApi/FluidApi/EnergyApi.BLOCK singletons (already
transitively on Archie's classpath, no new Gradle dependency) so ArchieItemStorage/
ArchieFluidStorage/ArchieEnergyStorage can be exposed to third-party mods' pipes and
hoppers on both loaders with one call at registration time — closing the gap called out
explicitly in ArchieEnergyStorage's own KDoc.

New API — net.kernelpanicsoft.archie.transfer.ArchieCapabilityExposure

TileRegistry.TestTile.exposeItemStorage { tile, direction ->
    if (direction == Direction.DOWN) null else tile.items
}
  • exposeItemStorage/exposeFluidStorage/exposeEnergyStorage on BlockEntityType<T>,
    each with a direction-aware and a no-direction overload, wrapping CSL's
    BlockLookup.onRegister { registrar -> registrar.registerBlockEntities(...) } (the only
    reachable path for BlockEntityGetter-based registration — confirmed via javap against
    the real CSL jars; registerSelf only accepts Block-keyed BlockGetter).
  • RegistrySupplier<BlockEntityType<T>> convenience overloads via Architectury's .listen{},
    for calling right next to a DeferredRegister declaration.
  • Stretch: Item.exposeItemStorage via ItemApi.ITEM, for item-in-item interop with other
    CSL-depending mods.
  • Deliberately not auto-wired into NBTHolder.itemField/etc. — registration must happen
    once per BlockEntityType, while those delegates run per-instance; an explicit call at
    registration time avoids awkward static bookkeeping.

Verification

New CapabilityLookupTests/CapabilityLookupTestFixtures in Archie-Test, registered at
mod-init time (after TileRegistry.init(), mirroring real consumer-mod usage — CSL's
onRegister is a one-shot listener that fires during CSL's own platform registration event,
long before a GameTest server boots, so this can't live inside the @GameTest methods
themselves). All 3 pass under a real fabric-test:runGametest run:

[GameTest] PASS archie:capabilitylookuptests.testexposeitemstoragereachesitemapiblock
[GameTest] PASS archie:capabilitylookuptests.testexposeitemstoragerespectsdirection
[GameTest] PASS archie:capabilitylookuptests.testunexposedtypeisnotfound

Manual-only (not GameTest-coverable): a real hopper/pipe mod on both Fabric and NeoForge
pulling/pushing into a block exposing ArchieItemStorage, before release.

Also in this PR: make GameTestAssertions.kt public

assertTrue/assertEquals/expectThrows were internal to Archie's own common module,
so Archie-Test's new tests above couldn't use them despite being the obvious sugar for this
kind of test. Moved from gametest.internal.tests to the public net.kernelpanicsoft.archie.gametest
package (alongside AClientGameTestHarness.kt) and made public; updated the 3 server-side
test files that referenced them via same-package resolution to import explicitly, and updated
docs/gametest.md/AGENTS.md to match.

Part of the three-feature pre-release plan (capability lookup / data attachments / item-backed
container menus); Phases 2 and 3 to follow in separate PRs.

🤖 Generated with Claude Code

Add ArchieCapabilityExposure.kt, wrapping Common Storage Lib's ItemApi/
FluidApi/EnergyApi.BLOCK singletons so BlockEntity-backed storage can be
exposed to third-party pipes/hoppers on both loaders with one call at
registration time (exposeItemStorage/exposeFluidStorage/exposeEnergyStorage,
plus RegistrySupplier convenience overloads and a stretch Item.exposeItemStorage
via ItemApi.ITEM). Update ArchieEnergyStorage's KDoc to point at the new helper.

Add CapabilityLookupTests/CapabilityLookupTestFixtures to Archie-Test,
verifying the wrapper actually reaches ItemApi.BLOCK.find (not just
Archie-internal bookkeeping) against a real registered BlockEntityType
(TileRegistry.TestTile) - fixture registration runs at mod-init time
(after TileRegistry.init()), matching real consumer-mod usage, since CSL's
BlockLookup.onRegister is a one-shot listener that fires during CSL's own
platform registration event, long before a GameTest server boots.

Also make GameTestAssertions.kt's assertTrue/assertEquals/expectThrows
public and move them from the internal gametest.internal.tests package to
the public net.kernelpanicsoft.archie.gametest package, so consuming mods
(including Archie-Test) can use them instead of hand-rolled fail(...) checks.
Update the 3 server-side test files that used them via same-package
resolution to import explicitly, and update docs/gametest.md and AGENTS.md
to match.

Verified: :common:compileKotlin and :common-test:compileKotlin both clean,
and CapabilityLookupTests all pass under a real fabric-test:runGametest run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@KP2048
KP2048 marked this pull request as ready for review August 8, 2026 15:32
Copilot AI lite review requested due to automatic review settings August 8, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@KP2048
KP2048 merged commit 4d385fb into 1.21.x Aug 8, 2026
3 of 4 checks passed
@KP2048
KP2048 deleted the feature-capability-lookup branch August 8, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants