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.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Helper class to collect a list of upgrades for adding to an object via one of the addApplicableUpgrades() methods
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addApplicableUpgrades(net.minecraft.world.entity.EntityType<?> type, IUpgradeRegistry.Builder builder)
    Register the given upgrade builder with the given entity type.
    void
    addApplicableUpgrades(net.minecraft.world.item.Item item, IUpgradeRegistry.Builder builder)
    Register the given upgrade builder with the given item.
    void
    addApplicableUpgrades(net.minecraft.world.level.block.entity.BlockEntityType<?> type, IUpgradeRegistry.Builder builder)
    Register the given upgrade builder with the given block entity type.
    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.
    getAllUpgrades(net.minecraft.world.item.ItemStack stack)
    Helper method to get all the upgrades currently installed in the given itemstack
    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
    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
    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
    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.
    net.minecraft.world.item.Item
    makeUpgradeItem(Supplier<PNCUpgrade> upgrade, int tier)
    Convenience method to create an Item implementing the IUpgradeItem interface, which can be used as a PneumaticCraft upgrade.
    net.minecraft.world.item.Item
    makeUpgradeItem(Supplier<PNCUpgrade> upgrade, int tier, net.minecraft.world.item.Item.Properties properties)
    Same as makeUpgradeItem(Supplier, int) but allows a custom item properties object to be supplied for use when the Item is created.
  • 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(Supplier, int). You can also call this yourself for custom upgrades that you create (i.e. items which implement IUpgradeItem).

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

      net.minecraft.world.item.Item makeUpgradeItem(Supplier<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(Supplier, int, Item.Properties) if you need custom behaviour here.

      Parameters:
      upgrade - a supplier for the upgrade object, which will not yet be registered
      tier - upgrade tier of this item
      Returns:
      an item, which should be registered in the usual way
    • makeUpgradeItem

      net.minecraft.world.item.Item makeUpgradeItem(Supplier<PNCUpgrade> upgrade, int tier, net.minecraft.world.item.Item.Properties properties)
      Same as makeUpgradeItem(Supplier, 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

      Map<PNCUpgrade,Integer> getAllUpgrades(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)