add a new api to stack extractors

Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
This commit is contained in:
Glease committed 2024-04-16 17:32:31 +08:00
1 parent a7f0d6be72
commit efd49701e1
1 file changed
+8
@@ -253,6 +253,8 @@ public class InventoryUtility {
}
if (!recursive) continue;
for (ItemStackExtractor f : stackExtractors) {
boolean end = f.isAPIImplemented(APIType.IS_VALID_SOURCE);
if (!f.isValidSource(stack, player)) continue;
if (filter != null && f.isAPIImplemented(APIType.EXTRACT_ONE_STACK)) {
copiedFilter.stackSize = count - found;
found += f.getItem(stack, copiedFilter, simulate, player);
@@ -260,6 +262,7 @@ public class InventoryUtility {
found += f.takeFromStack(predicate, simulate, count - found, store, stack, filter, player);
}
if (found >= count) return found;
if (end) break;
}
}
return found;
@@ -294,10 +297,15 @@ public class InventoryUtility {
enum APIType {
MAIN,
EXTRACT_ONE_STACK,
IS_VALID_SOURCE,
}
boolean isAPIImplemented(APIType type);
default boolean isValidSource(ItemStack is, EntityPlayerMP player) {
return true;
}
/**
* Extract a particular type of item. The extractor can choose to not return all items contained within this
* item as long as it makes sense, but the author should inform the player of this.