diff --git a/src/main/java/refinedstorage/api/storage/CompareUtils.java b/src/main/java/refinedstorage/api/storage/CompareUtils.java index 7ca1a671b..937e804bd 100755 --- a/src/main/java/refinedstorage/api/storage/CompareUtils.java +++ b/src/main/java/refinedstorage/api/storage/CompareUtils.java @@ -5,17 +5,43 @@ import net.minecraftforge.oredict.OreDictionary; import org.apache.commons.lang3.ArrayUtils; /** - * Comparison utils. + * Utilities for comparing {@link ItemStack}. */ public final class CompareUtils { public static final int COMPARE_DAMAGE = 1; public static final int COMPARE_NBT = 2; public static final int COMPARE_QUANTITY = 4; + /** + * Compares two stacks by NBT, damage and quantity. + * + * @param left The left stack + * @param right The right stack + * @return Whether the left and right stack are equal + */ public static boolean compareStack(ItemStack left, ItemStack right) { return compareStack(left, right, COMPARE_NBT | COMPARE_DAMAGE | COMPARE_QUANTITY); } + /** + * Compares two stacks by NBT and damage. + * + * @param left The left stack + * @param right The right stack + * @return Whether the left and right stack are equal + */ + public static boolean compareStackNoQuantity(ItemStack left, ItemStack right) { + return compareStack(left, right, COMPARE_NBT | COMPARE_DAMAGE); + } + + /** + * Compares two stacks by the given flags. + * + * @param left The left stack + * @param right The right stack + * @param flags The flags to compare with + * @return Whether the left and right stack are equal + */ public static boolean compareStack(ItemStack left, ItemStack right, int flags) { if (left == null && right == null) { return true; @@ -50,6 +76,13 @@ public final class CompareUtils { return true; } + /** + * Compares the NBT tags of two stacks. + * + * @param left The left stack + * @param right The right stack + * @return Whether the NBT tags are equal + */ public static boolean compareNbt(ItemStack left, ItemStack right) { if (!ItemStack.areItemStackTagsEqual(left, right)) { if (left.hasTagCompound() && !right.hasTagCompound() && left.getTagCompound().hasNoTags()) { @@ -64,10 +97,13 @@ public final class CompareUtils { return true; } - public static boolean compareStackNoQuantity(ItemStack left, ItemStack right) { - return compareStack(left, right, COMPARE_NBT | COMPARE_DAMAGE); - } - + /** + * Compares two stacks and checks if they share the same ore dictionary entry. + * + * @param left The left stack + * @param right The right stack + * @return Whether the stacks share the same ore dictionary entry + */ public static boolean compareStackOreDict(ItemStack left, ItemStack right) { if (left == null && right == null) { return true; diff --git a/src/main/java/refinedstorage/gui/GuiBase.java b/src/main/java/refinedstorage/gui/GuiBase.java index 932136f4c..5fd1d7ebe 100755 --- a/src/main/java/refinedstorage/gui/GuiBase.java +++ b/src/main/java/refinedstorage/gui/GuiBase.java @@ -279,7 +279,7 @@ public abstract class GuiBase extends GuiContainer { return guiTop; } - public static int calculateOffsetOnScale(int pos, float scale) { + protected int calculateOffsetOnScale(int pos, float scale) { float multiplier = (pos / scale); return (int) multiplier;