Skip to content

Fix road generation success when no RoadData is produced - #91

Open
ErikSteiner wants to merge 1 commit into
shiroha-233:1.20.1-Architecturyfrom
ErikSteiner:fix/generation-status-contract
Open

ErikSteiner wants to merge 1 commit into
shiroha-233:1.20.1-Architecturyfrom
ErikSteiner:fix/generation-status-contract

Conversation

@ErikSteiner

Copy link
Copy Markdown

Summary

Fixes a generation-status inconsistency in RoadGenerationService.generateTask().

Road.generateRoad() can legitimately return null, but generateTask() previously discarded that return value and reported success as long as no exception was thrown. safeGenerate() could therefore mark a StructureConnection as COMPLETED even though no RoadData had been produced.

Changes

  • Treat Road.generateRoad() == null as an unsuccessful generation attempt.
  • Add a regression test that deterministically exercises the real null path.
  • Add JUnit Jupiter and Mockito as test-only dependencies for the common module.

The production change is intentionally minimal:

return new Road(level, conn, cfg, genCfg)
        .generateRoad(modCfg.pathfindingCost().aStarMaxSteps()) != null;

Existing exception handling and the existing behavior when roads are globally disabled are unchanged.

Testing

  • Regression test demonstrated the previous bug first (expected false but was true).
  • Updated regression test passes and explicitly verifies that the test setup makes Road.generateRoad() return null.
  • :common:test --rerun-tasks: BUILD SUCCESSFUL (1/1 tests).
  • git diff --check: clean.
  • Built the Fabric mod from this branch and loaded it successfully in Minecraft 1.20.1.
  • A fresh world could be created without an observed regression.
  • The specific generateRoad() == null condition was not observed during the manual smoke test.

Scope

This PR only addresses the incorrect success contract around Road.generateRoad().

It does not change:

  • the separate case where RoadData is persisted and a later precomputation step fails

Development tracking:
ErikSteiner#1

@ErikSteiner
ErikSteiner force-pushed the fix/generation-status-contract branch from fbcfdef to 736eddd Compare August 26, 2026 09:40
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