Interface IUpgradeRegistry

All Known Implementing Classes:
ApplicableUpgradesDB

public interface IUpgradeRegistry
The upgrade registry can be used to register custom upgrades to be accepted by block entities, entities and items. Get an instance of it via PneumaticRegistry.IPneumaticCraftInterface.getUpgradeRegistry().

The addApplicableUpgrades() methods should be called from your FMLCommonSetupEvent handler.

  • Method Details

    • addApplicableUpgrades

      void addApplicableUpgrades(net.minecraft.world.level.block.entity.BlockEntityType<?> type, IUpgradeRegistry.Builder builder)
      Register the given upgrade builder with the given block entity type. Note that the upgrades in the given builder will overwrite and/or augment any upgrades already registered for the block entity.
      Parameters:
      type - the block entity type
      builder - the builder helper object
    • addApplicableUpgrades

      void addApplicableUpgrades(net.minecraft.world.entity.EntityType<?> type, IUpgradeRegistry.Builder builder)
      Register the given upgrade builder with the given entity type. Note that the upgrades in the given builder will overwrite and/or augment any upgrades already registered for the entity.
      Parameters:
      type - the entity type
      builder - the builder helper object
    • addApplicableUpgrades

      void addApplicableUpgrades(net.minecraft.world.item.Item item, IUpgradeRegistry.Builder builder)
      Register the given upgrade builder with the given item. Note that the upgrades in the given builder will overwrite and/or augment any upgrades already registered for the item.
      Parameters:
      item - the item
      builder - the builder helper object
    • getMaxUpgrades

      int getMaxUpgrades(net.minecraft.world.level.block.entity.BlockEntity te, PNCUpgrade upgrade)
      Get the maximum number of upgrades of the given type accepted by the given block entity
      Parameters:
      te - the block entity
      upgrade - the upgrade to check
      Returns:
      maximum number of that upgrade which can be installed
    • getMaxUpgrades

      int getMaxUpgrades(net.minecraft.world.entity.Entity entity, PNCUpgrade upgrade)
      Get the maximum number of upgrades of the given type accepted by the given entity
      Parameters:
      entity - the entity
      upgrade - the upgrade to check
      Returns:
      maximum number of that upgrade which can be installed
    • getMaxUpgrades

      int getMaxUpgrades(net.minecraft.world.item.Item item, PNCUpgrade upgrade)
      Get the maximum number of upgrades of the given type accepted by the given block entity
      Parameters:
      item - the item
      upgrade - the upgrade to check
      Returns:
      maximum number of that upgrade which can be installed
    • addUpgradeTooltip

      void addUpgradeTooltip(PNCUpgrade upgrade, List<net.minecraft.network.chat.Component> infoList)
      Convenience method which adds a list of the items which accept the given upgrade to the upgrade item's tooltip. This list is intended to be displayed while Shift is held down while hovering over the upgrade item, and will scroll if larger than 12 lines.

      This is automatically used by custom upgrades created via makeUpgradeItem(PNCUpgrade, int). You can also call this yourself on the client only for custom upgrades that you create (i.e. items which implement IUpgradeItem).

      Parameters:
      upgrade - the upgrade
      infoList - the tooltip to append to
    • registerUpgrade

      PNCUpgrade registerUpgrade(net.minecraft.resources.ResourceLocation id, int maxTier, String... depModIds)
      Register an upgrade. Note: this is a not a Forge or Minecraft registry object. It's OK to register upgrades during item registration, i.e. when you register your upgrade item(s).
      Parameters:
      id - the unique upgrade ID
      maxTier - the maximum tier of this upgrade
      depModIds - zero or more mod ID which must be present for this upgrade to be relevant
      Returns:
      an upgrade object
      Throws:
      IllegalStateException - if this upgrade ID has already been registered
    • registerUpgrade

      default PNCUpgrade registerUpgrade(net.minecraft.resources.ResourceLocation id)
      Register an upgrade with just one tier.
      Parameters:
      id - the unique upgrade ID
      Returns:
      an upgrade object
      Throws:
      IllegalStateException - if this upgrade ID has already been registered
    • getUpgradeById

      PNCUpgrade getUpgradeById(net.minecraft.resources.ResourceLocation upgradeId)
      Retrieve an upgrade by its ID
      Parameters:
      upgradeId - the upgrade ID, as used to register id
      Returns:
      the registered upgrade, or null if the id is not known
    • getKnownUpgrades

      Collection<PNCUpgrade> getKnownUpgrades()
      Retrieve an unmodifiable collection of all known registered upgrade objects
      Returns:
      all known upgrades
    • makeUpgradeItem

      net.minecraft.world.item.Item makeUpgradeItem(PNCUpgrade upgrade, int tier)
      Convenience method to create an Item implementing the IUpgradeItem interface, which can be used as a PneumaticCraft upgrade. This item has the default PneumaticCraft tooltip behaviour in that addUpgradeTooltip(PNCUpgrade, List) is called when Shift is held while hovering over the item.

      You can use this method when registering upgrade items as an alternative to creating an Item which implements IUpgradeItem yourself.

      The item created by this method will be in the PneumaticCraft creative tab and have no other special item properties; see makeUpgradeItem(PNCUpgrade, int, Item.Properties) if you need custom behaviour here.

      Parameters:
      upgrade - the upgrade object, as returned by registerUpgrade(ResourceLocation)
      tier - upgrade tier of this item
      Returns:
      an item, which should be registered in the usual way
    • makeUpgradeItem

      net.minecraft.world.item.Item makeUpgradeItem(PNCUpgrade upgrade, int tier, net.minecraft.world.item.Item.Properties properties)
      Same as makeUpgradeItem(PNCUpgrade, int) but allows a custom item properties object to be supplied for use when the Item is created.
      Parameters:
      upgrade - a supplier for the upgrade object, which will not yet be registered
      tier - upgrade tier of this item
      properties - an item properties object
      Returns:
      an item, which should be registered in the usual way
    • getUpgradeCount

      int getUpgradeCount(net.minecraft.world.item.ItemStack stack, PNCUpgrade upgrade)
      Helper method to get the number of the given upgrade which is installed in the given itemstack.
      Parameters:
      stack - the item holding the upgrades
      upgrade - the upgrade to check for
      Returns:
      the number of that upgrade installed in the item
    • getAllUpgrades

      @Deprecated(forRemoval=true) default Map<PNCUpgrade,Integer> getAllUpgrades(net.minecraft.world.item.ItemStack stack)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get all the upgrades install in a given item.
      Parameters:
      stack - an item
      Returns:
      all the upgrades installed in the item
    • getUpgradesInItem

      Map<PNCUpgrade,Integer> getUpgradesInItem(net.minecraft.world.item.ItemStack stack)
      Helper method to get all the upgrades currently installed in the given itemstack
      Parameters:
      stack - the item holding the upgrades
      Returns:
      an immutable map of (upgrade->count)
    • getItemRegistryName

      @Deprecated(forRemoval=true) net.minecraft.resources.ResourceLocation getItemRegistryName(PNCUpgrade upgrade, int tier)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the registry name for the corresponding item for this upgrade, given a tier. Do not use this before the upgrade itself has been registered!

      The default naming strategy is to take the upgrade's registry name and simply append "_upgrade" to it (along with the tier number if it's a multitier upgrade). You can override this strategy by extending this class and overriding this method if you need to.

      Parameters:
      upgrade - the upgrade in question
      tier - tier of the upgrade (ignored if the upgrade has only one tier)
      Returns:
      an item registry name