#Reduce Freeze damage

1 messages · Page 1 of 1 (latest)

zenith lantern
#

I'm trying to buff Fire Protection by redefining it as 'Elemental Protection' as I plan to give it the properties of Origin's Water Protection alongside protection against the Freeze damage type. However, there are 2 steps of it I don't know how to resolve.

1. How do I rename 'Fire Protection' to 'Elemental Protection'
2. In an EntityEvents.hurt, how do I detect if the damage type of the event is 'freeze'

stiff hawkBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

zenith lantern
#

actually i just solved the 1st one

zenith lantern
#

Reduce Freeze damage

autumn mist
#
event.source.type == 'freeze'
zenith lantern
#

but its come to my attention that i dont know how to modify the damage value taken

zenith lantern
#

current progress & log:

    const victim = event.entity;
    var elementalProtectionCount = 0
    console.log(`${victim ? "There is victim" : "There is no victim"}`)

    let armorPieces = [
        victim.getHeadArmorItem(),
        victim.getChestArmorItem(),
        victim.getLegsArmorItem(),
        victim.getFeetArmorItem()
    ].forEach((piece) => {
        elementalProtectionCount += piece.getEnchantmentLevel('minecraft:fire_protection')
    })
    if (event.source.type == 'freeze') {
        prevDamage = event.damage;
        event.damage *= 1 - Math.min(0.08 * elementalProtectionCount, 80)
        victim.tell(`Test 2: ${prevDamage} ${event.damage}`)
    }
})```

```[16:13:56] [Server thread/INFO]:
protectionEnchants.js#4: There is victim
[16:13:56] [Server thread/ERROR]:
protectionEnchants.js#12: Error in 'EntityEvents.hurt': TypeError: Cannot find function getEnchantmentLevel in object 1 glass_helmet```
#

idk how to get enchantment level if not the grappling example posted much earlier

zenith lantern
#
    const victim = event.entity;
    var elementalProtectionCount = 0

    let armorPieces = [
        victim.getHeadArmorItem(),
        victim.getChestArmorItem(),
        victim.getLegsArmorItem(),
        victim.getFeetArmorItem()
    ].forEach((piece) => {
        if (piece.id != "minecraft:air") {
            elementalProtectionCount += piece.getEnchantments().get('minecraft:fire_protection')
        }
    })
    console.log(`Event source type: ${event.source.type}`)
    if (event.source.type == 'freeze') {
        console.log(`Applying the anti-freeze Mr. Jason`)
        prevDamage = event.damage;
        event.damage *= 1 - Math.min(0.08 * elementalProtectionCount, 80)
        victim.tell(`Test 2: ${prevDamage} ${event.damage}`)
    }
})```
zenith lantern
autumn mist
#

you cant change damage value in kjs event

#

search relative tickets in support channel

zenith lantern
#
    const victim = event.entity;
    var elementalProtectionCount = 0
    var ruptureProtectionCount = 0
    var projectileProtectionCount = 0

    let armorPieces = [
        victim.getHeadArmorItem(),
        victim.getChestArmorItem(),
        victim.getLegsArmorItem(),
        victim.getFeetArmorItem()
    ].forEach((piece) => {
        if (piece.id != "minecraft:air") {
            elementalProtectionCount += piece.getEnchantments().get('minecraft:fire_protection')
            ruptureProtectionCount += piece.getEnchantments().get('minecraft:blast_protection')
            projectileProtectionCount += piece.getEnchantments().get('minecraft:projectile_protection')
        }
    })
    if ([
        "freeze",
        "cactus",
        "in_wall",
        "falling_stalactite",
        "stalagmite",
        "sweet_berry_bush"
    ].includes(event.source.getType())) {
        victim.heal(event.damage * Math.min(0.08 * elementalProtectionCount, 80))
    }
})```
#

i looked around for other damage related tickets but its hard for me to look through every thread

zenith lantern
autumn mist
#

oops, didnt notice that

#

fabric cant change damage

#

the only thing you can do is heal the player

zenith lantern
#

kk

#

well i guess this is resolved