0

I am trying to create a stamina system for a mini-game, but I just can't seem to get it to work properly. I can't use the exp bar, as that is already being used for a magic bar that I have up and running. I am trying to use the hunger bar. I have gotten the regen feature to work, but the problem is when it comes to draining it. Currently I have it so jumping and sprinting drain your stamina using the hunger effect, the problem though is that when the player jumps it gives them the hunger effect and won't take it away when the stop. The second issue is that it won't give the hunger effect for sprinting as I need to constantly reset it to make sure if the player is resting or sprinting. I want to know if there is a way to test if the player is not moving or just walking. Just testing for those two things would allow me to make the stamina system a lot easier to control. The scoreboards I am using are:

staminaRegen dummy
staminaUsage stat.sprintOneCm
staminaUsageAir stat.jump
Resting stat.sneakTime
1

you should reset the objective every time you applied the hunger effect, like so:

/effect @a[score_staminaUsage_min=1] minecraft:hunger 1 1 true
/scoreboard players set @a[score_staminaUsage_min=1] staminaUsage 0

same for the staminaUsageAir.

this way you can give the hunger effect only when a player sprints or jumps.


Here is another tip: if you're okay with your player regenerating hunger whenever he's not loosing, you could for example put this command on a clock:

/effect @a minecraft:saturation 1 0

this will regenerate half a cone each time it is activated (20 times a second: full bar in one second. once per second: full bar in 40 seconds).
then just put the hunger effect above it while they run (with a high amplifier, like 200) and bam, system complete.

3
  • Okay, I like the idea you are going for, but it sounds like they will only receive the effect upon death? If so, that isn't exactly what I am going for. I am trying to make a hunger system so that when the player is doing strenuous movement, such as jumping or sprinting, they are given the hunger effect so that their stamina drains faster. The second idea seems smart. To give them a large hunger effect while sprinting or jumping while they are also constantly receiving a low saturation effect. I will try that and see how it works. – TrueDakkon Feb 4 '17 at 7:44
  • UPDATE: Works really well. I have a clock running every 30 ticks to regen and give them a hunger effect of 100 as to not have it drain super quickly. Now I just need a way to incorporate special moves that drain stamina. – TrueDakkon Feb 4 '17 at 8:08
  • Whoops, I didn't mean to write death in there. Fixed. Also I'm happy that it works for you. :) – Plagiatus Feb 5 '17 at 22:12
0

Although I am incredibly late to this, I might have another option.

With the /bossbar command added in the Aquatic Update, you can control the bar up top where Withers' and Ender Dragons' health would show up. I don't have any experience using it, although I can tell you that the properties of it are the amount filled (of a configurable maximum) and the color of it.

Oh, also, you can have multiple boss bars for multiple people with different IDs.

1
  • I am interested in your idea behind how to do it and would like to know as it could be useful if I decide to get back into commandblock minigames. – TrueDakkon Aug 31 '19 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.