Skip to content

feat(map): add in-game territory map backed by Wynncraft API - #66

Merged
burgerfan41 merged 11 commits into
EdenGuild:masterfrom
Good627:feat/territory-map
Dec 2, 2026
Merged

burgerfan41 merged 11 commits into
EdenGuild:masterfrom
Good627:feat/territory-map

Conversation

@Good627

@Good627 Good627 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an in-game interactive Territory Map screen (TerritoryMapScreen) modeled after EdenWeb's territory map, fetching data directly from the Wynncraft API with zero EdenBot WebSocket changes (mod_version remains 1.6.6).

War Queuer and Going-To map integration is split into stacked follow-up PR #67 so this PR stays focused on the base territory map.

Data Sources & Client-Side Tower Estimation

  • Primary source (TerritoryMapService): Fetches https://api.wynncraft.com/v3/guild/list/territory directly using TlsPolicy.newHttpClientBuilder() with a 15s TTL cache, single-flight coalescing, 4 MiB response cap, HTTP 429 Retry-After / error backoff, 10-minute post-close warm background polling + single pre-warm on Wynncraft join, and stale snapshot fallback.
  • Guild color enrichment: Fetches https://athena.wynntils.com/cache/get/territoryList in parallel (5m TTL, independent failure backoff) for registered guild colors, falling back to TerritoryMapData.hashedRgb when unavailable.
  • Season SR leaderboard (TerritoryMapService): Fetches https://api.wynncraft.com/v3/guild/seasons + /v3/leaderboards/guildSeason<N>?resultLimit=25 on a 5-minute TTL (with 60s error backoff and last-good fallback).
  • Client-side tower estimation (TerritoryTowerEstimator): Ports EdenWeb/lib/wynn/tower.ts using a rolling 8-snapshot buffer to solve global resource-tick phase and estimate tower levels & economy bonuses (TOWER STATS (<active routes>)).
  • 2-tier LOD terrain map (TerritoryMapTexture + TerritoryMapTiles):
    • Tier 0: Bundled wynncraft_map_overview.jpg (1152×1661, 446 KB, replacing the 2.0 MB WebP) pre-decoded off-thread on Wynncraft JOIN (prewarmOverview()) and always rendered underneath so fresh opens never show a black terrain flash (~7.6 MB VRAM at Fit).
    • Tier 1: Lazy 1:1 block overworld PNG tiles (Main * and Realm of Light, parsed/validated from Reference/maps.json) streamed only when zoomed in (camScale >= 0.45f) for tiles intersecting the viewport.
    • Wynntils cache reuse: Checks <gameDir>/wynntils/cache/dataStaticMaps and <gameDir>/wynntils/cache/maps/<md5>.png read-only with MD5 verification before falling back to <gameDir>/config/edenmod/cache/maps/ and CDN (cdn.wynntils.com/static/) -> GitHub mirror (raw.githubusercontent.com/Wynntils/Static-Storage).
    • Bounded MAX_GPU_TILES = 8 LRU cache while open; both Tier-0 and Tier-1 textures release cleanly on disconnect and after 10 minutes idle (releaseNow()).
  • Location bounds validation (TerritoryMapData): Drops malformed territories outside [-100_000, 100_000] before spatial grid insertion.

Features & Gating

  • Open to both Travelers and Guild members:
    • Keybind J (key.edenmod.open_territory_map, tap-to-toggle), /eden map, and "Territory Map" button in EdenMenuScreen.
    • Framed map viewport with subtle borders (MAP_MARGIN = 14, FRAME_THICKNESS = 4) leaving surrounding gameplay visible (isPauseScreen() == false, transparent background), plus Wynntils-style WASD movement pass-through while unfocused.
    • Opens zoomed in on the player (DEFAULT_PLAYER_ZOOM = 0.75f) when no camera is saved yet and player is inside map bounds, then restores the player's last saved pan/zoom across reopens — including after visiting out-of-bounds areas (e.g. raids/housing/lobby) and returning (saveCameraOnClose prevents out-of-bounds fallback fitAll from overwriting the saved camera, and centerOnPlayer() ignores out-of-bounds clicks; only account changes clear saved camera).
    • Shrinking guild tags (TAG_SCALES: 1.0 -> 0.85 -> 0.7 -> 0.55) on tight territories before dropping the label.
    • Hover card and Inspect panel both show EdenWeb-style STORAGE / PER HOUR resource progress bars with compact formatting (400k, 16.8k) and +gen / —.
    • Collapsible bottom-left Leaderboard & Season SR widget (starts compact at 20px high; expands upward on click with Territories and Season <N> SR tabs, rank, color swatch, value, green +lead/tied, season countdown, and click-to-spotlight).
    • Search & guild spotlight, resource producer filters (Emeralds, Ore, Wood, Fish, Crops + 2x badges), Wynntils-style cycling tier filters (Def & Tres, Left/Right/Shift/Ctrl/Middle, cycling cleanly to OFF), +/- zoom shortcuts, 16x16 player skin head cursor, cooldown perimeter drains, Shift + Right-Click -> /gu territory <name>, and Middle-Click / Compass button -> /compass <worldX> <worldZ> with an orb pickup ping sound.
  • Role gating:
    • Eden's own tower estimates are hidden in the Inspect panel unless mod.isFullMember().
    • Active AttackTimerMenu WarBoard attack borders & countdowns are shown only to full members.

Verification

  • .\gradlew.bat build --console=plain: BUILD SUCCESSFUL (spotlessApply, compileJava, compileGametestJava, spotlessCheck, check, remapJar, test, build).
  • Unit tests (build/test-results/test/*.xml): 83 suites, 546 tests, 0 failures, 0 errors, 4 skipped (unrelated upstream tests), including TerritoryMapDataTest (9 passed) and TerritoryTowerEstimatorTest (2 passed).
  • git diff --name-only upstream/master -- gradle.properties src/tel/eden/mod/net/ test/tel/eden/mod/net/ is empty.
  • Not verified live in-game: Minecraft launch / visual rendering, Wynntils cache hit vs GitHub fallback download, WASD movement feel, and live Wynncraft/Athena HTTP round-trips in client runtime.

@burgerfan41
burgerfan41 merged commit 2adc3bb into EdenGuild:master Dec 2, 2026
3 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.

2 participants