Add ProgressBar/EnergyBar/FluidTank composables and energy storage - #3
Conversation
New GUI composables (all under gui/composables/basic): - ProgressBar: themed linear fill indicator, four fill directions. - EnergyBar: ProgressBar tuned for ArchieEnergyStorage (bottom-up default). - FluidTank: themed tank indicator rendering the real fluid texture and tint via a new per-loader render bridge (AFluidRenderPlatform), since Fabric's FluidRenderHandlerRegistry and NeoForge's IClientFluidTypeExtensions expose a fluid's client appearance through unrelated APIs. New ArchieEnergyStorage (transfer/) mirrors ArchieItemStorage/ ArchieFluidStorage's insert/extract/simulate shape as a single capacity-capped buffer - no CommonStorage backing, since there's no cross-loader "EnergyResource" the way there is for items/fluids. Bridging to a platform energy capability (NeoForge IEnergyStorage, Fabric Team Reborn Energy) is left to the consuming mod. Also fills a pre-existing gap: NBTHolder only exposed itemField(), even though ArchieFluidStorage already existed - added fluidField()/ energyField() (all three NBTHolder implementations) so fluid/energy storage can be declared the same declarative way as item storage. Ships default "java" theme JSON + sprites for all three new composables (progress_bar/energy_bar/fluid_tank), matching the existing button/slider convention - required, not optional, since ComposableTheme throws if a composable's theme isn't registered. Verified via ./gradlew :common:compileKotlin, :fabric:compileKotlin, and :neoforge:compileKotlin (all succeed) - not run through the full GameTest suite. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Common Storage Lib (already an Archie dependency) already ships an energy API - earth.terrarium.common_storage_lib.energy.EnergyApi, EnergyProvider, and the storage.base.ValueStorage interface - that the previous commit missed, incorrectly claiming "there's no cross-loader EnergyResource the way there is for items/fluids" and building a standalone class instead. ArchieEnergyStorage now implements ValueStorage + UpdateManager<NbtTag> the same way ArchieItemStorage/ArchieFluidStorage implement CommonStorage<T> + UpdateManager<NbtTag>, so it's consistent with the rest of transfer/ and interoperable with anything else built against CSL's ValueStorage. getAmount() is renamed to getStoredAmount() to match the interface's real method name. Archie still doesn't auto-register with EnergyApi.BLOCK/ITEM/ENTITY, matching the current (also unregistered) state of item/fluid storage - that's left as consistent future work for all three, not something to bolt onto energy alone in this PR. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Caught + fixed: |
There was a problem hiding this comment.
Pull request overview
Adds new GUI indicators (progress/energy/fluid) and introduces a platform-agnostic energy storage type, extending NBTHolder to support item/fluid/energy delegated storage fields across its implementations. This fits into Archie’s existing GUI framework (Compose-based widgets + theme sprites) and transfer/serialization patterns (CSL storage types + NBT snapshotting + optional @Sync state-container wiring).
Changes:
- Added
ProgressBar,EnergyBar, andFluidTankcomposables, including a cross-loader fluid render bridge for real fluid sprite + tint rendering. - Introduced
ArchieEnergyStorage(CSLValueStorage+ Archie NBT snapshot serialization). - Extended
NBTHolder(+ all implementations) withfluidField(...)andenergyField(...), and updated docs + theme assets for the new composables.
Reviewed changes
Copilot reviewed 20 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Archie/neoforge/src/main/kotlin/net/kernelpanicsoft/archie/gui/render/AFluidRenderPlatform.neoforge.kt | NeoForge actual implementation for fluid sprite/tint lookup via IClientFluidTypeExtensions. |
| Archie/fabric/src/main/kotlin/net/kernelpanicsoft/archie/gui/render/AFluidRenderPlatform.fabric.kt | Fabric actual implementation for fluid sprite/tint lookup via FluidRenderHandlerRegistry. |
| Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/gui/render/AFluidRenderPlatform.common.kt | Common expect API for cross-loader fluid appearance lookups used by GUI rendering. |
| Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/gui/composables/basic/ProgressBar.kt | New themed progress bar composable + shared fill rendering core. |
| Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/gui/composables/basic/EnergyBar.kt | New energy bar composable (wraps shared fill bar; supports raw values or ArchieEnergyStorage). |
| Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/gui/composables/basic/FluidTank.kt | New tank composable rendering real fluid sprite+tint with scissored fill. |
| Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/transfer/ArchieEnergyStorage.kt | New energy buffer type implementing CSL ValueStorage + NBT snapshot serialization. |
| Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/serialization/NBTHolder.kt | Adds fluidField(...) and energyField(...) delegate APIs to NBTHolder. |
| Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/serialization/NBTHolderImpl.kt | Implements fluidField(...)/energyField(...) for general NBTHolder (incl. BE sync/persistence hooks). |
| Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/serialization/ItemStackNBTHolderImpl.kt | Implements fluidField(...)/energyField(...) for item stack-backed holders + save/load wiring. |
| Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/serialization/FluidStackNBTHolderImpl.kt | Implements fluidField(...)/energyField(...) for fluid stack-backed holders + save/load wiring. |
| Archie/docs/gui.md | Documents the new indicator composables and usage examples. |
| Archie/docs/transfer.md | Documents ArchieFluidStorage and ArchieEnergyStorage usage + GUI integration points. |
| Archie/docs/serialization.md | Updates NBTHolder field-type documentation + examples for fluid/energy. |
| Archie/common/src/main/resources/assets/archie/textures/gui/sprites/java/progress_bar.png.mcmeta | Adds nine-slice metadata for the progress bar sprite. |
| Archie/common/src/main/resources/assets/archie/textures/gui/sprites/java/energy_bar.png.mcmeta | Adds nine-slice metadata for the energy bar sprite. |
| Archie/common/src/main/resources/assets/archie/textures/gui/sprites/java/fluid_tank.png.mcmeta | Adds nine-slice metadata for the fluid tank sprite. |
| Archie/common/src/main/resources/assets/archie/archie_themes/java/progress_bar.json | Registers default “java” theme entry for progress bar. |
| Archie/common/src/main/resources/assets/archie/archie_themes/java/energy_bar.json | Registers default “java” theme entry for energy bar. |
| Archie/common/src/main/resources/assets/archie/archie_themes/java/fluid_tank.json | Registers default “java” theme entry for fluid tank. |
Suppressed comments (1)
Archie/common/src/main/kotlin/net/kernelpanicsoft/archie/transfer/ArchieEnergyStorage.kt:118
Serializer.deserializecan construct anArchieEnergyStoragewith a negative capacity or an out-of-range stored amount. Since this data may come from NBT/network sync, it should be sanitized the same way asreadSnapshotto avoid invalid runtime state.
override fun deserialize(decoder: Decoder): ArchieEnergyStorage
{
val capacity = decoder.decodeLong()
val amount = decoder.decodeLong()
return ArchieEnergyStorage(capacity).also { it.amount = amount }
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| override fun readSnapshot(snapshot: NbtTag) | ||
| { | ||
| val decoded = NBT.decodeFromNbtTagRootless(serializer(), snapshot) | ||
| this.capacity = decoded.capacity | ||
| this.amount = decoded.amount | ||
| } |
| /** Declares an [ArchieFluidStorage] field with [size] tank slots each capped at [limit], keyed by the delegated property's name. */ | ||
| fun fluidField(limit: Long, size: Int = 1): PropertyDelegateProvider<Any?, ReadOnlyProperty<Any?, ArchieFluidStorage>> | ||
|
|
||
| /** Declares an [ArchieEnergyStorage] field capped at [capacity], keyed by the delegated property's name. */ | ||
| fun energyField(capacity: Long): PropertyDelegateProvider<Any?, ReadOnlyProperty<Any?, ArchieEnergyStorage>> |
| ProgressBar( | ||
| progress = observeProperty("progress", 0).value ?: 0 / smeltTicks.toFloat(), | ||
| direction = ProgressDirection.LEFT_TO_RIGHT, | ||
| ) |
Summary
gui/composables/basic/):ProgressBar(themed linear fill, 4 directions),EnergyBar(bottom-up by default, reads anArchieEnergyStorage),FluidTank(renders the real fluid texture + tint via a new per-loader render bridge, since Fabric'sFluidRenderHandlerRegistryand NeoForge'sIClientFluidTypeExtensionsexpose a fluid's client appearance through unrelated APIs).ArchieEnergyStorage(transfer/): implements Common Storage Lib'sValueStorage(the energy analogue of theCommonStorage<ItemResource>/CommonStorage<FluidResource>ArchieItemStorage/ArchieFluidStorageimplement) plus Archie's NBT serialization, mirroring their shape exactly. Archie doesn't auto-register it with CSL'sEnergyApi.BLOCK/ITEM/ENTITYlookups or bridge a platform energy capability (NeoForgeIEnergyStorage, Fabric Team Reborn Energy) - matching the current (also-unregistered) state of item/fluid storage, left as consistent future work for all three.NBTHolderonly exposeditemField()even thoughArchieFluidStoragealready existed. AddedfluidField()/energyField()across all threeNBTHolderimplementations (NBTHolderImpl,ItemStackNBTHolderImpl,FluidStackNBTHolderImpl).ComposableThemethrows if a composable's theme isn't registered).gui.md,transfer.md,serialization.md.Test plan
./gradlew :common:compileKotlin- succeeds./gradlew :fabric:compileKotlin- succeeds./gradlew :neoforge:compileKotlin- succeeds./gradlew :common:verifyGuiSpriteAssets- succeedsFluidTank's fluid rendering (compile-verified only; the tint/sprite math wasn't visually confirmed against a running client)🤖 Generated with Claude Code