Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cofh.core.hooks;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import cofh.api.energy.IEnergyContainerItem;
- // In PlayerControllerMP.sameToolAndBlock replace the call ItemStack.areItemStackTagsEqual to StackHook.areItemStackTagsEqual
- // This fixes charging items in your hotbar resetting block breaking progress.
- public class StackHook {
- public static boolean areItemStackTagsEqual(ItemStack s1, ItemStack s2) {
- if (s1.getItem() == s2.getItem() && s1.getItem() instanceof IEnergyContainerItem && s2.getItem() instanceof IEnergyContainerItem) {
- NBTTagCompound c1 = (NBTTagCompound) s1.stackTagCompound.copy();
- NBTTagCompound c2 = (NBTTagCompound) s2.stackTagCompound.copy();
- c1.removeTag("Energy");
- c2.removeTag("Energy");
- return c1.equals(c2);
- }
- return ItemStack.areItemStackTagsEqual(s1, s2);
- }
- }
Advertisement