Package me.desht.pneumaticcraft.api.item
Class PNCUpgrade
java.lang.Object
me.desht.pneumaticcraft.api.item.PNCUpgrade
Represents an upgrade which can be inserted into a PNC machine or item. Upgrades are Forge registry objects, and
should be registered in the usual way, using either
RegisterEvent or (preferably)
DeferredRegister.
Upgrades can have multiple tiers; each upgrade must have one corresponding item registered per upgrade tier.
Such items must implement IUpgradeItem.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor; register an upgrade with just one tier.PNCUpgrade(int maxTier, String... depModIds) Register an upgrade with just one tier. -
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.final net.minecraft.world.item.ItemgetItem()Get the corresponding item for this upgrade, assuming tier 1final net.minecraft.world.item.ItemgetItem(int tier) Get the corresponding item for this upgrade and tier.final net.minecraft.world.item.ItemStackGet an itemstack for the given upgradefinal net.minecraft.world.item.ItemStackgetItemStack(int count) Get an itemstack for the given upgradefinal intGet the max upgrade tier allowable for this upgrade.final booleanCheck if this upgrade's dependent mods are loaded.
-
Constructor Details
-
PNCUpgrade
public PNCUpgrade()Default constructor; register an upgrade with just one tier. -
PNCUpgrade
Register an upgrade with just one tier.- Parameters:
maxTier- maximum tier for this upgradedepModIds- zero or more mod IDs, at least one of which must be present for this upgrade to be relevant
-
-
Method Details
-
getCacheId
public 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
public final int getMaxTier()Get the max upgrade tier allowable for this upgrade.- Returns:
- the max tier
-
isDependencyLoaded
public final 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
-
getItem
public final net.minecraft.world.item.Item getItem(int tier) Get the corresponding item for this upgrade and tier.- Parameters:
tier- the upgrade tier- Returns:
- a Minecraft item, or air if no corresponding item can be found
- Throws:
NullPointerException- if called before the upgrade is registered
-
getItem
public final net.minecraft.world.item.Item getItem()Get the corresponding item for this upgrade, assuming tier 1- Returns:
- a Minecraft item
- Throws:
NullPointerException- if called before the upgrade is registered
-
getItemStack
public final 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
public final 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
-