Interface PNCUpgrade
- All Known Implementing Classes:
PNCUpgradeImpl
public interface PNCUpgrade
Represents an upgrade which can be inserted into a PNC machine or item. Upgrades are not Forge registry objects, but
have a 1:1 relationship to items; a
PNCUpgrade object should only be created during item registration.
Upgrades can have multiple tiers; each upgrade must have one corresponding item registered per upgrade tier.
Such items must implement IUpgradeItem.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PNCUpgradefrom(net.minecraft.world.item.ItemStack stack) Convenience method to get an upgrade from its corresponding itemintA numeric id for the upgrade which is not guaranteed to be persistent across game restarts.net.minecraft.resources.ResourceLocationgetId()Get the upgrade's unique IDdefault net.minecraft.world.item.ItemgetItem()Get the corresponding item for this upgrade, assuming tier 1net.minecraft.world.item.ItemgetItem(int tier) Get the corresponding item for this upgrade and tier.default net.minecraft.resources.ResourceLocationGet the corresponding item registry name for this upgrade, assuming tier 1.net.minecraft.resources.ResourceLocationgetItemRegistryName(int tier) Get the corresponding item registry name for this upgrade and tier.default net.minecraft.world.item.ItemStackGet an itemstack for the given upgradenet.minecraft.world.item.ItemStackgetItemStack(int count) Get an itemstack for the given upgradeintGet the max upgrade tier allowable for this upgrade.booleanCheck if this upgrade's dependent mods are loaded.
-
Method Details
-
getId
net.minecraft.resources.ResourceLocation getId()Get the upgrade's unique ID- Returns:
- the upgrade ID
-
getCacheId
@Internal int getCacheId()A numeric id for the upgrade which is not guaranteed to be persistent across game restarts. Used internally for performance; do not depend on the value of this.- Returns:
- a numeric ID, for internal use
-
getMaxTier
int getMaxTier()Get the max upgrade tier allowable for this upgrade.- Returns:
- the max tier
-
isDependencyLoaded
boolean isDependencyLoaded()Check if this upgrade's dependent mods are loaded. Used to control whether the upgrade is added to the creative item list (and thus JEI), and whether any upgrade info is shown for it in GUI side tabs. Note that upgrades are always registered in Forge registries, even if dependent mods are missing.- Returns:
- true if this upgrade's dependencies are satisfied, false otherwise
-
getItemRegistryName
net.minecraft.resources.ResourceLocation getItemRegistryName(int tier) Get the corresponding item registry name for this upgrade and tier. The item ID is determined by appending "_upgrade" to the upgrade's ID, followed by "_{tier-number}" if this upgrade has more than one tier.- Parameters:
tier- the upgrade tier- Returns:
- an item registry name
- Throws:
IllegalArgumentException- if the tier is less than 1 or greater than the upgrade's max tier
-
getItemRegistryName
default net.minecraft.resources.ResourceLocation getItemRegistryName()Get the corresponding item registry name for this upgrade, assuming tier 1.- Returns:
- an item registry name
-
getItem
net.minecraft.world.item.Item getItem(int tier) Get the corresponding item for this upgrade and tier. The item ID is determined by appending "_upgrade" to th upgrade's ID, followed by "_{tier-number}" if this upgrade has more than one tier.- Parameters:
tier- the upgrade tier- Returns:
- a Minecraft item, or air if no corresponding item can be found
- Throws:
IllegalArgumentException- if the tier is less than 1 or greater than the upgrade's max tier
-
getItem
default net.minecraft.world.item.Item getItem()Get the corresponding item for this upgrade, assuming tier 1- Returns:
- a Minecraft item
-
getItemStack
default net.minecraft.world.item.ItemStack getItemStack()Get an itemstack for the given upgrade- Returns:
- an upgrade itemstack, with a single item
- Throws:
NullPointerException- if called before the upgrade is registered
-
getItemStack
net.minecraft.world.item.ItemStack getItemStack(int count) Get an itemstack for the given upgrade- Parameters:
count- number of items in the stack- Returns:
- an upgrade itemstack
- Throws:
NullPointerException- if called before the upgrade is registered
-
from
Convenience method to get an upgrade from its corresponding item- Parameters:
stack- the item- Returns:
- the upgrade, or null if the item isn't an upgrade
-