Interface IUpgradeRegistry
- All Known Implementing Classes:
ApplicableUpgradesDB
PneumaticRegistry.IPneumaticCraftInterface.getUpgradeRegistry().
The addApplicableUpgrades() methods should be called from your
FMLCommonSetupEvent handler.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classHelper class to collect a list of upgrades for adding to an object via one of theaddApplicableUpgrades()methods -
Method Summary
Modifier and TypeMethodDescriptionvoidaddApplicableUpgrades(net.minecraft.world.entity.EntityType<?> type, IUpgradeRegistry.Builder builder) Register the given upgrade builder with the given entity type.voidaddApplicableUpgrades(net.minecraft.world.item.Item item, IUpgradeRegistry.Builder builder) Register the given upgrade builder with the given item.voidaddApplicableUpgrades(net.minecraft.world.level.block.entity.BlockEntityType<?> type, IUpgradeRegistry.Builder builder) Register the given upgrade builder with the given block entity type.voidaddUpgradeTooltip(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 itemstacknet.minecraft.resources.ResourceLocationgetItemRegistryName(PNCUpgrade upgrade, int tier) Get the registry name for the corresponding item for this upgrade, given a tier.intgetMaxUpgrades(net.minecraft.world.entity.Entity entity, PNCUpgrade upgrade) Get the maximum number of upgrades of the given type accepted by the given entityintgetMaxUpgrades(net.minecraft.world.item.Item item, PNCUpgrade upgrade) Get the maximum number of upgrades of the given type accepted by the given block entityintgetMaxUpgrades(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 entityintgetUpgradeCount(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.ItemmakeUpgradeItem(Supplier<PNCUpgrade> upgrade, int tier) Convenience method to create an Item implementing theIUpgradeIteminterface, which can be used as a PneumaticCraft upgrade.net.minecraft.world.item.ItemmakeUpgradeItem(Supplier<PNCUpgrade> upgrade, int tier, net.minecraft.world.item.Item.Properties properties) Same asmakeUpgradeItem(Supplier, int)but allows a custom item properties object to be supplied for use when theItemis 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 typebuilder- 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 typebuilder- the builder helper object
-
addApplicableUpgrades
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 itembuilder- the builder helper object
-
getMaxUpgrades
Get the maximum number of upgrades of the given type accepted by the given block entity- Parameters:
te- the block entityupgrade- the upgrade to check- Returns:
- maximum number of that upgrade which can be installed
-
getMaxUpgrades
Get the maximum number of upgrades of the given type accepted by the given entity- Parameters:
entity- the entityupgrade- the upgrade to check- Returns:
- maximum number of that upgrade which can be installed
-
getMaxUpgrades
Get the maximum number of upgrades of the given type accepted by the given block entity- Parameters:
item- the itemupgrade- the upgrade to check- Returns:
- maximum number of that upgrade which can be installed
-
addUpgradeTooltip
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 on the client only for custom upgrades that you create (i.e. items which implementIUpgradeItem).- Parameters:
upgrade- the upgradeinfoList- the tooltip to append to
-
makeUpgradeItem
Convenience method to create an Item implementing theIUpgradeIteminterface, which can be used as a PneumaticCraft upgrade. This item has the default PneumaticCraft tooltip behaviour in thataddUpgradeTooltip(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
IUpgradeItemyourself.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 registeredtier- 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 asmakeUpgradeItem(Supplier, int)but allows a custom item properties object to be supplied for use when theItemis created.- Parameters:
upgrade- a supplier for the upgrade object, which will not yet be registeredtier- upgrade tier of this itemproperties- an item properties object- Returns:
- an item, which should be registered in the usual way
-
getUpgradeCount
Helper method to get the number of the given upgrade which is installed in the given itemstack.- Parameters:
stack- the item holding the upgradesupgrade- the upgrade to check for- Returns:
- the number of that upgrade installed in the item
-
getAllUpgrades
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
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 questiontier- tier of the upgrade (ignored if the upgrade has only one tier)- Returns:
- an item registry name
- Throws:
NullPointerException- if called before the upgrade is registered
-