Interface UpgradeBase
- All Known Subinterfaces:
IPocketUpgrade,ITurtleUpgrade
- All Known Implementing Classes:
AbstractPocketUpgrade,AbstractTurtleUpgrade
ITurtleUpgrade and IPocketUpgrade.-
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.ItemStackReturn an item stack representing the type of item that a computer must be crafted with to create a version which holds this upgrade.static StringgetDefaultAdjective(net.minecraft.resources.ResourceLocation id) Get a suitable default unlocalised adjective for an upgrade ID.Return an unlocalised string to describe this type of computer in item names.default net.minecraft.nbt.CompoundTaggetUpgradeData(net.minecraft.world.item.ItemStack stack) Extract upgrade data from anItemStack.net.minecraft.resources.ResourceLocationGets a unique identifier representing this type of turtle upgrade.default net.minecraft.world.item.ItemStackgetUpgradeItem(net.minecraft.nbt.CompoundTag upgradeData) Returns the item stack representing a currently equipped turtle upgrade.default booleanisItemSuitable(net.minecraft.world.item.ItemStack stack) Determine if an item is suitable for being used for this upgrade.
-
Method Details
-
getUpgradeID
net.minecraft.resources.ResourceLocation getUpgradeID()Gets a unique identifier representing this type of turtle upgrade. eg: "computercraft:wireless_modem" or "my_mod:my_upgrade".You should use a unique resource domain to ensure this upgrade is uniquely identified. The upgrade will fail registration if an already used ID is specified.
- Returns:
- The unique ID for this upgrade.
-
getUnlocalisedAdjective
String getUnlocalisedAdjective()Return an unlocalised string to describe this type of computer in item names.Examples of built-in adjectives are "Wireless", "Mining" and "Crafty".
- Returns:
- The localisation key for this upgrade's adjective.
-
getCraftingItem
net.minecraft.world.item.ItemStack getCraftingItem()Return an item stack representing the type of item that a computer must be crafted with to create a version which holds this upgrade. This item stack is also used to determine the upgrade given byturtle.equipLeft()orpocket.equipBack()This should be constant over a session (or at least a datapack reload). It is recommended that you cache the stack too, in order to prevent constructing it every time the method is called.
- Returns:
- The item stack to craft with, or
ItemStack.EMPTYif it cannot be crafted.
-
getUpgradeItem
default net.minecraft.world.item.ItemStack getUpgradeItem(net.minecraft.nbt.CompoundTag upgradeData) Returns the item stack representing a currently equipped turtle upgrade.While upgrades can store upgrade data (
ITurtleAccess.getUpgradeNBTData(TurtleSide)andIPocketAccess.getUpgradeNBTData()}, by default this data is discarded when an upgrade is unequipped, and the original item stack is returned.By overriding this method, you can create a new
ItemStackwhich contains enough data to re-create the upgrade data if the item is re-equipped.When overriding this, you should override
getUpgradeData(ItemStack)andisItemSuitable(ItemStack)at the same time,- Parameters:
upgradeData- The current upgrade data. This should NOT be mutated.- Returns:
- The item stack returned when unequipping.
-
getUpgradeData
default net.minecraft.nbt.CompoundTag getUpgradeData(net.minecraft.world.item.ItemStack stack) Extract upgrade data from anItemStack.This upgrade data will be available with
ITurtleAccess.getUpgradeNBTData(TurtleSide)orIPocketAccess.getUpgradeNBTData().This should be an inverse to
getUpgradeItem(CompoundTag).- Parameters:
stack- The stack that was equipped by the turtle or pocket computer. This will have the same item asgetCraftingItem().- Returns:
- The upgrade data that should be set on the turtle or pocket computer.
-
isItemSuitable
default boolean isItemSuitable(net.minecraft.world.item.ItemStack stack) Determine if an item is suitable for being used for this upgrade.When un-equipping an upgrade, we return
getCraftingItem()rather than the original stack. In order to prevent people losing items with enchantments (or repairing items with non-0 damage), we impose additional checks on the item.The default check requires that any non-capability NBT is exactly the same as the crafting item, but this may be relaxed for your upgrade.
This is based on
net.minecraftforge.common.crafting.StrictNBTIngredient's check.- Parameters:
stack- The stack to check. This is guaranteed to be non-empty and have the same item asgetCraftingItem().- Returns:
- If this stack may be used to equip this upgrade.
-
getDefaultAdjective
Get a suitable default unlocalised adjective for an upgrade ID. This converts "modid:some_upgrade" to "upgrade.modid.some_upgrade.adjective".- Parameters:
id- The upgrade ID.- Returns:
- The generated adjective.
- See Also:
-