diff --git a/Changelog.txt b/Changelog.txt
index 49c8d47c1..645674540 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,6 +1,6 @@
Version 2.1.68
Updated Japanese locale (thanks Snake)
-
+ Fixed a bug where consuming food in the off hand did not trigger the Diet abilities
Version 2.1.67
The XP bar now reflects whether or not the player is receiving the early game boost
diff --git a/pom.xml b/pom.xml
index b21af3aef..1e704dd90 100755
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.gmail.nossr50.mcMMO
mcMMO
- 2.1.68-SNAPSHOT
+ 2.1.68
mcMMO
https://github.com/mcMMO-Dev/mcMMO
diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java
index 79c4999e3..bcecc77b5 100644
--- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java
@@ -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
diff --git a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java
index 0b9278735..16860e252 100644
--- a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java
+++ b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java
@@ -21,6 +21,7 @@ public class MaterialMapStore {
private HashSet blockCrackerWhiteList;
private HashSet canMakeShroomyWhiteList;
private HashSet multiBlockEntities;
+ private HashSet 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()