Posted January 27, 20169 yr I understand the base of how to acquire the player's FoodStats, but I would like to know how it works. Does FoodStats#addExaustion() affect it's drain speed? Or is there a better way of doing this? I simple example would be very helpful. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
January 27, 20169 yr Kind of. For my own purposes, adding exhaustion was sufficient, as once that reaches 0, hunger begins to deplete, and adding more exhaustion will deplete the hunger bar directly. So if you wanted a faster hunger bar drain, you could add 0.1F exhaustion (or however much) every so often and it would basically have the effect you want. http://i.imgur.com/NdrFdld.png[/img]
January 27, 20169 yr See: http://minecraft.gamepedia.com/Hunger#Mechanics Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 27, 20169 yr Author Thank you both, I realized I was on peaceful when testing, so the hunger bar wouldn't deplete. I do have a question about the implementation though: I use it in the #LivingUpdateEvent, and was wondering how I could do this with my weight variable. Should I create a timer that is affected by the player's current weight? Or do some math in order to determine how much exhaustion to add with the weight? I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
January 28, 20169 yr Well that depends: how do you want it to work? Either way you'll be doing math, and either way there should be a timer of some sort involved or else the player's hunger will go down pretty darn quick. Btw, why use LivingUpdateEvent when the only ones with hunger are players? This is what PlayerTickEvent is for. http://i.imgur.com/NdrFdld.png[/img]
January 28, 20169 yr Author Most of my update has been in LivingUpdate, will switch over here soon. My only problem is creating a timer within an update event. Seems the timer will always be reset, which is not what someone wants at all. Even though this is basic java, could you give an example on how I would start with a timer in a tick event? I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
January 28, 20169 yr Your tick event is handled in a class, is it not? And classes can have class members, can they not? So make your timer a class member, and simply update it in the tick counter. Or use player.ticksExisted, which is already a timer. http://i.imgur.com/NdrFdld.png[/img]
January 28, 20169 yr Or put it in player's IEEP if you need separate timer. 1.7.10 is no longer supported by forge, you are on your own.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.