Started by
Constant Constantine
on
Topic category: Help with Minecraft modding (Java Edition)
Basically, I want a procedure to run only when the player joins the world for the first time.. (Meaning if they rejoin the same world, the procedure doesn't run again.)
For context, the mod I'm making lowers the player's max health to 1 point and only a certain item can increase their max health. This means I don't want their max health to be reset back to 1 point upon rejoining the world.
Post-solved edit: Fixed the wording of the first sentence. Original wording was confusing.
Edited by Constant Constantine on Mon, 07/10/2023 - 22:05
A basic idea untested idea, you can try using nbt tag to save a logic variable in a player. Then check it every time player joined.
I literally have no idea how to do that.
bump
Try creating a global "logic" variable (scope: GLOBAL_MAP) that starts out as "false", and then have a procedure whose global trigger is "on player tick update". If the variable is false, reduce the player's max health and set the variable to true. This way, it only happens the first time the player joins.
There is a procedure trigger called "Player joins"
@sillypantscoder Please show me an example, because I don't quite understand what you mean. Because the procedure I made will just set the variable back to false every single tick and thus, make the procedure run again. Even if I set it to "Player Joins World," it will still set the variable back to false.
bump, again...
I will create an example.
@SpyCoder77 Okay, please show me it as soon as you can.
once u go to create a procedure event trigger- that says no additional trigger change that to player joins world
maybe a player persistent variable
https://drive.google.com/file/d/1H2wWh7TFhmVRXz7OxpDJXA7ADXHcFATp/view?…
@lavadabman Thanks, I plugged in the "player_join" variable as a player persistent variable into the procedure that Sillypantscoder suggested and then tweaked it to my liking. It works in the way I wanted it to, perfectly. Though I wasn't sure how to use the "player_heart" variable to change the player's max health, so I just had the procedure change it via /attribute. Nonetheless, I'm happy with how it works, now.
@SpyCoder77 I really must apologize for failing to mention that I already had the trigger set to "player joins" beforehand. That being said, it takes more than just that trigger to make a procedure run only on the first time that a player joins the world, not every single time. You only suggested to change the trigger to "player joins" and didn't give me any information related to rest of what I wanted.
if it's on a server, is it possible to make it check if a certain player joined for the first time? because this will basically be "when a player joins for the first time, do something, then never run again even if its a different player"