#how do i customize entity armor with EntityJS?
15 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
I summon thee @alpine wharf
i've risen yet again
you can do that via the entity attributes startup event```js
EntityJSEvents.attributes(event => {
event.modify('minecraft:allay', attribute => {
attribute.add("minecraft:generic.max_health", 30)
attribute.add("minecraft:generic.armor", 10)
attribute.add("minecraft:generic.armor_toughness", 2)
})
})
thanks ❤️
yup, you can also do this dynamically via the entity spawned server event js EntityEvents.spawned(event => { let /** @type {Internal.LivingEntity} */ entity = event.entity if (entity.type == "minecraft:allay") { entity.setMaxHealth(30) entity.setHealth(30) entity.getAttribute("minecraft:generic.armor").setBaseValue(10) entity.getAttribute("minecraft:generic.armor_toughness").setBaseValue(2) } })
You can also do on that script
const toBeChanged = ["minecraft:allay", "minecraft:zombie"] // A list of entities
EntityJSEvents.attributes(event => {
// Go thru each item
toBeChanged.forEach(item => {
event.modify(item, attribute => {
attribute.add("minecraft:generic.max_health", 30)
attribute.add("minecraft:generic.armor", 10)
attribute.add("minecraft:generic.armor_toughness", 2)
}
})
})
yup, a list is also possible
is there another way i can directly override entity health on startup
without adding to its base stats
yup, modifies the attributes directly
Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue!
This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.
Do you have any other questions regarding your issue? Feel free to ask!
Note: You should create a new post for unrelated issues.