Skip to content

Conversation

@Absolutionism
Copy link
Contributor

@Absolutionism Absolutionism commented Oct 2, 2025

Problem

Skript does not have support for Consumable Components yet. Leaving players unable to modify items to be consumable and other correlating data.

Solution

Adds Consumable Components and all correlating data to Skript following the backend of the component system locked behind a experiment. Allows players to modify items regarding consumption sound, consumption time, consume effects and many more.
Additionally adds ConsumeEffects with a custom ConsumeEffectType enum

Testing Completed

ConsumableComponents.sk

Supporting Information

N/A


Completes: none
Related: none

#	src/main/java/ch/njol/skript/registrations/Feature.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/ComponentWrapper.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/EquippableModule.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/EquippableWrapper.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompDamage.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompDispensable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompInteract.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompShearable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompSwapEquipment.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompDamageable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompDispensable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompInteract.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompShearable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompSwapEquipment.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompCameraOverlay.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompEntities.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompEquipSound.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompModel.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompShearSound.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompSlot.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquippableComponent.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprSecBlankEquipComp.java
#	src/main/resources/lang/default.lang
…leComponent

# Conflicts:
#	src/main/java/ch/njol/skript/Skript.java
#	src/main/java/ch/njol/skript/registrations/Feature.java
#	src/main/java/ch/njol/skript/util/ItemSource.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/ComponentUtils.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/ComponentWrapper.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/ItemComponentModule.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/EquippableModule.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/EquippableWrapper.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompDamage.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompDispensable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompInteract.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompShearable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/CondEquipCompSwapEquipment.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompDamageable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompDispensable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompInteract.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompShearable.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/EffEquipCompSwapEquipment.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompCameraOverlay.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompEntities.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompEquipSound.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompModel.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompShearSound.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquipCompSlot.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprEquippableComponent.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/equippable/elements/ExprSecBlankEquipComp.java
#	src/main/java/org/skriptlang/skript/bukkit/itemcomponents/generic/ExprItemCompCopy.java
#	src/main/resources/lang/default.lang
@Absolutionism Absolutionism requested a review from a team as a code owner October 2, 2025 02:24
@Absolutionism Absolutionism added the feature Pull request adding a new feature. label Oct 2, 2025
@Absolutionism Absolutionism requested review from cheeezburga and erenkarakal and removed request for a team October 2, 2025 02:24
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Oct 2, 2025
@Absolutionism Absolutionism moved this to In Review in 2.14 Releases Oct 2, 2025
@Absolutionism Absolutionism added the 2.14 Targeting a 2.14.X version release. label Nov 2, 2025
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser rework would be needed, but thoughts on something akin to

when {x} is consumed:
    clear all potion effects
    teleport randomly in a radius of 10
    play sound "xyz"
    
or
add the following consumption effects to {x}:
    ....

?


@Override
public Class<?> @Nullable [] acceptChange(ChangeMode mode) {
if (mode == ChangeMode.SET)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty much all of these attributes need RESET support and their default values spelled out in the description.
This one should also support DELETE

public static void register(SyntaxRegistry registry) {
registry.register(
SyntaxRegistry.EXPRESSION,
infoBuilder(ExprConsCompEffects.class, ConsumeEffect.class, "consum(e|ption) effects", "consumablecomponents", true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
infoBuilder(ExprConsCompEffects.class, ConsumeEffect.class, "consum(e|ption) effects", "consumablecomponents", true)
infoBuilder(ExprConsCompEffects.class, ConsumeEffect.class, "consum(e|ption) [potion] effects", "consumablecomponents", true)


@Name("Consumable Component - Consume Effects")
@Description("""
The consume effects that should activate when the item is consumed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The consume effects that should activate when the item is consumed.
The potion effects that should activate when the item is consumed.

public static void register(SyntaxRegistry registry) {
registry.register(
SyntaxRegistry.EXPRESSION,
infoBuilder(ExprConsCompTime.class, Timespan.class, "consum(e|ption) time", "consumablecomponents", true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
infoBuilder(ExprConsCompTime.class, Timespan.class, "consum(e|ption) time", "consumablecomponents", true)
infoBuilder(ExprConsCompTime.class, Timespan.class, "consum(e|ption) duration", "consumablecomponents", true)

registry.register(
SyntaxRegistry.EXPRESSION,
SyntaxInfo.Expression.builder(ExprConsumeEffectApply.class, ConsumeEffect.class)
.addPatterns("[a] consume effect to apply %potioneffects% with [a] probability of %number%")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.addPatterns("[a] consume effect to apply %potioneffects% with [a] probability of %number%")
.addPatterns("[a] consume effect that applies %potioneffects% with [a] probability of %number%")

or [a] chance to apply %potioneffects% with [a] probability of %number% if you want to get a bit more fluid with the syntax.

Comment on lines +58 to +60
//noinspection unchecked
effects = (Expression<PotionEffect>) exprs[0];
//noinspection unchecked
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can suppress with annotation instead

registry.register(
SyntaxRegistry.EXPRESSION,
SyntaxInfo.Expression.builder(ExprConsumeEffectRemove.class, ConsumeEffect.class)
.addPatterns("[a] consume effect to remove %potioneffecttypes%")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.addPatterns("[a] consume effect to remove %potioneffecttypes%")
.addPatterns("[a] consume effect that (removes|clears|cures) %potioneffecttypes%")

registry.register(
SyntaxRegistry.EXPRESSION,
SyntaxInfo.Expression.builder(ExprConsumeEffectSound.class, ConsumeEffect.class)
.addPatterns("[a] consume effect to play [[the] sound] %string%")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.addPatterns("[a] consume effect to play [[the] sound] %string%")
.addPatterns("[a] consume effect that plays [[the] sound] %string%")


@Name("Blank Consumable Component")
@Description("""
Gets a blank consumable component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEFAULTS!!!!

registry.register(
SyntaxRegistry.EXPRESSION,
SyntaxInfo.Expression.builder(LitConsumeEffectClear.class, ConsumeEffect.class)
.addPatterns("[a] consume effect to clear all (potion|status) effects")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.addPatterns("[a] consume effect to clear all (potion|status) effects")
.addPatterns("[a] consume effect that clears all (potion|status) effects")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.14 Targeting a 2.14.X version release. feature Pull request adding a new feature. needs reviews A PR that needs additional reviews

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants