Skip to content

Commit

Permalink
Fix #664 - Locked drawers appear to lose reservations
Browse files Browse the repository at this point in the history
  • Loading branch information
codewarrior0 committed Aug 31, 2018
1 parent d3c2815 commit e2585ef
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.capabilities.CapabilityDispatcher;
import net.minecraftforge.fml.relauncher.ReflectionHelper;

import javax.annotation.Nonnull;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -123,18 +124,18 @@ public static boolean isStackEncoded (@Nonnull ItemStack stack) {

static {
try {
itemField = ItemStack.class.getDeclaredField("item");
itemDamageField = ItemStack.class.getDeclaredField("itemDamage");
stackTagCompoundField = ItemStack.class.getDeclaredField("stackTagCompound");
capabilitiesField = ItemStack.class.getDeclaredField("capabilities");
itemField = ReflectionHelper.findField(ItemStack.class, "item", "field_151002_e");
itemDamageField = ReflectionHelper.findField(ItemStack.class,"itemDamage", "field_77991_e");
stackTagCompoundField = ReflectionHelper.findField(ItemStack.class,"stackTagCompound", "field_77990_d");
capabilitiesField = ReflectionHelper.findField(ItemStack.class,"capabilities");

itemField.setAccessible(true);
itemDamageField.setAccessible(true);
stackTagCompoundField.setAccessible(true);
capabilitiesField.setAccessible(true);

initialized = true;
} catch (NoSuchFieldException e) {
} catch (ReflectionHelper.UnableToFindFieldException e) {
initialized = false;
}
}
Expand Down

0 comments on commit e2585ef

Please sign in to comment.