Skip to content

Commit

Permalink
Fix math & Update github link
Browse files Browse the repository at this point in the history
  • Loading branch information
milkev committed Jul 19, 2023
1 parent 0f00de9 commit 4e3c663
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void eatFood(World world, ItemStack itemStack, CallbackInfoReturnable<Ite

//Reference;
//Max hunger = 20
//Max saturation = 40
//Max saturation = 20

if(!world.isClient) {
PlayerEntity thisO = ((PlayerEntity) (Object) this);
Expand All @@ -30,11 +30,20 @@ public void eatFood(World world, ItemStack itemStack, CallbackInfoReturnable<Ite
FoodComponent thisFood = itemStack.getItem().getFoodComponent();

if (thisHunger.getFoodLevel() + thisFood.getHunger() >= 20) {
float totalSaturation = thisHunger.getSaturationLevel() + thisFood.getSaturationModifier() * (float)40;
if (totalSaturation > (float)40) {
//no, i dont know why its 39.5... from my tests, this simply resulted in getting the correct saturation amount after overflowing into fullness & healing
totalSaturation = totalSaturation - (float)39.5;

float totalSaturation = thisHunger.getSaturationLevel() + thisFood.getSaturationModifier() * thisFood.getHunger() * 2;

//System.out.println("Saturation total is: " + totalSaturation);
//System.out.println("Saturation modifier of eaten food: " + thisFood.getSaturationModifier());

if (totalSaturation > (float)20) {

//System.out.println("Saturation overflowed, total: " + totalSaturation);

totalSaturation = totalSaturation - (float)20;

//System.out.println("Overflowing " + totalSaturation + " Saturation into meal api fullness!");

PlayerFullnessUtil.instance().setPlayerFullness(thisServerPlayer,
PlayerFullnessUtil.instance().getPlayerFullness(thisServerPlayer) + Math.round(totalSaturation));
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"contact": {
"homepage": "",
"sources": "https://github.com/milkev/"
"sources": "https://github.com/milkev/Meal-API-Addon"
},

"license": "CUSTOM LICENSE",
Expand All @@ -32,6 +32,7 @@
"fabricloader": ">=0.14.8",
"fabric": "*",
"fabric-key-binding-api-v1": "*",
"mealapi": ">=0.3.2",
"minecraft": "1.20.x"
},
"suggests": {
Expand Down

0 comments on commit 4e3c663

Please sign in to comment.