Interface IArmorUpgradeHandler<T extends IArmorExtensionData>
- All Known Implementing Classes:
AirConHandler,BaseArmorUpgradeHandler,BlockTrackerHandler,ChargingHandler,ChestplateLauncherHandler,CoordTrackerHandler,CoreComponentsHandler,DroneDebugHandler,ElytraHandler,EnderVisorHandler,EntityTrackerHandler,HackHandler,JetBootsHandler,JumpBoostHandler,KickHandler,MagnetHandler,NightVisionHandler,ReachDistanceHandler,ScubaHandler,SearchHandler,SpeedBoostHandler,StepAssistHandler,StompHandler
public interface IArmorUpgradeHandler<T extends IArmorExtensionData>
Represents the common part of a Pneumatic Armor upgrade handler. Singleton implementations of this are present
on both client and server. See
IArmorUpgradeClientHandler for the client-side handler (which has a
one-to-one mapping to this).
It is recommended to extend BaseArmorUpgradeHandler rather than implement this interface directly.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringUsed for translation keys and keybind naming -
Method Summary
Modifier and TypeMethodDescriptionSet up player-specific extension data for this armor upgrade; since armor upgrade handlers are singleton objects, any player-specific data needs to be stored separately.net.minecraft.world.entity.EquipmentSlotGet the armor slot that this upgrade handler is attached to.net.minecraft.resources.ResourceLocationgetID()Get a unique ID for this upgrade handler.floatgetIdleAirUsage(ICommonArmorHandler armorHandler) Returns the usage in mL/tick when this upgrade handler is enabled.intgetIndex()Used internally for quick lookup.default intgetMaxInstallableUpgrades(PNCUpgrade upgrade) Get the maximum number of the given upgrade which may be installed.default floatGet the minimum armor pressure for this renderer to operate; the armor piece pressure must be greater than this.Return the upgrades that are required to be in the armor piece to enable this module.static StringgetStringKey(net.minecraft.resources.ResourceLocation id) Source of truth for all translation keys and keybind names.default StringGet a translation key for this upgrade, for text display purposes.default voidonDataFieldUpdated(ICommonArmorHandler commonArmorHandler, String tagName, net.minecraft.nbt.Tag inbt) Called on both client and server when some NBT data is changed in this upgrade's armor itemstack.default voidonInit(ICommonArmorHandler commonArmorHandler) Called when the armor is initialising and this upgrade is installed.default voidonShutdown(ICommonArmorHandler commonArmorHandler) Called when the armor is removed; carry out any necessary shutdown tasks heredefault voidonToggle(ICommonArmorHandler commonArmorHandler, boolean newState) Called when an upgrade is toggled on/off by the playervoidsetIndex(int index) Used internally for quick lookup.default voidtick(ICommonArmorHandler commonArmorHandler, boolean enabled) Called every tick for a player when this upgrade is installed in their armor
-
Field Details
-
UPGRADE_PREFIX
Used for translation keys and keybind naming- See Also:
-
-
Method Details
-
getID
net.minecraft.resources.ResourceLocation getID()Get a unique ID for this upgrade handler.- Returns:
- a unique resource location
-
getIndex
int getIndex()Used internally for quick lookup. Don't use this directly; usegetID()for a unique identifier.- Returns:
- the internal numeric index for this upgrade
-
setIndex
void setIndex(int index) Used internally for quick lookup. Set once when this upgrade is registered; do not attempt to change this!- Parameters:
index- the internal numeric index for this upgrade
-
getRequiredUpgrades
PNCUpgrade[] getRequiredUpgrades()Return the upgrades that are required to be in the armor piece to enable this module.- Returns:
- an array of required upgrades
-
getMaxInstallableUpgrades
Get the maximum number of the given upgrade which may be installed.- Parameters:
upgrade- an upgrade- Returns:
- the maximum installable amount of this upgrade
-
getIdleAirUsage
Returns the usage in mL/tick when this upgrade handler is enabled. Note this is constant usage just from the upgrade being switched on, and does not take into account air used when some action is taken, e.g. flying with the Jet Boots upgrade is not included here, but air used by the Entity Tracker upgrade is included.- Parameters:
armorHandler- the armor handler object (can be used to get upgrades, etc.)- Returns:
- usage in mL/tick
-
getMinimumPressure
default float getMinimumPressure()Get the minimum armor pressure for this renderer to operate; the armor piece pressure must be greater than this. Most components require any pressure >0.0 bar. Return any negative value for the component to always render regardless of pressure.- Returns:
- the minimum required pressure
-
getEquipmentSlot
net.minecraft.world.entity.EquipmentSlot getEquipmentSlot()Get the armor slot that this upgrade handler is attached to.- Returns:
- the armor slot
-
getTranslationKey
Get a translation key for this upgrade, for text display purposes.- Returns:
- a translation key
-
tick
Called every tick for a player when this upgrade is installed in their armor- Parameters:
commonArmorHandler- the armor handler objectenabled- true if the upgrade is currently enabled, false otherwise
-
onInit
Called when the armor is initialising and this upgrade is installed.- Parameters:
commonArmorHandler- the armor handler object
-
onToggle
Called when an upgrade is toggled on/off by the player- Parameters:
commonArmorHandler- the armor handler objectnewState- the new state of the upgrade
-
onShutdown
Called when the armor is removed; carry out any necessary shutdown tasks here- Parameters:
commonArmorHandler- the armor handler object
-
onDataFieldUpdated
default void onDataFieldUpdated(ICommonArmorHandler commonArmorHandler, String tagName, net.minecraft.nbt.Tag inbt) Called on both client and server when some NBT data is changed in this upgrade's armor itemstack. Can be used to cache heavily-accessed NBT data for performance reasons.- Parameters:
commonArmorHandler- the armor handler objecttagName- the NBT tag nameinbt- the NBT data
-
extensionData
Set up player-specific extension data for this armor upgrade; since armor upgrade handlers are singleton objects, any player-specific data needs to be stored separately. If your handler needs this (most don't), override this method to return a supplier of a new instance of some class that implementsIArmorExtensionData. This data will be stored in the common armor handler for the player, and can be retrieved withICommonArmorHandler.getExtensionData(IArmorUpgradeHandler).- Returns:
- a supplier for the extension data for this upgrade & player; supply null if there is none
-
getStringKey
Source of truth for all translation keys and keybind names. Standard "pneumaticcraft.armor.upgrade" prefix, followed by a resource location ID, where the ID is converted to a string. ID's from the "pneumaticcraft" namespace use just the resource location's path, while ID's from other namespaces include the namespace. E.g.:- "pneumaticcraft:block_tracker" -> "pneumaticcraft.armor.upgrade.block_tracker"
- "pneumaticcraft:block_tracker.module.energy" -> "pneumaticcraft.armor.upgrade.block_tracker.module.energy"
- "mod2:other_upgrade" -> "pneumaticcraft.armor.upgrade.mod2.other_upgrade"
- Parameters:
id- the upgrade ID, as returned bygetID()- Returns:
- a dot-separated string key, suitable for a translation key or keybind name
-