Upgrading from CCA 5.x to 6.0  

Minecraft 1.20.5 has been quite the deal in terms of technical changes. With networking and item NBT being completely redone, Cardinal Components API had to adapt - prompting several breaking changes.

This page details the main changes in the 6.0.0 update, and how to deal with them.

Note that the 6.0.0 update is not completely done yet, and therefore this page may be amended before the full release.

Package migration

This new major version has brought the opportunity to update the library’s maven group and package, from dev.onyxstudios to org.ladysnake. You can migrate imports quickly by using your IDE’s global search feature - here are the instructions for Intellij Idea:

  1. press Ctrl + Shift + R (or Cmd + Shift + R on MacOS) to open the global replace window
    • make sure the “Regex” option (the .* button to the right of the search field) is disabled
  2. type import dev.onyxstudios.cca in the first line (“Search”)
  3. type import org.ladysnake.cca in the second line (“Replace”)
  4. Click on Replace All to perform the replacement
  5. You’re done!

On the maven side of things, the old maven group is aliased to the new one, so your builds should keep working. However, to avoid future issues, you should still update the dependency information in your Gradle buildscript, substituting dev.onyxstudios.cardinal-components-api with org.ladysnake.cardinal-components-api.

Changes to the Base module

AutoSyncedComponent now reads from and writes to a RegistryByteBuf instead of a PacketByteBuf. This new type can be used in exactly the same way, while also allowing the use of more vanilla serialization methods (notably the new PacketCodecs).

You can use the same Search/Replace procedure as above to handle this migration, first replacing public void writeSyncPacket(PacketByteBuf with public void writeSyncPacket(RegistryByteBuf, then replacing public void applySyncPacket(PacketByteBuf with public void applySyncPacket(RegistryByteBuf.

Changes to the Item module

Item components have been entirely removed from Cardinal Components API.

With Minecraft 1.20.5 adding data components for item stacks, all the functionality of the cardinal-components-item module has been superseded by vanilla components and Fabric API’s API Lookup API.

You can find an example of a component interface reimplemented with the new APIs in CCA’s test mod. The basic idea is:

  1. move all your component’s fields to an immutable record
  2. create a Codec, a PacketCodec and a DataComponentType for that record
  3. register the DataComponentType to Registries.DATA_COMPONENT_TYPE
  4. reimplement your component interface by delegating reads and writes to the new data component, using ItemStack#get, ItemStack#set, and ItemStack#apply as required
  5. register an ItemApiLookup<T, Void> for your component interface
  6. replace uses of COMPONENT_KEY.get(stack) with API_LOOKUP.get(stack, null)

Changes to the Entity module

  • The PlayerCopyCallback has been removed. If you were using it, you can switch to ServerPlayerEvents.COPY_FROM from Fabric API.
  • RespawnCopyStrategy is now called for mobs other when players when they get converted (think smitten pigs turning to piglins, or zombies drowning)

CCA Dev Wiki