#(Skullfurious) Any way to get total armor of all combined equipments?

51 messages · Page 1 of 1 (latest)

stray pumice
#

Just trying to figure this out.

I'm kind of here:

                - foreach <[target].equipment> as:equipment:
                    - define armor armor.add[<[equipment].>]
tame breachBOT
#

(Skullfurious) Any way to get total armor of all combined equipments?

tame breachBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

stray pumice
#

I'm not sure how to access the value of the armor or toughness (whichever it's called) by the armor.

stray pumice
#

- define armor armor.add[<[equipment].attribute_value[generic.armor]>]

#

doesn't seem to be it, I am getting the chest piece as the item however.

static topaz
#

its generic_armor

#

!t itemtag.attribute_modifiers

tepid perchBOT
# static topaz !t itemtag.attribute_modifiers

Returns a map of all attribute modifiers on the item, with key as the attribute name and value as a list of modifiers,
where each modifier is a MapTag containing keys 'name', 'amount', 'slot', 'operation', and 'id'.
This is formatted in a way that can be sent back into the 'attribute_modifiers' mechanism.
See also !language attribute modifiers.

Group

properties

Returns

MapTag

Mechanism

ItemTag.attribute_modifiers

stray pumice
#

Looks like the map is empty for some reason.

#

just testing some stuff

#
                - foreach <[target].equipment> as:equipment:
                    - if <[equipment]> !matches air:
                        - define armor <[equipment].attribute_modifiers>
#

equipment does match i@iron_chestplate

#

hmm

#

Not sure I completely understand what's going on, but I assume it's because the map is empty I'm getting an unrecognized subtag .get

#

Looks like the item doesn't have the attribute modifiers, so that's more than likely the problem.

#
TestWorld:
    type: world
    events:
        on player right clicks block:
        - foreach <player.item_in_hand.attribute_modifiers> key:key as:val:
            - narrate "<[key]> is set as <[val]>"
#

reproducable with that.

stray pumice
#

Okay, so here's where I'm at for anyone willing to jump in.

<player.attribute_modifiers> will list all the armor the player has equipped. This isn't what I need though, but it does work as you would anticipate.

The problem is that <npc.attribute_modifiers> will not list anything even if the entity has armor equipped. The map is simply empty.

The closest I've come to grabbing attributes from the NPC is with <npc.describe> but the items listed in the various maps don't contain the armor attributes, only durability.

Basically what I'm looking at is going through each item in the equipment menu, manually listing its defaults, check for enchantments, tally everything up, or wait for this to be implemented for NPC's.

It also may just be me not understanding what's going on.

spring heron
tepid perchBOT
#
Possible Confusion

Did you mean to search for itemtag.default_attribute_modifiers?

tepid perchBOT
stray pumice
#

Won't that give the wrong armor value if any of the gear on the NPC is enchanted?

I'll definitely try it out when I wake up in the morning.

stray pumice
#

Could I possibly make it a feature request to make the tag attribute_modifiers work on NPC's as it does on players?

#

It's not possible to iterate through default_attribute_modifier[<slot>] with a foreach loop because you have to specify the slot which makes the code a bit more complex.

#

Or, a better solution, may be to just have a .armor and .toughness tag for npc's.

#

Oh, and interestingly enough...

Weapons with sharpness enchantments have their damage values updated, but armors for some reason don't. (I'm not super familiar with how MC works, so maybe that's obvious, but you'd think protection V would modify the armor's value, but perhaps because different damage sources are broken up into different enchantments that's why it doesn't).

As far as enchantments go.. I can just find out if the player is receiving additional damage mitigation from enchanted gear some other way I guess, if I wanted to go that far. Which I currently do not.

tight condor
#

!t player.armor_bonus

tepid perchBOT
tight condor
#

That's for armor ^

#

ie; it returns the amount of armor points above the hotbar

#

and you could use that to get the armor_toughness applied on the player
<player.attribute_value[GENERIC_ARMOR_TOUGHNESS]>

#

!t entity.attribute_value

tepid perchBOT
tight condor
#

The first one player.armor_bonus is technically also just a shorthand for
<player.attribute_value[GENERIC_ARMOR]>

stray pumice
#

I'll close this as soon as I get a chance to read it over thank you.

spring heron
#

Marking this for closing, it'll be auto-closed in 3 days as usual so you'll have time to look it over (also it's still here forever even if closed, ofc)

cosmic gladeBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@stray pumice