Updating items

From Matcha Flavoured Wiki
Jump to navigation Jump to search

Updating items refers to the tools Matcha Flavoured provides for bringing items from older versions of the pack up to date, chiefly the /trigger update_item command added in 1.12.2.

Background

Datapacks cannot add items, so every custom item is a vanilla item with extra data components (name, model, lore, enchantments, attributes). An item keeps the components it was created with, so when a new version changes an item's stats, textures or name, old copies stay as they were and often no longer stack with new ones. In 1.12.2 almost all models and data moved from the minecraft and main namespaces to matcha, which made many old items appear broken.[1]

/trigger update_item

Hold the item in the main hand and run /trigger update_item. Any player can use it without cheats.[2] The function:[3]

  1. Reads the held item's translation key. If it has none, it reports "The held item cannot be updated because it is missing a translation key."
  2. Looks the key up in a table of 234 current item definitions, generated from the pack's crafting, smithing and food recipes and villager trades. Unknown items are reported as "cannot be updated".
  3. Builds the current version of the item, and carries over the stack size, custom name, armor trim and lodestone compass target. Durability damage is kept as a proportion of the new maximum.
  4. Merges the old item's enchantments onto the new one, so where both have an enchantment, the old item's level is kept. Vanilla Fortune is then capped at level I, the pack's maximum.
  5. Removes the held item and drops the new one at the player's feet with no pickup delay, then reports "The held item has been successfully updated."

The table is generated by the script generate_update_item_mcfunction.py in the repository.[4]

Automatic updates

  • The sacred texts (The Avesta, The Book of Enoch, The Divine Comedy, The Lesser Key of Solomon, Paradise Lost, The Quran and The Tanakh) and the "Golden" music disc are replaced automatically when picked up, outside Creative mode.[5]
  • Vanilla apples, sweet berries and turtle scutes, vanilla water bottles and unenchanted vanilla elytra are converted into the pack's versions.
  • When a player joins after an update, their recipe unlocks and most reward advancements are reset so new recipes can unlock. See Advancements#Revocation on update.

Other methods

  • /loot give @s loot matcha:... gives a fresh copy of many items, for example matcha:treasure/divine_comedy.
  • Loading the previous resource pack below the new one hides broken textures, although enchantments stay broken.
  • The weaponsmith (grindstone villager) melts alloyed equipment into its components, and an amnestic resets a villager's trades. Both were added in 1.10.

History

1.10 Added version tracking, recipe unlock resets, weaponsmith melting and the amnestic.
1.12.1-alpha Automatic replacement of moved books and the "Golden" disc.
1.12.2 Added /trigger update_item, by FloofShade. After release, it gained support for villager-trade items, armor trims and lodestone compasses, and stopped identifying items by ID.

References