Adds weapon, break_sound, equippable, and swing_animation item components.#2821
Open
heypr wants to merge 3 commits intoDenizenScript:devfrom
Open
Adds weapon, break_sound, equippable, and swing_animation item components.#2821heypr wants to merge 3 commits intoDenizenScript:devfrom
weapon, break_sound, equippable, and swing_animation item components.#2821heypr wants to merge 3 commits intoDenizenScript:devfrom
Conversation
tal5
requested changes
Apr 28, 2026
| } | ||
| if (value.allowedEntities() != null) { | ||
| ListTag entities = new ListTag(); | ||
| value.allowedEntities().forEach(key -> entities.addObject(new ElementTag(key.key().asMinimalString(), true))); |
Member
There was a problem hiding this comment.
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); |
Member
There was a problem hiding this comment.
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<>(); |
Member
There was a problem hiding this comment.
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> |
| // 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. |
| 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), |
Member
There was a problem hiding this comment.
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. |
| // 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. |
Member
There was a problem hiding this comment.
durability_per_attack maybe? Just to match the naming of existing features
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As stated in the title, this PR adds four item components :)