#How to double entity base health?
42 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
How to double entity base health?
okay got the list using alembic and a little ai help to clean it up
now I dont really know how to get base hp of a mod so I can double it
Ye
I want to double their base max health
I had a script to double it on spawn but that had a weird interactions sometimes
EntityJSEvents.attributes(e => {
e.modify('minecraft:zombie', attribute => {
const default_health = attribute.defaultValues.get('minecraft:generic.max_health');
attribute.add('minecraft:generic.max_health', default_health*2);
})
})
i guess
[15:00:15] [ERROR] ! entities.js#4: Error in 'EntityJSEvents.attributes': TypeError: Cannot call method "get" of undefined
Weird
are you telling me to report a bug or that the answer is here and I cant see it? because I read it couple of times before and I have no idea how to get the max health attribute from this
EntityJSEvents.attributes(e => {
e.getAttributes('minecraft:zombie').get('minecraft:generic.max_health').defaultValue
})
oh yeah I had no idea how to filter for max health thank you!
there is another issue tho
1) entities.js#3: Error in 'EntityJSEvents.attributes': Cannot convert minecraft:generic.max_health to java.lang.Integer```
did it output the name of the attribute instead of the value?
EntityJSEvents.attributes(e => {
const default_health = e.getAttributes('minecraft:zombie').get('minecraft:generic.max_health').defaultValue
e.modify('minecraft:zombie', attribute => {
attribute.add('minecraft:generic.max_health', default_health*2);
})
})
e.getAttributes('minecraft:zombie').filter(a => a.descriptionId == 'minecraft:generic.max_health').defaultValue
lmao this set every zombie to one health
how did that happend
EntityJSEvents.attributes(e => {
let default_health = e.getAttributes('minecraft:zombie').filter(a => a.descriptionId == 'minecraft:generic.max_health').defaultValue
console.log("debuging"+default_health)
e.modify('minecraft:zombie', attribute => {
attribute.add('minecraft:generic.max_health', default_health*2);
})
})
[18:18:17] [Render thread/INFO]: entities.js#4: debugingundefined
seems like it still not a number lol
@dense arch something like this js EntityJSEvents.attributes(event => { event.getAllTypes().forEach(entity => { event.modify(entity, a => { event.getAttributes(entity).forEach(attribute => { if (attribute.descriptionId == "attribute.name.generic.max_health") { a.add(attribute, attribute.defaultValue * 2) } }) }) }) })
should iterate over all entities which have health
is it possible that it quadruples animal health because there is also a baby version of them?
weirdly zombies do have 53 hp but maybe its some mode interaction
the calculations should be after their base attributes to babies
the baby health is calculated based off the base attributes registered on startup
maybe a mod is adding varied zombie health, either that or theres some spawn bonus
though i think thats only for horses ect
okay thats no big deal gonna check if this:
EntityJSEvents.attributes(event => {
event.getAllTypes().forEach(entity => {
if(!entity.isPlayer()){
event.modify(entity, a => {
event.getAttributes(entity).forEach(attribute => {
if (attribute.descriptionId == "attribute.name.generic.max_health") {
a.add(attribute, attribute.defaultValue * 2)
}
})
})
}})
})
Works for excluding a player
well it does not
how else could I do it?
you want something like this js let EntityTypes = Java.loadClass("net.minecraft.world.entity.EntityType") EntityJSEvents.attributes(event => { event.getAllTypes().forEach(entity => { event.modify(entity, a => { if (entity == EntityTypes.PLAYER) return event.getAttributes(entity).forEach(attribute => { if (attribute.descriptionId == "attribute.name.generic.max_health") { a.add(attribute, attribute.defaultValue * 2) } }) }) }) })
works perfectly! Thank you so much ❤️