How would I add a Thirst requirement and bar

Started by GreensilverMega on

Topic category: Help with Minecraft modding (Java Edition)

Active 1 week ago
Joined Dec 2022
Points:
465

User statistics:

  • Modifications: 5
  • Forum topics: 18
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 59
How would I add a Thirst requirement and bar

I am working on a mod and I want to add thirst as a requirement to survive. You can purify it to replenish your thirst better but I don't know how to make a thirst bar above the hunger bar and I don't know how to make it work. It would be so appreciated for my Horror Mod 

Active 3 weeks ago
Joined Oct 2022
Points:
405

User statistics:

  • Modifications: 1
  • Forum topics: 9
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 41
Maybe with an overlay that…
Sun, 12/17/2023 - 21:10

Maybe with an overlay that has display conditions based on a variable. 

Like, create 10 overlays for each level of thirst and set their display conditions depending on the variable. 

Active 1 year ago
Joined Nov 2023
Points:
489

User statistics:

  • Modifications: 0
  • Forum topics: 36
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 343
you prb will need a Global…
Mon, 12/18/2023 - 00:17

you prb will need a Global Var (Player Lifetime) - this will save when u leave the world and reset when the player dies, then:

  • make a procedure (OnPlayerTickUpdate) - to timer your thrist decays and also to modify the value here when player drink water, make a Return of that variable on the end of the procedure
  • make a procedure to Return the current value (from the last procedure) of the Variable (thrist) so u can display on the Overlay

    let me know if u made it work, i made a bank acount system like that (mine is player persistent thou, so wont reset on player death) but the rest its the same i think, i might be able to help you more :)

Active 1 year ago
Joined Nov 2023
Points:
489

User statistics:

  • Modifications: 0
  • Forum topics: 36
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 343
and no you dont need 10…
Mon, 12/18/2023 - 00:18

and no you dont need 10 overlays, all u need is to Return the Current value of the Thrist variable on the overlay, work with my variable so should work for you :)

Active 1 year ago
Joined Nov 2023
Points:
489

User statistics:

  • Modifications: 0
  • Forum topics: 36
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 343
for your thirst bar u need…
Mon, 12/18/2023 - 00:22

for your thirst bar u need to make 10 images (1 display on each condition - bar 25%, 50% and so on, so u need 10 bars over each other on the Same overlay), like condition 1 -> if Return value (current thrist) = max value (full bar) /  5 = 20% so this will display the bar at 20% for example, i also made this for fuel and energy bars so principle is the same, but instead of Return current energy you return the current thrist (global var)

Active 1 year ago
Joined Nov 2023
Points:
489

User statistics:

  • Modifications: 0
  • Forum topics: 36
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 343
clarifying - 10 images for…
Mon, 12/18/2023 - 00:23

clarifying - 10 images for bars that go 10% for condition

5 images - 20% per conditions and so on

Active 3 weeks ago
Joined Oct 2022
Points:
405

User statistics:

  • Modifications: 1
  • Forum topics: 9
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 41
Yes, 10 images, not 10…
Mon, 12/18/2023 - 12:34

Yes, 10 images, not 10 overlays, thanks for the correction. 

Active 1 week ago
Joined Dec 2022
Points:
465

User statistics:

  • Modifications: 5
  • Forum topics: 18
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 59
Thanks for the help I found…
Mon, 12/18/2023 - 15:17

Thanks for the help I found a tutorial on youtube for the bar but now I just need the part where it drains every 2 minutes, any ideas?

Active 1 week ago
Joined Dec 2022
Points:
465

User statistics:

  • Modifications: 5
  • Forum topics: 18
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 59
Thanks Klemen!
Mon, 12/18/2023 - 19:57

Thanks Klemen!

Active 1 week ago
Joined Dec 2022
Points:
465

User statistics:

  • Modifications: 5
  • Forum topics: 18
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 59
Wait nevermind it won't let…
Mon, 12/18/2023 - 20:17

Wait nevermind it won't let me save it because it says this

it says this: On world tick update global trigger is tick event based. Keep in mind that running to complex or demanding procedures each tick can impact game performance

Active 1 week ago
Joined Dec 2022
Points:
465

User statistics:

  • Modifications: 5
  • Forum topics: 18
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 59
   
Mon, 12/18/2023 - 20:28

aa

 

 

Active 3 weeks ago
Joined Oct 2022
Points:
405

User statistics:

  • Modifications: 1
  • Forum topics: 9
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 41
Try on player tick update. 
Tue, 12/19/2023 - 12:53

Try on player tick update. 

You can save anyway, this is…
Wed, 12/20/2023 - 19:50

You can save anyway, this is warning only:

On world tick update global trigger is tick event based. Keep in mind that running to complex or demanding procedures each tick can impact game performance

Active 1 year ago
Joined Nov 2023
Points:
489

User statistics:

  • Modifications: 0
  • Forum topics: 36
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 343
yeah its a warning so people…
Thu, 12/21/2023 - 01:50

yeah its a warning so people know if they start to put A LOT of stuff on world/player ticks off course the game might lag (fps drop) - btw u should use OnPlayerTickUpdate (since its a player variable) instead of OnWorldTickUpdate, less heavy