Class ConsumableUseComponent


public class ConsumableUseComponent extends ItemActionsComponent
Component responsible for handling the usage of consumable items.

When used, this component applies the effects of the consumable to the player entity and updates the inventory accordingly (either removing the item if it has been fully consumed, or decrementing its stack count).

  • Constructor Details

    • ConsumableUseComponent

      public ConsumableUseComponent()
  • Method Details

    • use

      public void use(Entity player)
      Uses the consumable item on the given player.

      If the consumable does not fire a projectile, all of its effects are applied to the player. The item is then consumed (removed or decremented) from the player's inventory.

      Specified by:
      use in class ItemActionsComponent
      Parameters:
      player - the entity representing the player using the consumable