Skip to content

Commit

Permalink
Merge pull request #665 from codewarrior0/locked-drawers-losing-reser…
Browse files Browse the repository at this point in the history
…vations-redux

Fix #664 - Locked drawers appear to lose reservations
  • Loading branch information
jaquadro committed Aug 31, 2018
2 parents d3c2815 + e2585ef commit cfa3d18
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 cfa3d18

Please sign in to comment.