mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-10-25 20:32:24 +00:00
add a new api to stack extractors
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
This commit is contained in:
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.
|
||||
|
||||
Reference in new issue
Block a user