#how can i make a function that runs every time the player spawns
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 While you wait, take this time to provide more context and details.
🙇 If nobody has answered you by <t:1748005863:t>, feel free to use the Summon Helpers button to ping our helper team.
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
you can make this grace period by checking the time_since_last_death statistic.
you have to add that scoreboard beforehand for the statistic to update that scoreboard automatically
first you have to add it in your load function.
scoreboard objectives add time_since_last_death
the name might be a bit different, i can't remember
idk how origin files are structured though
are conditions just predicates?
i don't know what predicates means
but you can add your own stuff in tha code, it doesn't need to have the "origins:"
predicates are just a bunch of conditions that can be referred to in a command, advancements, etc.. and they return either true or false
do you know what those files are in the conditions field?
if you could send the code of one of the files I can see what file type it is.
have the full thing
yeah, but that doesn't contain the origins:exposed_to_sun file
i think that is just included in the mod tbh
i mean the original origins mod
do you really need that?
I at least need to know if they are predicates or some kind of special origins condition check file
alright
if they are predicates, you can just add your own, if not, you have to make a weird and probably janky workaround (unless origin adds different stuff for that which idk)
i think they should be predicates as you say, cuz in the interface their is an option for custom conditions
You can then make a pretty simple value check predicate
like this?
not the id of the statistic, but the name you gave the objective
in that field, you have to put this part scoreboard objectives add >>>grace_timer<<< time_since_last_death or whatever you called it. Not just any random name.
after that, you save the file and put the id to it in the list of conditions.
so like
scoreboard objectives add >>>grace_timer<<< My_First_Ever_Thing
no, the arrow were there to indicate the thing that I meant
👌 understandable
grace_time is the name in the example
like this?
scoreboard objectives add My_First_Ever_Thing time_since_last_death
yea
now what?
.
a
doing that now
question
what happens when the player first joins, where he hasn't ever died, so they don't have a time_since_last_death value?
and what happens when a player dies in a server, and then leaves? does the value keep counting?
also, what happens while the player is sitting in the death screen? does the value keep counting up?
- The value starts from 0 and constantly counts up. It just resets when you die.
- It only counts up if the player is online
- It only starts counting again when you pres respawn.
majestic
testing it rn
wait, i'm stubid
i forgot to paste the new function file in the datapack
no
i just get the regular 3 secs or so of on spawn invulnerability
hmm, maybe someone who knows origins can better help.
you think i've done goofed up with the mins?
i am 1000% certain i just did something silly
I something very silly
in the score filed you are supposed to ONLY put the name of the score
not the whole command that creates the scoreboard
my custom one or the vanila
👌 .
i feel like this is a lot better
noticed here you had {Target Enum This}, so i changed my bit accordingly
looks correct now
question
how does my custom value relate to the "time_since_last_death" value?
since it ain't writen anywere in the code, how does it connect
it checks if value (your current score) is in the specified rang (1200 or more)
or what do you mean with custom value?
i mean the "My_First_Ever_Thing" value
how is it linked to the player's "time_since_last_death"
when you create that scoreboard it just reflects the statistics of the players
every player has their own score value in that scoreboard
My_First_Ever_Thing is just the name you gave the scoreboard with the type time_since_last_death
you can have multiple scoreboard with the same type and that's why you name them.
Still with the same command in your load function -> scoreboard objectives add <scoreboard name> <scoreboard type>
do i need to run that command manually?
like how does that work
do you now what a load function is?
no
there are two special function types in minecraft
- tick: runs once every tick
- load: runs every time you enter the world/start up the server or whne /reload is used
View this guide on datapack.wiki: https://datapack.wiki/guide/getting-started/
do i just make an empty function with just the command?
there is more to it than just a function file. I suggest you take a look at this. It is not very long and the relevant part is even shorter, so it really doesn't take that long.
alright
i'm giving up and becoming an apple farmer
have a nice day and thank you for tolerating my incompetent ass
?