Package dan200.computercraft.api.pocket
Interface PocketUpgradeSerialiser<T extends IPocketUpgrade>
- Type Parameters:
T
- The type of pocket computer upgrade this is responsible for serialising.
- All Superinterfaces:
UpgradeSerialiser<T>
Reads a
IPocketUpgrade
from disk and reads/writes it to a network packet.
This follows the same format as TurtleUpgradeSerialiser
- consult the
documentation there for more information.
- See Also:
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<PocketUpgradeSerialiser<?>>>
The ID for the associated registry.static <T extends IPocketUpgrade>
PocketUpgradeSerialiser<T>Create an upgrade serialiser for a simple upgrade.static <T extends IPocketUpgrade>
PocketUpgradeSerialiser<T>simpleWithCustomItem
(BiFunction<net.minecraft.resources.ResourceLocation, net.minecraft.world.item.ItemStack, T> factory) Create an upgrade serialiser for a simple upgrade whose crafting item can be specified.Methods inherited from interface dan200.computercraft.api.upgrades.UpgradeSerialiser
fromJson, fromNetwork, toNetwork
-
Method Details
-
registryId
static net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<PocketUpgradeSerialiser<?>>> registryId()The ID for the associated registry.- Returns:
- The registry key.
-
simple
static <T extends IPocketUpgrade> PocketUpgradeSerialiser<T> simple(Function<net.minecraft.resources.ResourceLocation, T> factory) Create an upgrade serialiser for a simple upgrade. This is similar to aSimpleCraftingRecipeSerializer
, but for upgrades.If you might want to vary the item, it's suggested you use
simpleWithCustomItem(BiFunction)
instead.- Type Parameters:
T
- The type of the generated upgrade.- Parameters:
factory
- Generate a new upgrade with a specific ID.- Returns:
- The serialiser for this upgrade
-
simpleWithCustomItem
static <T extends IPocketUpgrade> PocketUpgradeSerialiser<T> simpleWithCustomItem(BiFunction<net.minecraft.resources.ResourceLocation, net.minecraft.world.item.ItemStack, T> factory) Create an upgrade serialiser 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:
- The serialiser for this upgrade.
- See Also:
-