AppleCore

AppleCore

56M Downloads

Add access to max foodLevel.

primetoxinz opened this issue ยท 6 comments

commented

I would like to port Better With Mods Hardcore hunger over to AppleCore entirely.
To do this without overwriting EntityPlayer.foodStats, a method to changing the maximum for FoodStats.foodLevel.
There are multiple places where the maximum is in effect, including
this.foodLevel = Math.min(foodLevelIn + this.foodLevel, **20** );
and
public boolean needFood() { return this.foodLevel < **20**; }

I'm willing to make the PR if need be, but I'm not exactly sure how you'd want it implemented.

Additionally, an event called on FoodStats::addExhaustion would be with parts of this.

commented

Sorry for not following up on this the last time I mentioned it. I began implementing this quite a while ago and now forget why I didn't finish it (I remember kinda getting tripped up by something but not sure what it was).

I pushed my WIP branch here if you want to give feedback on the implementation: https://github.com/squeek502/AppleCore/tree/1.10.2-max-hunger

commented

I after attempting to run that branch, I found the problem you ran into.
When trying to replace the int for the vanilla max with the lookup from GetMaxHunger it throws
java.lang.ClassCastException: org.objectweb.asm.tree.IntInsnNode cannot be cast to org.objectweb.asm.tree.VarInsnNode. Guess it doesn't like trying to replace one with the other. I don't know enough about java bytecode to fix that.

commented

Ok, it seems like simply changing the VarInsNodes to IntInsNodes worked haha. So, GetMaxHunger is correctly working, yet the hunger bar doesn't scale by default in AppleCore, not sure if you are worried about that; I am going to render the hunger bar custom either way, so it doesn't really matter for HCHunger

commented

Yeah I think AppleCore should scale the HUD accordingly, will work on that (but it will still use only the 1/2 and full hunger icons so it won't be as precise as BWM's).

commented

Thanks!
A port of those changes to 1.11.2 (and hopefully 1.12 soon) would be most appreciated :)

commented

Will do.