#Two options for capping a certain mob's health
12 messages · Page 1 of 1 (latest)
The XY problem is when you really want to do X, and you think that Y can achieve X. However, you can't get Y to work, and so ask for help exclusively about Y.
This can lead to a lot of confusion from the people trying to help you, as Y can seem like a very random thing to want to do, and a lot of the time isn't the best way to achieve X anyway.
Its fine to ask about Y, just always include some context about X so you can be put on the right track if Y won't do X well, or there is an easier way to do X.
how did you make a zombie that has that many health
and:
a. yes, but mostly on the event itself
b. depends on the question above
EntityEvents.spawned('minecraft:zombie', e => {
e.entity.maxHealth = 19
})
or
const capHealth = {
'minecraft:zombie': 19
}
Object.keys(capHealth).forEach(key => EntityEvents.spawned(key, e => e.entity.maxHealth = capHealth[key]))
the second one is more suitable for multiple entities
idk, it shouldnt do anything on render thread
my scirpt is faster than the original one
it uses a event that fires on entity spawn, with extra argument
this should work better:
const capHealth = {
'minecraft:zombie': 19
}
Object.keys(capHealth).forEach(key =>
EntityEvents.spawned(key, e => {
const data = capHealth[key];
const {entity} = e;
if(entity.maxHealth > data) entity.maxHealth = data;
})
)
it's already fast enough