2.1.68 - You can use food in the off hand with the diet abilities now.

This commit is contained in:
nossr50
2019-06-02 22:41:13 -07:00
parent f6dc76719a
commit f93a1aa151
4 changed files with 62 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.taming.Taming;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.MaterialMapStore;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
@ -825,12 +826,24 @@ public class EntityListener implements Listener {
return;
}
//Determine which hand is eating food
//The main hand is used over the off hand if they both have food, so check the main hand first
Material foodInHand;
if(mcMMO.getMaterialMapStore().isFood(player.getInventory().getItemInMainHand().getType())) {
foodInHand = player.getInventory().getItemInMainHand().getType();
} else if(mcMMO.getMaterialMapStore().isFood(player.getInventory().getItemInOffHand().getType())) {
foodInHand = player.getInventory().getItemInOffHand().getType();
} else {
return; //Not Food
}
/*
* 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
* if we find something is giving too much of a bonus
*/
switch (player.getInventory().getItemInMainHand().getType()) {
switch (foodInHand) {
case BAKED_POTATO: /*
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
* 1000

View File

@ -21,6 +21,7 @@ public class MaterialMapStore {
private HashSet<String> blockCrackerWhiteList;
private HashSet<String> canMakeShroomyWhiteList;
private HashSet<String> multiBlockEntities;
private HashSet<String> foodItemWhiteList;
public MaterialMapStore()
{
@ -32,6 +33,7 @@ public class MaterialMapStore {
blockCrackerWhiteList = new HashSet<>();
canMakeShroomyWhiteList = new HashSet<>();
multiBlockEntities = new HashSet<>();
foodItemWhiteList = new HashSet<>();
fillHardcodedHashSets();
}
@ -86,6 +88,50 @@ public class MaterialMapStore {
fillBlockCrackerWhiteList();
fillShroomyWhiteList();
fillMultiBlockEntitiesList();
fillFoodWhiteList();
}
private void fillFoodWhiteList() {
foodItemWhiteList.add("apple");
foodItemWhiteList.add("baked_potato");
foodItemWhiteList.add("beetroot");
foodItemWhiteList.add("beetroot_soup");
foodItemWhiteList.add("bread");
foodItemWhiteList.add("cake");
foodItemWhiteList.add("carrot");
foodItemWhiteList.add("chorus_fruit");
foodItemWhiteList.add("cooked_chicken");
foodItemWhiteList.add("cooked_cod");
foodItemWhiteList.add("cooked_mutton");
foodItemWhiteList.add("cooked_porkchop");
foodItemWhiteList.add("cooked_rabbit");
foodItemWhiteList.add("cooked_salmon");
foodItemWhiteList.add("cookie");
foodItemWhiteList.add("dried_kelp");
foodItemWhiteList.add("golden_apple");
foodItemWhiteList.add("enchanted_golden_apple");
foodItemWhiteList.add("golden_carrot");
foodItemWhiteList.add("melon_slice");
foodItemWhiteList.add("mushroom_stew");
foodItemWhiteList.add("poisonous_potato");
foodItemWhiteList.add("potato");
foodItemWhiteList.add("pumpkin_pie");
foodItemWhiteList.add("rabbit_stew");
foodItemWhiteList.add("raw_beef");
foodItemWhiteList.add("raw_chicken");
foodItemWhiteList.add("raw_cod");
foodItemWhiteList.add("raw_mutton");
foodItemWhiteList.add("raw_porkchop");
foodItemWhiteList.add("raw_rabbit");
foodItemWhiteList.add("raw_salmon");
foodItemWhiteList.add("rotten_flesh");
foodItemWhiteList.add("suspicious_stew");
foodItemWhiteList.add("sweet_berries");
foodItemWhiteList.add("tropical_fish");
}
public boolean isFood(Material material) {
return foodItemWhiteList.contains(material.getKey().getKey());
}
private void fillMultiBlockEntitiesList()