Adds weapon, break_sound, equippable, and swing_animation item components.#2821
Adds weapon, break_sound, equippable, and swing_animation item components.#2821heypr wants to merge 4 commits into
weapon, break_sound, equippable, and swing_animation item components.#2821Conversation
| } | ||
| if (value.allowedEntities() != null) { | ||
| ListTag entities = new ListTag(); | ||
| value.allowedEntities().forEach(key -> entities.addObject(new ElementTag(key.key().asMinimalString(), true))); |
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); |
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<>(); |
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), |
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. |
There was a problem hiding this comment.
durability_per_attack maybe? Just to match the naming of existing features
| // @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> |
There was a problem hiding this comment.
Also just realized this makes the key swing_animation.animation_type - the double animation is redundant there imo
As stated in the title, this PR adds four item components :)