Skip to content

ConsumableComponentHelper ​

com.jsmacrosce.jsmacros.client.api.helper.inventory.ConsumableComponentHelper

Since2.3.0

Reads how a stack is consumed. Nutrition and potion contents are separate components.

js
const use = Player.getPlayer()?.getMainHand().getComponents().getConsumable();  
if (use != null) Chat.log(`${use.getAnimation()} takes ${use.getDurationTicks()} ticks`);

Methods ​

getAnimation ​

getAnimation(): String#
Returns: the animation name, such as "eat" or "drink"

getDurationSeconds ​

getDurationSeconds(): float#
Returns: the configured consumption time in seconds

getDurationTicks ​

getDurationTicks(): int#
Returns: the consumption time Minecraft uses, in ticks

getEffects ​

getEffects(): List<ConsumeEffectHelper>#
Lists the effects configured in this component. Other components, such as potion contents, can provide additional effects.
Returns: the configured effects in Minecraft's application order

getSoundId ​

getSoundId(): String#
Returns: the ID of the configured consumption sound

hasParticles ​

hasParticles(): boolean#
Returns: whether consuming the item is configured to show particles