Skip to content

Introduce codec module for data serialization and deserialization#15

Merged
Gu-ZT merged 14 commits intoAnvil-Dev:dev/1.21.1from
Gu-ZT:dev/codec
Apr 10, 2026
Merged

Introduce codec module for data serialization and deserialization#15
Gu-ZT merged 14 commits intoAnvil-Dev:dev/1.21.1from
Gu-ZT:dev/codec

Conversation

@Gu-ZT
Copy link
Copy Markdown
Contributor

@Gu-ZT Gu-ZT commented Apr 10, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new codec module to centralize common Codec / StreamCodec helpers, and migrates recipe-related serialization code to depend on that shared module.

Changes:

  • Added module.codec (new Gradle module + CI/release workflow jobs) providing CodecUtil and StreamCodecUtil.
  • Migrated module.recipe serialization utilities to use dev.anvilcraft.lib.v2.codec.* and removed the old module.recipe CodecUtil.
  • Updated documentation and Gradle wiring to include/publish the new codec artifact.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
settings.gradle Includes and names the new module.codec project.
README.md Documents the new Codec module and adds dependency examples.
README.en.md English documentation for the new Codec module and dependency examples.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/util/CodecUtil.java Removes recipe-local codec utilities (moved to new module).
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/predicate/item/HasItemBase.java Switches network codecs to StreamCodecUtil.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/predicate/block/HasBlockBase.java Switches Vec3 stream codec to StreamCodecUtil.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/outcome/SpawnItem.java Switches number-provider/Vec3 codecs to codec module utilities.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/outcome/SetBlock.java Switches blockstate/number-provider/Vec3 codecs to codec module utilities.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/outcome/ProduceExplosion.java Switches codec-to-stream bridging to StreamCodecUtil.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/outcome/ChooseOneOutcome.java Switches codec-to-stream bridging to StreamCodecUtil.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/data/advancement/predicate/item/OrPredicate.java Uses dev.anvilcraft.lib.v2.codec.CodecUtil.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/data/advancement/predicate/item/NotPredicate.java Uses dev.anvilcraft.lib.v2.codec.CodecUtil.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/data/advancement/predicate/item/AndPredicate.java Uses dev.anvilcraft.lib.v2.codec.CodecUtil.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/component/ItemPredicate.java Switches codec-to-stream bridging to StreamCodecUtil.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/component/ItemIngredientPredicate.java Switches codec-to-stream bridging to StreamCodecUtil.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/component/ChanceItemStack.java Switches number-provider codecs to codec module utilities.
module.recipe/src/main/java/dev/anvilcraft/lib/v2/recipe/component/ChanceBlockState.java Switches blockstate/number-provider codecs to codec module utilities.
module.recipe/build.gradle Adds codec dependency (jarJar) for recipe module builds.
module.main/build.gradle Adds codec dependency (jarJar) for aggregate/main module builds.
module.codec/src/main/resources/META-INF/neoforge.mods.toml Adds module metadata for NeoForge loading.
module.codec/src/main/resources/anvillib_codec.mixins.json Adds mixin config for the new module.
module.codec/src/main/java/dev/anvilcraft/lib/v2/codec/StreamCodecUtil.java New: shared stream codecs + high-arity composite(...) helpers.
module.codec/src/main/java/dev/anvilcraft/lib/v2/codec/CodecUtil.java New: shared Codec/MapCodec helpers moved from recipe.
module.codec/src/main/java/dev/anvilcraft/lib/v2/codec/package-info.java New: package-level nullability defaults.
module.codec/gradle.properties New: codec module properties (mod id/name/versions).
module.codec/build.gradle New: module build/publish configuration.
.github/workflows/release.yml Adds codec build + deploy jobs to release pipeline.
.github/workflows/pull_request.yml Adds codec job and updates recipe job ordering.
.github/workflows/ci.yml Adds codec job and updates recipe job ordering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread README.en.md Outdated
Comment thread .github/workflows/pull_request.yml Outdated
Comment thread .github/workflows/release.yml
Comment thread module.codec/src/main/java/dev/anvilcraft/lib/v2/codec/CodecUtil.java Outdated
Comment thread module.codec/src/main/resources/anvillib_codec.mixins.json Outdated
Comment thread module.codec/build.gradle Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

.github/workflows/pull_request.yml:117

  • PR workflow jobs call build_and_test.yml, which hard-codes NOT_DEV: true. That means module.recipe / module.main will resolve anvillib-codec via Maven (latest.release) instead of using the code from this PR, and on PR builds publish is skipped so the new codec artifact won’t be available. Consider adjusting the PR workflow/build script so PR builds use project dependencies (e.g., set NOT_DEV based on pr_build, or publish built modules to a local repository and resolve from there) to ensure recipe/main actually build against the in-PR codec changes.
  recipe:
    needs:
      - config
      - codec
    uses: ./.github/workflows/build_and_test.yml
    with:
      module: recipe
      module_id: anvillib-recipe
      mod_id: anvillib_recipe
      ci_build: true
      pr_build: true

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread module.codec/src/main/java/dev/anvilcraft/lib/v2/codec/StreamCodecUtil.java Outdated
Comment thread module.codec/src/main/java/dev/anvilcraft/lib/v2/codec/StreamCodecUtil.java Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread module.codec/src/main/java/dev/anvilcraft/lib/v2/codec/CodecUtil.java Outdated
Comment thread module.codec/src/main/java/dev/anvilcraft/lib/v2/codec/CodecUtil.java Outdated
Comment thread module.codec/src/main/java/dev/anvilcraft/lib/v2/codec/StreamCodecUtil.java Outdated
Comment thread .github/workflows/pull_request.yml
Comment thread .github/workflows/build_and_test.yml
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/build_and_test.yml Outdated
@Gu-ZT Gu-ZT merged commit 3c02ffe into Anvil-Dev:dev/1.21.1 Apr 10, 2026
8 checks passed
QiuShui1012 pushed a commit to QiuShui1012/AnvilLib that referenced this pull request Apr 17, 2026
Introduce codec module for data serialization and deserialization
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