Class UpgradableItemUtils

java.lang.Object
me.desht.pneumaticcraft.common.util.UpgradableItemUtils

public class UpgradableItemUtils extends Object
Some helper methods to manage items which can store upgrades (Pneumatic Armor, Drones...)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addUpgradeInformation(net.minecraft.world.item.ItemStack iStack, List<net.minecraft.network.chat.Component> textList, net.minecraft.world.item.TooltipFlag flag)
    Add a standardized tooltip listing the installed upgrades in the given item.
    static int
    getUpgradeCount(net.minecraft.world.item.ItemStack stack, PNCUpgrade upgrade)
    Get the installed count for the given upgrade.
    static it.unimi.dsi.fastutil.ints.IntList
    getUpgradeList(net.minecraft.world.item.ItemStack stack, PNCUpgrade... upgradeList)
    Get the installed count for the given upgrades.
    getUpgrades(net.minecraft.world.item.ItemStack stack)
    Retrieves the upgrades currently installed on the given itemstack.
    static boolean
    hasCreativeUpgrade(net.minecraft.world.item.ItemStack stack)
     
    static void
    setUpgrades(net.minecraft.world.item.ItemStack stack, net.minecraftforge.items.ItemStackHandler handler)
    Store a collection of upgrades into an item stack.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • UpgradableItemUtils

      public UpgradableItemUtils()
  • Method Details

    • addUpgradeInformation

      public static void addUpgradeInformation(net.minecraft.world.item.ItemStack iStack, List<net.minecraft.network.chat.Component> textList, net.minecraft.world.item.TooltipFlag flag)
      Add a standardized tooltip listing the installed upgrades in the given item.
      Parameters:
      iStack - the item
      textList - list of text to append tooltip too
      flag - tooltip flag
    • setUpgrades

      public static void setUpgrades(net.minecraft.world.item.ItemStack stack, net.minecraftforge.items.ItemStackHandler handler)
      Store a collection of upgrades into an item stack. This should be only be used for items; don't use it to manage saved upgrades on a dropped block which has serialized upgrade data.
      Parameters:
      stack - the stack
      handler - an ItemStackHandler holding upgrade items
    • getUpgrades

      public static Map<PNCUpgrade,Integer> getUpgrades(net.minecraft.world.item.ItemStack stack)
      Retrieves the upgrades currently installed on the given itemstack. Upgrade tiers are taken into account, e.g. a single tier 5 upgrade will have a count of 5.
      Parameters:
      stack - the itemstack to check
      Returns:
      a map of upgrade->count
    • getUpgradeCount

      public static int getUpgradeCount(net.minecraft.world.item.ItemStack stack, PNCUpgrade upgrade)
      Get the installed count for the given upgrade. Tiered upgrades count as multiple, e.g. one Tier 5 upgrade will return a result of 5 if queried for.
      Parameters:
      stack - the itemstack to check
      upgrade - the upgrade to check for
      Returns:
      number of upgrades installed
    • getUpgradeList

      public static it.unimi.dsi.fastutil.ints.IntList getUpgradeList(net.minecraft.world.item.ItemStack stack, PNCUpgrade... upgradeList)
      Get the installed count for the given upgrades. Tiered upgrades count as multiple, e.g. one Tier 5 upgrade will return a result of 5 if queried for.
      Parameters:
      stack - the itemstack to check
      upgradeList - the upgrades to check for
      Returns:
      number of upgrades installed, in the same order as the upgrades which were passed to the method
    • hasCreativeUpgrade

      public static boolean hasCreativeUpgrade(net.minecraft.world.item.ItemStack stack)