Skip to content

Adds weapon, break_sound, equippable, and swing_animation item components.#2821

Open
heypr wants to merge 3 commits intoDenizenScript:devfrom
heypr:more-new-stuff
Open

Adds weapon, break_sound, equippable, and swing_animation item components.#2821
heypr wants to merge 3 commits intoDenizenScript:devfrom
heypr:more-new-stuff

Conversation

@heypr
Copy link
Copy Markdown
Contributor

@heypr heypr commented Apr 11, 2026

As stated in the title, this PR adds four item components :)

}
if (value.allowedEntities() != null) {
ListTag entities = new ListTag();
value.allowedEntities().forEach(key -> entities.addObject(new ElementTag(key.key().asMinimalString(), true)));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Meta says ListTag(EntityTag) (which is probably correct for this), but these are ElementTags

Also, should be able to use RegistryKeySet#values with the LisTag convertor constructor instead of looping over


@Override
public Equippable fromDenizen(MapTag value, Mechanism mechanism) {
ElementTag slot = value.getObjectAs("slot", ElementTag.class, mechanism.context);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this can just be #getElement?

setIfValid(builder::shearSound, value, "shear_sound", ElementTag.class, null, element -> Utilities.parseNamespacedKey(element.asString()), "namespaced key", mechanism);
ListTag entityList = value.getObjectAs("allowed_entities", ListTag.class, mechanism.context);
if (entityList != null) {
List<TypedKey<EntityType>> keys = new ArrayList<>();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick, but can initialize to the correct size here

// @description
// Controls an item's swing animation <@link language Item Components>.
// The map includes keys:
// - "animation_type", an ElementTag representing the animation type. Valid animation types can be found at <@link url https://jd.papermc.io/paper/io/papermc/paper/datacomponent/item/SwingAnimation.Animation.html>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missing . at end of line.

// Controls an item's swing animation <@link language Item Components>.
// The map includes keys:
// - "animation_type", an ElementTag representing the animation type. Valid animation types can be found at <@link url https://jd.papermc.io/paper/io/papermc/paper/datacomponent/item/SwingAnimation.Animation.html>
// - "duration", an ElementTag(Number) representing the duration of the animation.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"duration"

ElementTag

public SwingAnimation fromDenizen(MapTag value, Mechanism mechanism) {
SwingAnimation.Builder builder = SwingAnimation.swingAnimation();
setIfValid(builder::type, value, "animation_type", ElementTag.class,
element -> element.matchesEnum(SwingAnimation.Animation.class),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can test, but pretty sure this is redundant - asEnum would return null for invalid input and setIfValid will treat that as invalid input the same way

// @description
// Controls an item's weapon <@link language Item Components>.
// The map includes keys:
// - "disable_blocking_duration", an ElementTag(Decimal) representing the number of seconds that a shield will be disabled for after blocking an attack from this item.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

_duration

ElementTag

// Controls an item's weapon <@link language Item Components>.
// The map includes keys:
// - "disable_blocking_duration", an ElementTag(Decimal) representing the number of seconds that a shield will be disabled for after blocking an attack from this item.
// - "item_damage_per_attack", an ElementTag(Number) representing the amount of durability damage this item will take when used to attack an entity or break a block.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

durability_per_attack maybe? Just to match the naming of existing features

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants