I have absolutely no clue why I did this and why it works, and why changing it makes it not work.
const equipment = player.getComponent("minecraft:equippable");
if (equipment.getEquipment(EquipmentSlot.Head) != undefined && equipment.getEquipment(EquipmentSlot.Head).getTags().find(tag => tag.startsWith('runecraft:armor_tier'))) {
player.__totalArmor += equipment.getEquipment(EquipmentSlot.Head).getTags().find(tag => tag.startsWith('runecraft:armor_tier'))[equipment.getEquipment(EquipmentSlot.Head).getTags().find(tag => tag.startsWith('runecraft:armor_tier')).length - 1]
}```
The contents inside of the if statement is pretty much the same thing, the only difference being the 2nd part has .length - 1. if I remove either parts, the values bug out and are incorrect. Does anyone know why this is happening? They are identical and I don't see why I duplicated them.
```js
player.__totalArmor += equipment.getEquipment(EquipmentSlot.Head).getTags().find(tag => tag.startsWith('runecraft:armor_tier'))[equipment.getEquipment(EquipmentSlot.Head).getTags().find(tag => tag.startsWith('runecraft:armor_tier')).length - 1]```
vs
```js
player.__totalArmor += equipment.getEquipment(EquipmentSlot.Head).getTags().find(tag => tag.startsWith('runecraft:armor_tier')).length - 1```