#Item baseDamage Component?

1 messages · Page 1 of 1 (latest)

dusk jolt
#

Is there a way to obtain the base damage of an item? For example the diamond sword having +7 attack damage

uncut schooner
# dusk jolt Is there a way to obtain the base damage of an item? For example the diamond swo...

You cant directly get it, but you can find it with this simple script

// tool type modifier
const tool = [
    { id: '_sword', modifier: 0 },
    { id: '_axe', modifier: -1 },
    { id: '_pickaxe', modifier: -2 },
    { id: '_hoe', modifier: -2 },
    { id: '_shovel', modifier: -3 }
].find(({ id }) => itemStack?.typeId.includes(id)) || null

// material modifier
const material = [
    { id: 'netherite', dmg: 8 },
    { id: 'diamond', dmg: 7 },
    { id: 'iron', dmg: 6 },
    { id: 'gold', dmg: 5 },
    { id: 'stone', dmg: 5 },
    { id: 'wooden', dmg: 4 },
].find(({ id }) => itemStack?.typeId.includes(id)) || null

// total damage
const damage = (material?.dmg + tool?.modifier) || 0;