Migrating Scripts to CraftTweaker 7.1
CraftTweaker version 7.1 has some changes that break backwards compatibility.
These breaking changes are in the API that addons use as well as in the types that scripts use.
This document should give an overview of the most important changes and how pack developers can get their scripts working again.
MCTag becomes MCTag<T>
We replaced Tags with a generic system that is more extensible and will work better with future updates.
That change will break existing scripts in two ways:
- The specialized addition and removal methods have been removed.
You now useadd
andremove
instead ofaddItems
,addFluids
and the like. - The syntax of the Bracket handlers now requires the tag type as an additional parameter.
So<tag:forge:gems>
becomes<tag:items:forge:gems>
The /ct dump tags
and /ct hand
commands have been updated to reflect this change.
If you need to use any of IIngredient’s expansion methods from an item tag, you need to call .asIIngredient()
first.
Migration example
Wrapper types become vanilla types
We changed some internals workings of CraftTweaker to directly use minecraft types.
This change should not affect your existing scripts directly, but will break some of the integrations added by other mods.
The broken classes will be logged in the crafttweaker log. If you find some of your scripts breaking, check if they use one of the broken classes.
Method to register EventHandlers changed signature
Event listeners no longer have the consumer in a custom constructor.
Instead, the registitration method was changed to be generic.
Migration example:
ZenCode: Storage tags are gone
We removed Storage tags from the ZenCode language Specifications for now.
They are not required for CraftTweaker and made debugging harder.
Most people did not need to use storage tags so we don’t expect you to need to pursue this migration step.
Migration example: