Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,27 @@ private InvUtils() {

// Predicates

private static Predicate<ItemStack> isOneOf(Item... items) {
return itemStack -> {
for (var item : items) if (itemStack.is(item)) return true;
return false;
};
}

public static boolean testInMainHand(Predicate<ItemStack> predicate) {
return predicate.test(mc.player.getMainHandItem());
}

public static boolean testInMainHand(Item... items) {
return testInMainHand(itemStack -> {
for (var item : items) if (itemStack.is(item)) return true;
return false;
});
return testInMainHand(isOneOf(items));
}

public static boolean testInOffHand(Predicate<ItemStack> predicate) {
return predicate.test(mc.player.getOffhandItem());
}

public static boolean testInOffHand(Item... items) {
return testInOffHand(itemStack -> {
for (var item : items) if (itemStack.is(item)) return true;
return false;
});
return testInOffHand(isOneOf(items));
}

public static boolean testInHands(Predicate<ItemStack> predicate) {
Expand All @@ -73,10 +74,7 @@ public static boolean testInHotbar(Predicate<ItemStack> predicate) {
}

public static boolean testInHotbar(Item... items) {
return testInHotbar(itemStack -> {
for (var item : items) if (itemStack.is(item)) return true;
return false;
});
return testInHotbar(isOneOf(items));
}

// Finding items
Expand All @@ -86,12 +84,7 @@ public static FindItemResult findEmpty() {
}

public static FindItemResult findInHotbar(Item... items) {
return findInHotbar(itemStack -> {
for (Item item : items) {
if (itemStack.getItem() == item) return true;
}
return false;
});
return findInHotbar(isOneOf(items));
}

public static FindItemResult findInHotbar(Predicate<ItemStack> isGood) {
Expand All @@ -107,12 +100,7 @@ public static FindItemResult findInHotbar(Predicate<ItemStack> isGood) {
}

public static FindItemResult find(Item... items) {
return find(itemStack -> {
for (Item item : items) {
if (itemStack.getItem() == item) return true;
}
return false;
});
return find(isOneOf(items));
}

public static FindItemResult find(Predicate<ItemStack> isGood) {
Expand Down