#how to use EntityEvents.hurt and healing entity after?

21 messages · Page 1 of 1 (latest)

wind turret
#

im not sure how to use this bit of code, there arent really any guides ;-;

midnight rockBOT
#

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

cold mason
#

so what do u want to do? more context

wind turret
#

there is an entity melting in a tinkers smeltery, i cant set the damage to 0 or else it wont work, but i dont want the entity to die

#

event.custom({
"type": "tconstruct:entity_melting",
"entity": {
"types": [
'create_confectionery:little_gingerbread_man'
]
},
"result": {
"fluid": "kubejs:essence_of_whimsy",
"amount": 40
},
"damage": 1
})

#

for context of code for melting

cold mason
#

@wind turret

#
EntityEvents.hurt(e=> {
    console.log(e.damage)
    if ((e.source.getType() == "tconstruct.smeltery_magic" || e.source.getType() == "tconstruct.smeltery_heat") && !e.entity.player) {
        e.entity.heal(e.getDamage())
    }
})
wind turret
#

oh?

cold mason
#

this works for all entity, except player

wind turret
#

i see

#

is there a way for a specific entity?

cold mason
#

yeah, hold on

#

here

#
const entity_list = ["minecraft:blaze", "minecraft:polar_bear"]

EntityEvents.hurt(e=> {
    if (entity_list.includes(e.entity.type)) {
        if (e.source.getType() == "tconstruct.smeltery_magic" || e.source.getType() == "tconstruct.smeltery_heat") {
            e.entity.heal(e.getDamage())
        }
    }
})
wind turret
#

thank you so much! :D

#

i shall test to see if it works

#

it works flawlessly! holy

#

thank you again!

cold mason
#

have a nice day