This is purely a example script for custom potions with custom effects. This is not so much about tough as nails but I might as well explain that right?
https://tenor.com/view/anime-tired-lucky-star-tired-anime-gif-1495236166145253179
#Custom Potions with Custom Effects and Modded Support for Tough As Nails Thirst.
15 messages · Page 1 of 1 (latest)
Paste version of server.log, LifebloodAlchemy.js from @coarse pendant
[➤](#1282743289417564171 message)
let $PotionBuilder = Java.loadClass("dev.latvian.mods.kubejs.misc.PotionBuilder")
function potionRegist(e, id, durationInSeconds){
e.createCustom(id, () => {
return new $PotionBuilder(id)
.effect(`kubejs:${id}`, durationInSeconds * 20, 0)
.createObject()
})
}
StartupEvents.registry("potion", e => {
potionRegist(e, 'blast_immunity', 5);
})```
I've noticed that for some reason "entity.age" keeps going forward and backwards as a value, probably because of client-server de-synchronizations, but anyways I've solved it by using "entity.server.tickCount" instead.
Before it would run the code twice
Hello, I don't think understand what you meant by posting this message here?
I see now
if (entity.age % 20 != 0 || !entity.isPlayer()) return;
Well I think it's fine that it goes forward or backwards because modulo makes it wrap around regardless but I do see your point
I think the reason I did it from the entity age was likely because I thought the poition would be tied to the entity not the server.

Yeah I think that's about it with also that server might not be available.
What I meant is that I tried to make an effect that subtracts one heart from the player each 600 ticks, but instead it would first subtract one heart, and then after a small delay subtract another one, so two hearts each 600 ticks.
I tried printing the raw "entity.age" value at the start of the function, and the result was something like:
200
220
201
221
202
222
etc.
It was jumping back and forth, like if there were two counters conflicting with each other
After using entity.server.tickCount the problem disappeared.
I don't know the details of this, and neither do I know what are best practices, I'm still learning KubeJS and I'm not used at all to Minecraft modding.
But since this solved the problem for me I thought it would be a good idea to post it here.
I don't know if it causes any other problems, but it worked for me
