From 8eddbaf6c54eece6ae7aca52e5504785418a9801 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 19 May 2016 00:00:46 -0700 Subject: [PATCH] Fix #1162 Backpack persists upon item switching --- src/main/java/forestry/storage/items/ItemBackpack.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index bc5095790..fa5e5447e 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.storage.items; +import javax.annotation.Nullable; import java.util.List; import java.util.Locale; @@ -258,7 +259,12 @@ public class ItemBackpack extends ItemWithGui implements IColoredItem { } } + @Nullable public static BackpackMode getMode(ItemStack backpack) { + if (!(backpack.getItem() instanceof ItemBackpack)) { + return null; + } + int meta = backpack.getItemDamage(); if (meta >= 3) { @@ -274,7 +280,9 @@ public class ItemBackpack extends ItemWithGui implements IColoredItem { @Override public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { - return getMode(oldStack) != getMode(newStack); + Item oldItem = oldStack.getItem(); + Item newItem = newStack.getItem(); + return oldItem != newItem || getMode(oldStack) != getMode(newStack); } @SuppressWarnings("incomplete-switch")