Class CommonArmorHandler

java.lang.Object
me.desht.pneumaticcraft.common.pneumatic_armor.CommonArmorHandler
All Implemented Interfaces:
ICommonArmorHandler

public class CommonArmorHandler extends Object implements ICommonArmorHandler
  • Field Details

  • Method Details

    • getHandlerForPlayer

      public static CommonArmorHandler getHandlerForPlayer(net.minecraft.world.entity.player.Player player)
    • getHandlerForPlayer

      public static CommonArmorHandler getHandlerForPlayer()
    • getExtensionData

      public <T extends IArmorExtensionData> T getExtensionData(IArmorUpgradeHandler<T> handler)
      Description copied from interface: ICommonArmorHandler
      Get the per-player extension data for the given upgrade, if any. See IArmorUpgradeHandler.extensionData().
      Specified by:
      getExtensionData in interface ICommonArmorHandler
      Type Parameters:
      T - handler type
      Parameters:
      handler - the armor upgrade handler
      Returns:
      the extension, or null if there is none for this type of upgrade
    • tickArmorPiece

      public void tickArmorPiece(net.minecraft.world.entity.EquipmentSlot slot)
    • getIdleAirUsage

      public float getIdleAirUsage(net.minecraft.world.entity.EquipmentSlot slot, boolean countDisabled)
    • addAir

      public float addAir(net.minecraft.world.entity.EquipmentSlot slot, int airAmount)
      Description copied from interface: ICommonArmorHandler
      Add (or remove) air from the armor piece in the given slot.
      Specified by:
      addAir in interface ICommonArmorHandler
      Parameters:
      slot - the slot
      airAmount - amount to add (negative amounts remove air)
      Returns:
      the previous pressure for the armor piece
    • initArmorInventory

      public void initArmorInventory(net.minecraft.world.entity.EquipmentSlot slot)
      Called on the first tick after the armor piece is equipped. Scan the armor piece in the given slot, and record all installed upgrades for fast access later on. Upgrades can't be changed without removing and re-equipping the piece, so we can cache quite a lot of useful info.
      Parameters:
      slot - the equipment slot
    • getPlayer

      public net.minecraft.world.entity.player.Player getPlayer()
      Description copied from interface: ICommonArmorHandler
      Get the player wearing this armor
      Specified by:
      getPlayer in interface ICommonArmorHandler
      Returns:
      the player
    • getUpgradeCount

      public int getUpgradeCount(net.minecraft.world.entity.EquipmentSlot slot, PNCUpgrade upgrade)
      Description copied from interface: ICommonArmorHandler
      Get the number of the given upgrade installed in the given armor slot
      Specified by:
      getUpgradeCount in interface ICommonArmorHandler
      Parameters:
      slot - the equipment slot (must be one of HEAD, CHEST, LEGS or FEET)
      upgrade - the upgrade to query
      Returns:
      the number of upgrades installed
    • getUpgradeCount

      public int getUpgradeCount(net.minecraft.world.entity.EquipmentSlot slot, PNCUpgrade upgrade, int max)
    • isUpgradeInserted

      public boolean isUpgradeInserted(net.minecraft.world.entity.EquipmentSlot slot, int featureIndex)
    • isUpgradeEnabled

      public boolean isUpgradeEnabled(net.minecraft.world.entity.EquipmentSlot slot, int featureIndex)
    • setUpgradeEnabled

      public void setUpgradeEnabled(net.minecraft.world.entity.EquipmentSlot slot, byte featureIndex, boolean state)
    • getTicksSinceEquipped

      public int getTicksSinceEquipped(net.minecraft.world.entity.EquipmentSlot slot)
    • getSpeedFromUpgrades

      public int getSpeedFromUpgrades(net.minecraft.world.entity.EquipmentSlot slot)
      Description copied from interface: ICommonArmorHandler
      Convenience method to get the speed boost for the given armor piece, which is 1 + {number_of_speed_upgrades}
      Specified by:
      getSpeedFromUpgrades in interface ICommonArmorHandler
      Parameters:
      slot - the equipment slot
      Returns:
      the speed boost
    • getStartupTime

      public int getStartupTime(net.minecraft.world.entity.EquipmentSlot slot)
    • isArmorReady

      public boolean isArmorReady(net.minecraft.world.entity.EquipmentSlot slot)
    • getArmorPressure

      public float getArmorPressure(net.minecraft.world.entity.EquipmentSlot slot)
      Description copied from interface: ICommonArmorHandler
      Get the pressure for the armor piece in the given equipment slot.
      Specified by:
      getArmorPressure in interface ICommonArmorHandler
      Parameters:
      slot - the equipment slot
      Returns:
      the pressure of the armor piece, in bar
    • getAir

      public int getAir(net.minecraft.world.entity.EquipmentSlot slot)
      Description copied from interface: ICommonArmorHandler
      Get the amount of air for the armor piece in the given equipment slot.
      Specified by:
      getAir in interface ICommonArmorHandler
      Parameters:
      slot - the equipment slot
      Returns:
      air, in mL
    • isArmorEnabled

      public boolean isArmorEnabled()
      Description copied from interface: ICommonArmorHandler
      Check if the armor master switch is enabled (i.e. core components are active)
      Specified by:
      isArmorEnabled in interface ICommonArmorHandler
      Returns:
      true if enabled
    • isValid

      public boolean isValid()
    • invalidate

      public void invalidate()
    • hasMinPressure

      public boolean hasMinPressure(net.minecraft.world.entity.EquipmentSlot slot)
      Description copied from interface: ICommonArmorHandler
      Check that the armor in the given is above the minimum pressure limit to operate
      Specified by:
      hasMinPressure in interface ICommonArmorHandler
      Parameters:
      slot - the slot
      Returns:
      true if the armor piece can function, false if not
    • upgradeUsable

      public boolean upgradeUsable(IArmorUpgradeHandler<?> upgrade, boolean mustBeActive)
      Description copied from interface: ICommonArmorHandler
      Check if the given upgrade handler is actually usable right now. Validates that the upgrade is installed, and that the corresponding armor piece is initialized and has sufficient pressure.
      Specified by:
      upgradeUsable in interface ICommonArmorHandler
      Parameters:
      upgrade - the upgrade handler to check
      mustBeActive - if true, the handler must be currently active
      Returns:
      true if the upgrade is usable right now, false otherwise
    • isUpgradeEnabled

      public boolean isUpgradeEnabled(IArmorUpgradeHandler<?> upgrade)
      Description copied from interface: ICommonArmorHandler
      Check if the given upgrade is currently enabled, i.e. has been switched on by the player.
      Specified by:
      isUpgradeEnabled in interface ICommonArmorHandler
      Parameters:
      upgrade - the upgrade to check
      Returns:
      true if the upgrade is currently enabled, false otherwise
    • setUpgradeEnabled

      public void setUpgradeEnabled(IArmorUpgradeHandler<?> upgrade, boolean enabled)
      Description copied from interface: ICommonArmorHandler
      Set the given upgrade enablement status. This can be called on either client or server, and will handle sync'ing the enablement appropriately. This is a no-op if the status is already the same as the requested new status, or if the upgrade isn't usable (i.e. not installed, armor disabled, out of air...)
      Specified by:
      setUpgradeEnabled in interface ICommonArmorHandler
      Parameters:
      upgrade - the upgrade to enable/disable
      enabled - the new enablement status
    • isOnCooldown

      public boolean isOnCooldown(net.minecraft.world.entity.EquipmentSlot slot)
      Description copied from interface: ICommonArmorHandler
      Convenience method to check if the armor item in the given slot is on (vanilla) cooldown. Note that the method does not check if the item is actually a Pneumatic Armor piece; this method is typically called from IArmorUpgradeHandler.tick(ICommonArmorHandler, boolean) where the armor is already known to be Pneumatic Armor.
      Specified by:
      isOnCooldown in interface ICommonArmorHandler
      Parameters:
      slot - the slot to check
      Returns:
      true if the equipped item is on cooldown, false otherwise