GenuineSounds

Proper Comparator for IEnergyContainerItem.

Aug 6th, 2014
333
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package cofh.core.hooks;
  2.  
  3. import net.minecraft.item.ItemStack;
  4. import net.minecraft.nbt.NBTTagCompound;
  5. import cofh.api.energy.IEnergyContainerItem;
  6.  
  7. // In PlayerControllerMP.sameToolAndBlock replace the call ItemStack.areItemStackTagsEqual to StackHook.areItemStackTagsEqual
  8. // This fixes charging items in your hotbar resetting block breaking progress.
  9.  
  10. public class StackHook {
  11.     public static boolean areItemStackTagsEqual(ItemStack s1, ItemStack s2) {
  12.         if (s1.getItem() == s2.getItem() && s1.getItem() instanceof IEnergyContainerItem && s2.getItem() instanceof IEnergyContainerItem) {
  13.             NBTTagCompound c1 = (NBTTagCompound) s1.stackTagCompound.copy();
  14.             NBTTagCompound c2 = (NBTTagCompound) s2.stackTagCompound.copy();
  15.             c1.removeTag("Energy");
  16.             c2.removeTag("Energy");
  17.             return c1.equals(c2);
  18.         }
  19.         return ItemStack.areItemStackTagsEqual(s1, s2);
  20.     }
  21. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment