Skip to content

Cache converted resource packs by effective stack and ZIP hash - #420

Closed
AlexProgrammerDE wants to merge 3 commits into
ViaVersionAddons:mainfrom
AlexProgrammerDE:codex/resource-pack-cache
Closed

AlexProgrammerDE wants to merge 3 commits into
ViaVersionAddons:mainfrom
AlexProgrammerDE:codex/resource-pack-cache

Conversation

@AlexProgrammerDE

Copy link
Copy Markdown
Collaborator

Description

Fixes #416. Supersedes #417.

Bedrock announces pack identities in RESOURCE_PACKS_INFO, then sends the effective pack order in RESOURCE_PACK_STACK. The Java pack is now pushed only after the stack arrives and the Bedrock sources have loaded. Conversion uses that stack order, so pack overrides match the server's choice.

The HTTP server prepares the converted ZIP before the Java push. The push advertises the SHA-1 of the exact ZIP it serves and a stable UUID derived from that SHA-1. A new URL token still restricts each connection's download, while an unchanged ZIP keeps the same hash and UUID for the Java client's cache.

Source pack caches use the advertised content ID and decryption key in addition to pack UUID and version. If Bedrock provides no content ID, the source is downloaded again rather than trusted by UUID and version alone. The converted cache keys on the ordered source bytes and ViaBedrock build version. Disk entries are checked against their SHA-1 before reuse; pack-cache disabled, memory, and disk modes apply to converted packs as well.

ZIP entries are written in a stable path order. Stack-only packs cannot replace sources already loaded from the Info packet.

Testing

  • ./gradlew build
  • Regression tests cover pack order, changed source bytes, source content identity, and stable ZIP bytes, SHA-1, and UUID.

Live Bedrock server and Java client behavior still needs verification. A Bedrock server that changes pack bytes while reusing a nonempty content ID can still make its own source cache stale, because the advertised metadata gives no way to detect that change without downloading it.

Wait for the Bedrock pack stack before pushing a Java pack so server order controls asset overrides. Prepare and hash the exact converted ZIP before advertising it, allowing Java clients to reuse their cached copy.

Key source caches by advertised content identity and decryption key, and converted caches by ordered source bytes and converter version. Honor disabled, memory, and disk cache modes; add regression tests for order, content changes, and stable ZIP output.
Merge the current main branch, including EditorConfig and Checkstyle rules. Preserve delayed pack conversion and cache identity behavior while updating the affected Java code to pass the new build checks.
Bring in the latest chunk completion and request scheduling changes while retaining the resource pack cache behavior. The merged code passes the full Gradle build.
AlexProgrammerDE added a commit to StackAnvil/ViaBedrock that referenced this pull request Sep 26, 2026
Converting a resource-pack stack on every join repeats expensive ZIP work and can advertise stale output when the pack content changes. Cache conversions by the effective pack stack and content hash, and verify cached ZIPs before reuse.

Write converted packs and their index atomically, give identical content a stable advertised hash and ID, and make ZIP entry order deterministic. Encode ResourcePackClientResponse with the current varint pack-list count; the old 16-bit count breaks game-protocol downloads. Add focused cache, load-state, and packet-layout tests. Based on ViaBedrock PR ViaVersionAddons#420.
AlexProgrammerDE added a commit to StackAnvil/ViaBedrock that referenced this pull request Sep 26, 2026
Converting a resource-pack stack on every join repeats expensive ZIP work and can advertise stale output when the pack content changes. Cache conversions by the effective pack stack and content hash, and verify cached ZIPs before reuse.

Write converted packs and their index atomically, give identical content a stable advertised hash and ID, and make ZIP entry order deterministic. Encode ResourcePackClientResponse with the current varint pack-list count; the old 16-bit count breaks game-protocol downloads. Add focused cache, load-state, and packet-layout tests. Based on ViaBedrock PR ViaVersionAddons#420.
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.

Java clients re-download and re-apply the translated resource pack on every join (random pack UUID)

1 participant