Class ItemDataFix
java.lang.Object
com.saicone.rtag.item.ItemDataFix
- Direct Known Subclasses:
ItemDataFix.MojangDataFix, ItemDataFix.RtagDataFix, ItemDataFix.SafeDataFix
This class provides a way to decode and encode items from/to NBT compounds, as well as update them between different Minecraft versions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMojang implementation of the item data fix, using the DataFixerUpper system to update items between different Minecraft versions.static classRtag implementation of the item data fix, using the Rtag system to update items between different Minecraft versions.static classA safe item data fix implementation, made specifically to fix invalid items across serialization formats. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecodeContainer(@Nullable Object compound) Decodes an array of items from a NBT compound, updating them to the current Minecraft version if necessary.decodeItem(@NotNull Object compound, @NotNull MC version) Decodes an item from a NBT compound, updating it to the current Minecraft version if necessary.decodeItem(@Nullable Object compound) Decodes an item from a NBT compound, updating it to the current Minecraft version if necessary.encodeContainer(@Nullable ItemStack[] items) Encodes an array of items into a NBT compound.encodeContainer(@Nullable ItemStack[] items, @NotNull MC version) Encodes an array of items into a NBT compound, adding the data version of the specified Minecraft version.encodeItem(@Nullable ItemStack item) Encodes an item into a NBT compound.encodeItem(@Nullable ItemStack item, @NotNull MC version) Encodes an item into a NBT compound, adding the data version of the specified Minecraft version.static @NotNull ItemDataFixmojang()Returns the Mojang implementation of the item data fix,static @NotNull ItemDataFixrtag()Returns the Rtag implementation of the item data fix,static @NotNull ItemDataFixsafe()Returns the safe implementation of the item data fix,Updates an item NBT compound from one Minecraft version to another.
-
Constructor Details
-
ItemDataFix
public ItemDataFix()
-
-
Method Details
-
mojang
Returns the Mojang implementation of the item data fix,- Returns:
- an item data fix
-
rtag
Returns the Rtag implementation of the item data fix,- Returns:
- an item data fix
-
safe
Returns the safe implementation of the item data fix,- Returns:
- an item data fix
-
decodeItem
-
decodeItem
@NotNull public @NotNull ItemStack decodeItem(@NotNull @NotNull Object compound, @NotNull @NotNull MC version) Decodes an item from a NBT compound, updating it to the current Minecraft version if necessary.- Parameters:
compound- the NBT compound representing the itemversion- the Minecraft version of the item- Returns:
- the decoded ItemStack
-
decodeContainer
Decodes an array of items from a NBT compound, updating them to the current Minecraft version if necessary.- Parameters:
compound- the NBT compound representing the container- Returns:
- an array of decoded ItemStacks
-
encodeItem
-
encodeItem
@NotNull public @NotNull Object encodeItem(@Nullable @Nullable ItemStack item, @NotNull @NotNull MC version) Encodes an item into a NBT compound, adding the data version of the specified Minecraft version.- Parameters:
item- the item to encodeversion- the Minecraft version to use for the data version- Returns:
- an encoded NBT compound
-
encodeContainer
-
encodeContainer
@NotNull public @NotNull Object encodeContainer(@Nullable @Nullable ItemStack[] items, @NotNull @NotNull MC version) Encodes an array of items into a NBT compound, adding the data version of the specified Minecraft version.- Parameters:
items- the array of items to encodeversion- the Minecraft version to use for the data version- Returns:
- an encoded NBT compound
-
updateItem
@NotNull public abstract @NotNull Object updateItem(@NotNull @NotNull Object compound, @NotNull @NotNull MC version, @NotNull @NotNull MC newVersion) Updates an item NBT compound from one Minecraft version to another.- Parameters:
compound- the NBT compound representing the itemversion- the current Minecraft version of the itemnewVersion- the target Minecraft version to update the item to- Returns:
- the updated NBT compound
-