#(Skullfurious) Any way to get total armor of all combined equipments?
51 messages · Page 1 of 1 (latest)
(Skullfurious) Any way to get total armor of all combined equipments?
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>
I'm not sure how to access the value of the armor or toughness (whichever it's called) by the armor.
- 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.
just based on https://minecraft.fandom.com/wiki/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.
properties
MapTag
ItemTag.attribute_modifiers
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
Content of Denizen Script Paste #107264: Unnamed Denizen Script Paste... pasted 2023/03/11 21:00:38 UTC-08:00, Paste length: 574 characters across 5 lines, Content: [00:59:25 INFO]: Filled tag <[equipment]> with i@iron_chestplate.[00:59:25 INFO]: Comparing if...
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.
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.
!t default_atrribute_modifires
Did you mean to search for itemtag.default_attribute_modifiers?
Returns a map of all default attribute modifiers on the item based purely on its material type, for the given slot,
in the same format as !tag ItemTag.attribute_modifiers
Slot must be one of: HAND, OFF_HAND, FEET, LEGS, CHEST, or HEAD
properties
MapTag
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.
https://paste.denizenscript.com/View/107300
It's working.. for anyone curious what I ended up having to do.
Content of Denizen Script Paste #107300: Unnamed Denizen Script Paste... pasted 2023/03/12 13:41:19 UTC-07:00, Paste length: 2095 characters across 19 lines, Content: #- Armor and Toughness Logic - define armor 0
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.
!t player.armor_bonus
Returns the entity's base armor bonus.
attributes
ElementTag(Decimal)
EntityTag.armor_bonus
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
Returns the final calculated value of the named attribute for the entity.
See also !tag EntityTag.has_attribute.
Valid attribute names are listed at https://hub.spigotmc.org/javadocs/spigot/org/bukkit/attribute/Attribute.html
See also !language attribute modifiers.
properties
ElementTag(Decimal)
EntityTag.attribute_base_values
The first one player.armor_bonus is technically also just a shorthand for
<player.attribute_value[GENERIC_ARMOR]>
I'll close this as soon as I get a chance to read it over thank you.
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)
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