CC: Tweaked

CC: Tweaked

57M Downloads

Data fixers for the post-1.20.1 world(s)

SquidDev opened this issue ยท 3 comments

commented

Every version, the way Minecraft stores game data (such as blocks and items) changes slightly. For instance, post 1.20.1 (the current version CC:T targets):

  • Minecraft 1.20.2, changes how potions store their effects.
  • Minecraft 1.20.5, removes item NBT entirely, migrating it to a more structured component-based system.

Minecraft handles this migration by using the DFU library. However, CC: Tweaked (like most mods), does not hook into it - DFU doesn't really have good support for mods (Mojang/DataFixerUpper#80), and (AFAIK) mod loaders have deemed adding support too complex to be worth it.

This is a problem for CC: Tweaked, as it means that worlds cannot be migrated between versions (or at least, not without some data loss).

It's not entirely clear what should be done here. At a bare-minimum, we should mixin to Minecraft's existing data-fixers, and register CC:T's block entities as inventories - this at least ensures items inside turtles (and disk drives and printers) will be migrated.

I'm less sure what to do about 1.20.5's components. I've not actually looked at how data-fixers for that are implemented - it may be quite simple to hook into as well, but failing that we can probably convert NBT on-the-fly, reading out of the custom_nbt component and adding our custom one instead.

Turtle/pocket computer upgrades are a bit tricky here. Upgrade data may store item NBT which we'd want to migrate, but because it's currently unstructured, we can't automatically do so. Ideally we'd be able to expose data fixers for upgrade data too, but I don't think that's really possible :(. Maybe time to revisit #903?

commented

Minecraft 1.20.5, removes item NBT entirely, migrating it to a more structured component-based system.

No-no-no-no-no-no-no-no-no-no-no-no-no-no-no-no-no

commented

It's honestly a really cool system - I'm assuming block entities will be migrating to something similar at some point. But yes, also a nightmare for every mod.

commented

Okay, looked at a 1.20.5 workspace, and this actually looks fairly manageable. I think we can do the following:

1.20.4

Mixin to V1460 on 1.20.4 to register all of CC:T's inventories in DFU.

1.20.5

  • Replace turtle/pocket computer upgrade data with a bundle of components (so same as item stacks have). This makes future integration with DFU easier, and saves us having to implement our own data type.
  • Mixin to the 1.20.5 schema to register left/right upgrade components, and the 1.20.5 datafixer to migrate everything.