From 044e0c9f624f971995edb3f6cd6242664bb9ece5 Mon Sep 17 00:00:00 2001 From: Enderaoe Date: Thu, 11 Nov 2021 00:24:55 +0800 Subject: [PATCH] fix saturation max --- .../nossr50/listeners/EntityListener.java | 16 ++-- .../com/gmail/nossr50/util/ItemUtils.java | 80 +++++++++---------- .../gmail/nossr50/util/skills/SkillUtils.java | 5 +- 3 files changed, 52 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 9628a3a55..743ad6aa7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -914,12 +914,6 @@ public class EntityListener implements Listener { return; //Not Food } - Float foodSaturation = ItemUtils.getFoodSaturation(foodInHand); - - if (foodSaturation != null) { - newSaturationLevel = currentSaturationLevel + foodSaturation; - } - /* * Some foods have 3 ranks Some foods have 5 ranks The number of ranks * is based on how 'common' the item is We can adjust this quite easily @@ -928,7 +922,7 @@ public class EntityListener implements Listener { //Hacky 1.17 support if(foodInHand.getKey().getKey().equalsIgnoreCase("glow_berries")) { - newSaturationLevel = currentSaturationLevel + 0.4F; + newSaturationLevel = currentSaturationLevel + 0.2F; if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) { event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDietHunger(newFoodLevel)); player.setSaturation(UserManager.getPlayer(player).getHerbalismManager().farmersDietSaturation(newSaturationLevel)); @@ -937,6 +931,14 @@ public class EntityListener implements Listener { return; } + Float foodSaturation = ItemUtils.getFoodSaturation(foodInHand); + + if (foodSaturation != null) { + newSaturationLevel = currentSaturationLevel + foodSaturation; + } else { + return; //Food unknown + } + switch (foodInHand) { case BAKED_POTATO, BEETROOT, BREAD, CARROT, GOLDEN_CARROT, MUSHROOM_STEW, PUMPKIN_PIE, COOKIE, MELON_SLICE, POISONOUS_POTATO, POTATO -> { if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) { diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index 1bd361de3..e5e5f9828 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -34,46 +34,46 @@ public final class ItemUtils { private static final HashMap foodSaturation = new HashMap<>(); static { - foodSaturation.put(Material.APPLE, 2.4F); - foodSaturation.put(Material.BAKED_POTATO, 6.0F); - foodSaturation.put(Material.BEETROOT, 1.2F); - foodSaturation.put(Material.BEETROOT_SOUP, 7.2F); - foodSaturation.put(Material.BREAD, 6.0F); - foodSaturation.put(Material.CAKE, 0.4F); - foodSaturation.put(Material.CARROT, 3.6F); - foodSaturation.put(Material.CHORUS_FRUIT, 2.4F); - foodSaturation.put(Material.COOKED_BEEF, 12.8F); - foodSaturation.put(Material.COOKED_CHICKEN, 7.2F); - foodSaturation.put(Material.COOKED_COD, 6.0F); - foodSaturation.put(Material.COOKED_MUTTON, 9.6F); - foodSaturation.put(Material.COOKED_PORKCHOP, 12.8F); - foodSaturation.put(Material.COOKED_RABBIT, 6.0F); - foodSaturation.put(Material.COOKED_SALMON, 9.6F); - foodSaturation.put(Material.COOKIE, 0.4F); - foodSaturation.put(Material.DRIED_KELP, 0.6F); - foodSaturation.put(Material.ENCHANTED_GOLDEN_APPLE, 9.6F); - foodSaturation.put(Material.HONEY_BOTTLE, 1.2F); - foodSaturation.put(Material.GOLDEN_APPLE, 9.6F); - foodSaturation.put(Material.GOLDEN_CARROT, 14.4F); - foodSaturation.put(Material.MELON_SLICE, 1.2F); - foodSaturation.put(Material.MUSHROOM_STEW, 7.2F); - foodSaturation.put(Material.POISONOUS_POTATO, 1.2F); - foodSaturation.put(Material.POTATO, 0.6F); - foodSaturation.put(Material.PUFFERFISH, 0.2F); - foodSaturation.put(Material.PUMPKIN_PIE, 4.8F); - foodSaturation.put(Material.RABBIT_STEW, 12.0F); - foodSaturation.put(Material.BEEF, 1.8F); - foodSaturation.put(Material.CHICKEN, 1.2F); - foodSaturation.put(Material.COD, 0.4F); - foodSaturation.put(Material.MUTTON, 1.2F); - foodSaturation.put(Material.PORKCHOP, 1.8F); - foodSaturation.put(Material.RABBIT, 1.8F); - foodSaturation.put(Material.SALMON, 0.4F); - foodSaturation.put(Material.ROTTEN_FLESH, 0.8F); - foodSaturation.put(Material.SPIDER_EYE, 3.2F); - foodSaturation.put(Material.SUSPICIOUS_STEW, 7.2F); - foodSaturation.put(Material.SWEET_BERRIES, 0.4F); - foodSaturation.put(Material.TROPICAL_FISH, 0.2F); + foodSaturation.put(Material.APPLE, 1.2F); + foodSaturation.put(Material.BAKED_POTATO, 3.0F); + foodSaturation.put(Material.BEETROOT, 0.6F); + foodSaturation.put(Material.BEETROOT_SOUP, 3.6F); + foodSaturation.put(Material.BREAD, 3.0F); + foodSaturation.put(Material.CAKE, 0.2F); + foodSaturation.put(Material.CARROT, 1.8F); + foodSaturation.put(Material.CHORUS_FRUIT, 1.2F); + foodSaturation.put(Material.COOKED_BEEF, 6.4F); + foodSaturation.put(Material.COOKED_CHICKEN, 3.6F); + foodSaturation.put(Material.COOKED_COD, 3.0F); + foodSaturation.put(Material.COOKED_MUTTON, 4.8F); + foodSaturation.put(Material.COOKED_PORKCHOP, 6.4F); + foodSaturation.put(Material.COOKED_RABBIT, 3.0F); + foodSaturation.put(Material.COOKED_SALMON, 4.8F); + foodSaturation.put(Material.COOKIE, 0.2F); + foodSaturation.put(Material.DRIED_KELP, 0.3F); + foodSaturation.put(Material.ENCHANTED_GOLDEN_APPLE, 4.8F); + foodSaturation.put(Material.HONEY_BOTTLE, 0.6F); + foodSaturation.put(Material.GOLDEN_APPLE, 4.8F); + foodSaturation.put(Material.GOLDEN_CARROT, 7.2F); + foodSaturation.put(Material.MELON_SLICE, 0.6F); + foodSaturation.put(Material.MUSHROOM_STEW, 3.6F); + foodSaturation.put(Material.POISONOUS_POTATO, 0.6F); + foodSaturation.put(Material.POTATO, 0.3F); + foodSaturation.put(Material.PUFFERFISH, 0.1F); + foodSaturation.put(Material.PUMPKIN_PIE, 2.4F); + foodSaturation.put(Material.RABBIT_STEW, 6.0F); + foodSaturation.put(Material.BEEF, 0.9F); + foodSaturation.put(Material.CHICKEN, 0.6F); + foodSaturation.put(Material.COD, 0.2F); + foodSaturation.put(Material.MUTTON, 0.6F); + foodSaturation.put(Material.PORKCHOP, 0.9F); + foodSaturation.put(Material.RABBIT, 0.9F); + foodSaturation.put(Material.SALMON, 0.2F); + foodSaturation.put(Material.ROTTEN_FLESH, 0.4F); + foodSaturation.put(Material.SPIDER_EYE, 1.6F); + foodSaturation.put(Material.SUSPICIOUS_STEW, 3.6F); + foodSaturation.put(Material.SWEET_BERRIES, 0.2F); + foodSaturation.put(Material.TROPICAL_FISH, 0.1F); } /** diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index ea72521c6..b02f31c0d 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -90,15 +90,16 @@ public final class SkillUtils { return currentFoodLevel + foodChange; } + //Saturation maximum is 10 instead of 20 public static float handleFoodSkillsSaturation(Player player, float eventSaturationLevel, SubSkillType subSkillType) { int curRank = RankUtils.getRank(player, subSkillType); float currentSaturationLevel = player.getSaturation(); float saturationChange = eventSaturationLevel - currentSaturationLevel; - saturationChange += curRank; + saturationChange += (curRank/2.0F); - return currentSaturationLevel + saturationChange; + return (currentSaturationLevel + saturationChange); } /**