#how do i make it so regeneration works on undead mobs?
1 messages · Page 1 of 1 (latest)
it's a bit janky but you could use scoreboards
to do regeneration without effects, you could
- code a cooldown so that the following only occurs every 20 ticks or however many you choose
- store the mount's health in a scoreboard
- add 1 to the scoreboard value
- store the scoreboard value in the mount's health
how would i store the mount's health?
wouldnt i have to check its nbt which is bad for performance?
you could use execute store result score @s [scoreboard name] run data get entity @s Health
it is an expensive operation but at least it wouldnt be every tick
i could try it tommorow if i dont think of any other solution, they regen naturally but very slowly, would it be possible to change that?
I doubt that - afaik the natural mount regen is hardcoded
unfortunately health regen is one of the few things we have little control over. I have for some time wanted to create an armor set with slight regeneration and healthboost when worn but the regeneration is either the effect (which would make other items obsolete) or impossible.
You can make an if statement that just gives them poison instead. Theoretically, and iirc, undead creatures regen from the poison potion effect
they are immune, it does not work as regen... in fact they can't be poisoned at all
Huh! That's on me for expecting minecraft to be consistent
the only sensible workaround for non-players would be to directly modify their health in a function by using commands.
health in general is pretty weird in its behavior, you can have 10/10 hearts yet not be full health
you don't see the difference between 20.0f and 19.Xf health
you can damage a player for 0.99999 and they will still see 10 full hearts while they are practically already at 9.5 hearts.
Zombie ans Skeleton Horses have different max health too
I guess the most sensible way would be to also get their max_health attribute
iirc max_health is respected when you modify health
the only time max_health can be lower than Health is when the max_health itself was modified. you cant set health over the max_health attribute directly using data modify
You also can just give then instand damage effect
Bc undead mobs heal from it
Yea
But i think you'll need only one heart per second
Like
I think the way regeneration works on higher levels is that it still heals 1 heart just it does it faster
When you have regeneration you can see them "jump", when they "jump" they regenerate
So yea, i think effect give @s minecraft:instant_damage 0 will do it
I would probably just have a function to set their health.
instant effects start at 3 health or 1.5 hearts.
for players it is about the only way to do this, for mobs, not so much
Huh, i didn't know that
formula is: 3 * 2 ^ level
actually instant health has 2 * 2 ^ level according to the wiki, but I recall seeings 1.5 hearts going up (could be rounding related again)
pretty sure i tried that already and it doesnt work, only the splash potions of instant damage work
you can directly apply the effect on the entity and it will work
but it will heal them 3 health or 1.5 hearts
while you can also just store their health in a score, add 1, store score into their health
i figured it out, thanks!