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.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.net.minecraft.resources.ResourceLocationgetItemRegistryName(PNCUpgrade upgrade, int tier) Deprecated, for removal: This API element is subject to removal in a future version.Retrieve an unmodifiable collection of all known registered upgrade objectsintgetMaxUpgrades(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 entitygetUpgradeById(net.minecraft.resources.ResourceLocation upgradeId) Retrieve an upgrade by its IDintgetUpgradeCount(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.getUpgradesInItem(net.minecraft.world.item.ItemStack stack) Helper method to get all the upgrades currently installed in the given itemstacknet.minecraft.world.item.ItemmakeUpgradeItem(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(PNCUpgrade upgrade, int tier, net.minecraft.world.item.Item.Properties properties) Same asmakeUpgradeItem(PNCUpgrade, int)but allows a custom item properties object to be supplied for use when theItemis created.default PNCUpgraderegisterUpgrade(net.minecraft.resources.ResourceLocation id) Register an upgrade with just one tier.registerUpgrade(net.minecraft.resources.ResourceLocation id, int maxTier, String... depModIds) Register an upgrade.
-
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(PNCUpgrade, 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
-
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 IDmaxTier- the maximum tier of this upgradedepModIds- 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
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
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
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(PNCUpgrade, int, Item.Properties)if you need custom behaviour here.- Parameters:
upgrade- the upgrade object, as returned byregisterUpgrade(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 asmakeUpgradeItem(PNCUpgrade, 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
@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
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 questiontier- tier of the upgrade (ignored if the upgrade has only one tier)- Returns:
- an item registry name
-
getUpgradesInItem(ItemStack)