Skip to content

refactor: introduce FuelHelper interface for fuel value management#364

Merged
Indemnity83 merged 2 commits into
mc/26.1from
feat/introduce-fuelhelper-spi-abstract-level-fuelvalues
May 9, 2026
Merged

refactor: introduce FuelHelper interface for fuel value management#364
Indemnity83 merged 2 commits into
mc/26.1from
feat/introduce-fuelhelper-spi-abstract-level-fuelvalues

Conversation

@Indemnity83
Copy link
Copy Markdown
Owner

Summary

This update introduces a FuelHelper interface designed to standardize fuel value handling across different loaders, enriching the mod's compatibility and maintainability. By abstracting the fuel value logic, this change facilitates easier integration and extension of fuel-related functionality for future development, allowing developers to focus on building new features more efficiently.

Changes

  • New FuelHelper Interface:

    • Implemented a common FuelHelper interface that includes methods for validating fuel and retrieving burn durations.
    • Added service loader support to dynamically resolve the appropriate fuel helper for the current loader (Fabric or NeoForge).
  • Loader-Specific Implementations:

    • Created FabricFuelHelper and NeoForgeFuelHelper classes implementing the FuelHelper interface for their respective environments.
  • Updated Stirling Engine Logic:

    • Refactored the StirlingEngineBlockEntity and StirlingEngineScreenHandler to utilize the FuelHelper interface methods instead of direct level calls, improving code clarity and flexibility.

Notes

  • This change provides a unified way of handling fuel values, which will simplify future enhancements for adding more fuel types or modifying fuel mechanics across different platforms.

@Indemnity83 Indemnity83 changed the title feat: introduce FuelHelper interface for fuel value management refactor: introduce FuelHelper interface for fuel value management May 9, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d3262e60-c953-40e3-aff8-996817ec107b

📥 Commits

Reviewing files that changed from the base of the PR and between 4a35b62 and 41c3c6a.

📒 Files selected for processing (5)
  • common/src/main/java/com/logistics/core/lib/power/FuelHelper.java
  • common/src/main/java/com/logistics/power/engine/block/entity/StirlingEngineBlockEntity.java
  • common/src/main/java/com/logistics/power/engine/ui/StirlingEngineScreenHandler.java
  • fabric/src/main/java/com/logistics/fabric/FabricFuelHelper.java
  • neoforge/src/main/java/com/logistics/neoforge/NeoForgeFuelHelper.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • fabric/src/main/java/com/logistics/fabric/FabricFuelHelper.java
  • common/src/main/java/com/logistics/power/engine/block/entity/StirlingEngineBlockEntity.java
  • common/src/main/java/com/logistics/power/engine/ui/StirlingEngineScreenHandler.java

📝 Walkthrough

Walkthrough

This pull request introduces a centralized fuel abstraction layer for the Stirling engine. A new FuelHelper interface is created in the common module with methods isFuel and getBurnDuration, resolved at runtime via Java ServiceLoader. Platform-specific implementations are added for Fabric and NeoForge that delegate to their respective level.fuelValues() APIs. StirlingEngineBlockEntity and StirlingEngineScreenHandler are updated to use FuelHelper.INSTANCE for all fuel checks and burn-duration lookups, replacing direct calls to platform APIs.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: introducing a FuelHelper interface for standardized fuel value management across loaders.
Description check ✅ Passed The description provides comprehensive context about the FuelHelper interface introduction, loader-specific implementations, and refactored engine components, all directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/introduce-fuelhelper-spi-abstract-level-fuelvalues

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@common/src/main/java/com/logistics/core/lib/power/FuelHelper.java`:
- Around line 30-32: ServiceLoader.load(FuelHelper.class) in the
FuelHelper.INSTANCE initialization can throw IllegalStateException when no
provider is registered; add a service provider descriptor named
META-INF/services/com.logistics.core.lib.power.FuelHelper to your resources
containing the fully qualified class name of your FuelHelper implementation
(e.g., com.logistics.core.lib.power.DefaultFuelHelper), ensure that
implementation class is on the classpath, and verify the descriptor has the
exact FQN with no extra whitespace so ServiceLoader.findFirst() can discover the
provider for FuelHelper used by the INSTANCE field.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1fa1ed0b-dff6-479e-85f9-a1c04265a6a6

📥 Commits

Reviewing files that changed from the base of the PR and between b8ec653 and 4a35b62.

📒 Files selected for processing (5)
  • common/src/main/java/com/logistics/core/lib/power/FuelHelper.java
  • common/src/main/java/com/logistics/power/engine/block/entity/StirlingEngineBlockEntity.java
  • common/src/main/java/com/logistics/power/engine/ui/StirlingEngineScreenHandler.java
  • fabric/src/main/java/com/logistics/fabric/FabricFuelHelper.java
  • neoforge/src/main/java/com/logistics/neoforge/NeoForgeFuelHelper.java

Comment thread common/src/main/java/com/logistics/core/lib/power/FuelHelper.java
@Indemnity83 Indemnity83 merged commit 5e74e4d into mc/26.1 May 9, 2026
6 checks passed
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.

1 participant