Skip to content

fix: rivers inside a lure's province no longer count as leaving it - #19

Merged
XxFran10xX merged 2 commits into
mainfrom
fix/lure-river-reach
Oct 28, 2026
Merged

XxFran10xX merged 2 commits into
mainfrom
fix/lure-river-reach

Conversation

@XxFran10xX

@XxFran10xX XxFran10xX commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A player reported that during a lure, crossing a river inside the lure's province hurts as if they had left it. Lure mobs spawn on the far bank, players can't reach them without taking damage, and the lure fails.

SimpleFactions stores every river and lake as its own WATER province, so a block of river has the river's province ID, not the ID of the land around it. On Main, province 429 (bog, swamp_mobs) is cut into two pieces (about 18.5k and 7.6k blocks) by river 779. Infested provinces 465, 471, 480, 483 and 489 have small cut-off pieces too, and 30 land provinces are split across the whole map.

Change

  • New Provinces.within(player, provinceId): true on the province's own land, or in a WATER province (river or lake) while that province's land is within river-reach blocks. SEA still counts as outside.
  • New config.yml key river-reach (default 16, capped at 64 so a typo can't stall the tick; 0 = old behaviour). Rivers that split provinces on Main are at most 14 blocks wide (half-width 7 or less), so 16 covers them. A long river can't be used to walk away from the province.
  • Committed players use within: deserter damage (tickOutsideCommitted), the leave-province chat warning, and the fail and victory messages (plus the /lure leave fail message that has to match them).
  • Bystander checks stay strict (join-window bar, non-joiner damage, lure-placed notice). Otherwise a passer-by boating down a river on the province's border would take damage along its whole length.
  • Lure and ambient spawning are unchanged. Mobs on the far bank are now reachable.

Existing servers have no river-reach key, so they use the default 16 without a config edit.

Tests

  • mvn clean verify: 184 tests pass, 100% line coverage. New tests cover Provinces.within (on the land, null player, land province, WATER with no grid, land outside the circle, reach 0 and 1, SEA), the manager (committed wader safe; far river hurts; bystander in the river not hurt; no leave warning in the river) and the config default and both clamps.
  • Dev (TFMCDev01), bot TestChar1 as a real character: placed a lure in 429, then stood at six points in survival for 7 s each.
Point river-reach 16 river-reach 0 (control = old behaviour)
429 land safe safe
River 779 through 429 safe hurt (outside bar + chat, 7 hits)
429 far bank safe safe
River 779, 31 blocks from 429 hurt hurt
Province 430 land hurt hurt
River 779 through 429 again safe hurt

/lure leave then failed the lure as before. No Infestations errors in Dev's log.

🤖 Generated with Claude Code

Rivers and lakes are SimpleFactions provinces of their own, so a committed
player wading across a river that cuts through the lure's province took
deserter damage, and lure mobs spawned on the far bank could not be reached.
A committed player in a WATER province now counts as inside while the lure
province's land is within river-reach blocks (default 16). Bystander checks
stay strict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5824de6e-e78b-4d10-91ca-eaecc8484405
Commits

Reviewing files that changed from the base of the PR and between 64c1091 and 8b1734b.

Files selected for processing: 9
  • README.md
  • src/main/java/net/tfminecraft/infestations/cache/Cache.java
  • src/main/java/net/tfminecraft/infestations/infestation/InfestationManager.java
  • src/main/java/net/tfminecraft/infestations/loader/ConfigLoader.java
  • src/main/java/net/tfminecraft/infestations/utils/Provinces.java
  • src/main/resources/config.yml
  • src/test/java/net/tfminecraft/infestations/InfestationsServicesTest.java
  • src/test/java/net/tfminecraft/infestations/infestation/InfestationManagerTest.java
  • src/test/java/net/tfminecraft/infestations/loader/LoadersTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features

    • Players in rivers or lakes can count as being inside a province when its land is within the configured reach. The default reach is 16 blocks and can be set from 0 to 64 blocks.
    • Lure participation checks now account for this nearby water, reducing incorrect warnings or missed messages for players near a province’s land.
  • Documentation

    • Clarified that rivers and lakes adjoining a province’s land count as inside the province.

The change adds a configurable reach for treating players in rivers or lakes as within nearby land provinces. Lure participation and messaging checks now use this province-membership rule.

Changes: River province membership

Layer / File(s) Summary
Configure and calculate river reach
src/main/java/net/tfminecraft/infestations/cache/Cache.java, src/main/java/net/tfminecraft/infestations/loader/ConfigLoader.java, src/main/java/net/tfminecraft/infestations/utils/Provinces.java, src/main/resources/config.yml, src/test/java/net/tfminecraft/infestations/InfestationsServicesTest.java, src/test/java/net/tfminecraft/infestations/loader/LoadersTest.java, README.md
Adds the river-reach setting, defaults it to 16, and clamps configured values to 0–64. Provinces.within checks the player’s province and, for water provinces, nearby land within the configured reach. Tests cover reach limits, terrain, and unavailable grid context. The README describes the river and lake rule.
Apply reach to lure checks
src/main/java/net/tfminecraft/infestations/infestation/InfestationManager.java, src/test/java/net/tfminecraft/infestations/infestation/InfestationManagerTest.java
Lure participation, departure, failure, victory, and province-leave checks use Provinces.within. Tests cover committed players on a matching river bank, players in another province, and an uncommitted bystander.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Player
  participant InfestationManager
  participant Provinces
  participant ProvinceGrid
  InfestationManager->>Provinces: Check within(player, provinceId)
  Provinces->>ProvinceGrid: Check province and nearby land within riverReach
  ProvinceGrid-->>Provinces: Return province lookup results
  Provinces-->>InfestationManager: Return inside or outside
  InfestationManager->>Player: Send lure message or warning based on result
Loading

Suggested reviewers: ryanbarlow97

Merge Risk: Minimal · up to 8b173

The river-reach change is mergeable after normal checks.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added the size:M 30-99 effective changed lines (tests excluded in mixed PRs). label Oct 28, 2026
The river check scans a circle of river-reach blocks, so its cost grows with
the square of the setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XxFran10xX
XxFran10xX marked this pull request as ready for review October 28, 2026 09:24
@XxFran10xX

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@XxFran10xX
XxFran10xX merged commit 9ea2e67 into main Oct 28, 2026
4 checks passed
@XxFran10xX
XxFran10xX deleted the fix/lure-river-reach branch October 28, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant