fix saturation max

This commit is contained in:
Enderaoe 2021-11-11 00:24:55 +08:00
parent adc480fd03
commit 044e0c9f62
3 changed files with 52 additions and 49 deletions

View File

@ -914,12 +914,6 @@ public class EntityListener implements Listener {
return; //Not Food 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 * 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 * 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 //Hacky 1.17 support
if(foodInHand.getKey().getKey().equalsIgnoreCase("glow_berries")) { if(foodInHand.getKey().getKey().equalsIgnoreCase("glow_berries")) {
newSaturationLevel = currentSaturationLevel + 0.4F; newSaturationLevel = currentSaturationLevel + 0.2F;
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) { if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDietHunger(newFoodLevel)); event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDietHunger(newFoodLevel));
player.setSaturation(UserManager.getPlayer(player).getHerbalismManager().farmersDietSaturation(newSaturationLevel)); player.setSaturation(UserManager.getPlayer(player).getHerbalismManager().farmersDietSaturation(newSaturationLevel));
@ -937,6 +931,14 @@ public class EntityListener implements Listener {
return; return;
} }
Float foodSaturation = ItemUtils.getFoodSaturation(foodInHand);
if (foodSaturation != null) {
newSaturationLevel = currentSaturationLevel + foodSaturation;
} else {
return; //Food unknown
}
switch (foodInHand) { switch (foodInHand) {
case BAKED_POTATO, BEETROOT, BREAD, CARROT, GOLDEN_CARROT, MUSHROOM_STEW, PUMPKIN_PIE, COOKIE, MELON_SLICE, POISONOUS_POTATO, POTATO -> { 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)) { if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {

View File

@ -34,46 +34,46 @@ public final class ItemUtils {
private static final HashMap<Material, Float> foodSaturation = new HashMap<>(); private static final HashMap<Material, Float> foodSaturation = new HashMap<>();
static { static {
foodSaturation.put(Material.APPLE, 2.4F); foodSaturation.put(Material.APPLE, 1.2F);
foodSaturation.put(Material.BAKED_POTATO, 6.0F); foodSaturation.put(Material.BAKED_POTATO, 3.0F);
foodSaturation.put(Material.BEETROOT, 1.2F); foodSaturation.put(Material.BEETROOT, 0.6F);
foodSaturation.put(Material.BEETROOT_SOUP, 7.2F); foodSaturation.put(Material.BEETROOT_SOUP, 3.6F);
foodSaturation.put(Material.BREAD, 6.0F); foodSaturation.put(Material.BREAD, 3.0F);
foodSaturation.put(Material.CAKE, 0.4F); foodSaturation.put(Material.CAKE, 0.2F);
foodSaturation.put(Material.CARROT, 3.6F); foodSaturation.put(Material.CARROT, 1.8F);
foodSaturation.put(Material.CHORUS_FRUIT, 2.4F); foodSaturation.put(Material.CHORUS_FRUIT, 1.2F);
foodSaturation.put(Material.COOKED_BEEF, 12.8F); foodSaturation.put(Material.COOKED_BEEF, 6.4F);
foodSaturation.put(Material.COOKED_CHICKEN, 7.2F); foodSaturation.put(Material.COOKED_CHICKEN, 3.6F);
foodSaturation.put(Material.COOKED_COD, 6.0F); foodSaturation.put(Material.COOKED_COD, 3.0F);
foodSaturation.put(Material.COOKED_MUTTON, 9.6F); foodSaturation.put(Material.COOKED_MUTTON, 4.8F);
foodSaturation.put(Material.COOKED_PORKCHOP, 12.8F); foodSaturation.put(Material.COOKED_PORKCHOP, 6.4F);
foodSaturation.put(Material.COOKED_RABBIT, 6.0F); foodSaturation.put(Material.COOKED_RABBIT, 3.0F);
foodSaturation.put(Material.COOKED_SALMON, 9.6F); foodSaturation.put(Material.COOKED_SALMON, 4.8F);
foodSaturation.put(Material.COOKIE, 0.4F); foodSaturation.put(Material.COOKIE, 0.2F);
foodSaturation.put(Material.DRIED_KELP, 0.6F); foodSaturation.put(Material.DRIED_KELP, 0.3F);
foodSaturation.put(Material.ENCHANTED_GOLDEN_APPLE, 9.6F); foodSaturation.put(Material.ENCHANTED_GOLDEN_APPLE, 4.8F);
foodSaturation.put(Material.HONEY_BOTTLE, 1.2F); foodSaturation.put(Material.HONEY_BOTTLE, 0.6F);
foodSaturation.put(Material.GOLDEN_APPLE, 9.6F); foodSaturation.put(Material.GOLDEN_APPLE, 4.8F);
foodSaturation.put(Material.GOLDEN_CARROT, 14.4F); foodSaturation.put(Material.GOLDEN_CARROT, 7.2F);
foodSaturation.put(Material.MELON_SLICE, 1.2F); foodSaturation.put(Material.MELON_SLICE, 0.6F);
foodSaturation.put(Material.MUSHROOM_STEW, 7.2F); foodSaturation.put(Material.MUSHROOM_STEW, 3.6F);
foodSaturation.put(Material.POISONOUS_POTATO, 1.2F); foodSaturation.put(Material.POISONOUS_POTATO, 0.6F);
foodSaturation.put(Material.POTATO, 0.6F); foodSaturation.put(Material.POTATO, 0.3F);
foodSaturation.put(Material.PUFFERFISH, 0.2F); foodSaturation.put(Material.PUFFERFISH, 0.1F);
foodSaturation.put(Material.PUMPKIN_PIE, 4.8F); foodSaturation.put(Material.PUMPKIN_PIE, 2.4F);
foodSaturation.put(Material.RABBIT_STEW, 12.0F); foodSaturation.put(Material.RABBIT_STEW, 6.0F);
foodSaturation.put(Material.BEEF, 1.8F); foodSaturation.put(Material.BEEF, 0.9F);
foodSaturation.put(Material.CHICKEN, 1.2F); foodSaturation.put(Material.CHICKEN, 0.6F);
foodSaturation.put(Material.COD, 0.4F); foodSaturation.put(Material.COD, 0.2F);
foodSaturation.put(Material.MUTTON, 1.2F); foodSaturation.put(Material.MUTTON, 0.6F);
foodSaturation.put(Material.PORKCHOP, 1.8F); foodSaturation.put(Material.PORKCHOP, 0.9F);
foodSaturation.put(Material.RABBIT, 1.8F); foodSaturation.put(Material.RABBIT, 0.9F);
foodSaturation.put(Material.SALMON, 0.4F); foodSaturation.put(Material.SALMON, 0.2F);
foodSaturation.put(Material.ROTTEN_FLESH, 0.8F); foodSaturation.put(Material.ROTTEN_FLESH, 0.4F);
foodSaturation.put(Material.SPIDER_EYE, 3.2F); foodSaturation.put(Material.SPIDER_EYE, 1.6F);
foodSaturation.put(Material.SUSPICIOUS_STEW, 7.2F); foodSaturation.put(Material.SUSPICIOUS_STEW, 3.6F);
foodSaturation.put(Material.SWEET_BERRIES, 0.4F); foodSaturation.put(Material.SWEET_BERRIES, 0.2F);
foodSaturation.put(Material.TROPICAL_FISH, 0.2F); foodSaturation.put(Material.TROPICAL_FISH, 0.1F);
} }
/** /**

View File

@ -90,15 +90,16 @@ public final class SkillUtils {
return currentFoodLevel + foodChange; return currentFoodLevel + foodChange;
} }
//Saturation maximum is 10 instead of 20
public static float handleFoodSkillsSaturation(Player player, float eventSaturationLevel, SubSkillType subSkillType) { public static float handleFoodSkillsSaturation(Player player, float eventSaturationLevel, SubSkillType subSkillType) {
int curRank = RankUtils.getRank(player, subSkillType); int curRank = RankUtils.getRank(player, subSkillType);
float currentSaturationLevel = player.getSaturation(); float currentSaturationLevel = player.getSaturation();
float saturationChange = eventSaturationLevel - currentSaturationLevel; float saturationChange = eventSaturationLevel - currentSaturationLevel;
saturationChange += curRank; saturationChange += (curRank/2.0F);
return currentSaturationLevel + saturationChange; return (currentSaturationLevel + saturationChange);
} }
/** /**