Class PNCUpgrade

java.lang.Object
me.desht.pneumaticcraft.api.item.PNCUpgrade

public class PNCUpgrade extends Object
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

    Constructors
    Constructor
    Description
    Default constructor; register an upgrade with just one tier.
    PNCUpgrade(int maxTier, String... depModIds)
    Register an upgrade with just one tier.
  • Method Summary

    Modifier and Type
    Method
    Description
    static PNCUpgrade
    from(net.minecraft.world.item.ItemStack stack)
    Convenience method to get an upgrade from its corresponding item
    int
    A numeric id for the upgrade which is not guaranteed to be persistent across game restarts.
    final net.minecraft.world.item.Item
    Get the corresponding item for this upgrade, assuming tier 1
    final net.minecraft.world.item.Item
    getItem(int tier)
    Get the corresponding item for this upgrade and tier.
    final net.minecraft.world.item.ItemStack
    Get an itemstack for the given upgrade
    final net.minecraft.world.item.ItemStack
    getItemStack(int count)
    Get an itemstack for the given upgrade
    final int
    Get the max upgrade tier allowable for this upgrade.
    final boolean
    Check if this upgrade's dependent mods are loaded.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PNCUpgrade

      public PNCUpgrade()
      Default constructor; register an upgrade with just one tier.
    • PNCUpgrade

      public PNCUpgrade(int maxTier, String... depModIds)
      Register an upgrade with just one tier.
      Parameters:
      maxTier - maximum tier for this upgrade
      depModIds - 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

      public static PNCUpgrade from(net.minecraft.world.item.ItemStack stack)
      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