Interface UpgradeType<T extends UpgradeBase>
- Type Parameters:
T
- The upgrade subclass that this upgrade type represents.
Turtle and pocket computer upgrades are registered using Minecraft's dynamic registry system. As a result, they
follow a similar design to other dynamic content, such as recipes or loot functions
.
While the ITurtleUpgrade
/IPocketUpgrade
class should contain the core logic of the upgrade, they are
not registered directly. Instead, each upgrade class has a corresponding UpgradeType
, which is responsible
for loading the upgrade from a datapack. The upgrade type should then be registered in its appropriate registry
(ITurtleUpgrade.typeRegistry()
, IPocketUpgrade.typeRegistry()
).
In order to register the actual upgrade, a JSON file referencing your upgrade type should be added to a datapack. It is recommended to do this via the data generators.
Data Generation 
As turtle and pocket upgrades are just loaded using vanilla's dynamic loaders, one may use the same data generation
tools as you would for any other dynamic registry.
See the turtle upgrade docs for a concrete example.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec
<T> codec()
The codec to read and write this upgrade from a datapack.static <T extends UpgradeBase>
UpgradeType<T> create
(com.mojang.serialization.MapCodec<T> codec) Create a new upgrade type.static <T extends UpgradeBase>
UpgradeType<T> simple
(T instance) Create an upgrade type for an upgrade that takes no arguments.static <T extends UpgradeBase>
UpgradeType<T> simpleWithCustomItem
(Function<net.minecraft.world.item.ItemStack, T> factory) Create an upgrade type for a simple upgrade whose crafting item can be specified.
-
Method Details
-
codec
com.mojang.serialization.MapCodec<T> codec()The codec to read and write this upgrade from a datapack.- Returns:
- The codec for this upgrade.
-
create
Create a new upgrade type.- Type Parameters:
T
- The type of the generated upgrade.- Parameters:
codec
- The codec- Returns:
- The newly created upgrade type.
-
simple
Create an upgrade type for an upgrade that takes no arguments.If you might want to vary the item, it's suggested you use
simpleWithCustomItem(Function)
instead.- Type Parameters:
T
- The type of the generated upgrade.- Parameters:
instance
- Generate a new upgrade with a specific ID.- Returns:
- A new upgrade type.
-
simpleWithCustomItem
static <T extends UpgradeBase> UpgradeType<T> simpleWithCustomItem(Function<net.minecraft.world.item.ItemStack, T> factory) Create an upgrade type for a simple upgrade whose crafting item can be specified.- Type Parameters:
T
- The type of the generated upgrade.- Parameters:
factory
- Generate a new upgrade with a specific ID and crafting item. The returned upgrade'sUpgradeBase.getCraftingItem()
MUST equal the provided item.- Returns:
- A new upgrade type.
- See Also:
-