Skip to content
Open
Show file tree
Hide file tree
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 @@ -32,6 +32,11 @@ public Integer copyWithModifier(Integer content, ContentModifier modifier) {
return modifier.apply(content);
}

@Override
public boolean skipEmptyContentCheck() {
return true;
}

@Override
public void addXEIInfo(WidgetGroup group, int xOffset, GTRecipe recipe, List<Content> contents, boolean perTick,
boolean isInput, MutableInt yOffset) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,13 @@ public boolean isTickSlot(int index, IO io, GTRecipe recipe) {
public boolean shouldBypassDistinct() {
return true;
}

/**
* Should handlers of this capability be tried even when {@link IRecipeHandler#getTotalContentAmount()} is zero?
* E.g. should this capability bypass the empty handler optimization for rate-based capabilities.
* for example: CWU, where stored amount is zero but the handler can still provide computation.
*/
public boolean skipEmptyContentCheck() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ public Map<RecipeCapability<?>, List<Object>> handleRecipe(IO io, GTRecipe recip
var entry = it.next();
var handlerList = getCapability(entry.getKey());
for (var handler : handlerList) {
if (io == IO.IN && handler.getTotalContentAmount() == 0 &&
!handler.getCapability().skipEmptyContentCheck()) {
continue;
}
var left = handler.handleRecipe(io, recipe, entry.getValue(), simulate);
if (left == null) {
it.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ public static ActionResult handleRecipe(IRecipeCapabilityHolder holder, GTRecipe
Map<RecipeCapability<?>, List<Content>> contents,
Map<RecipeCapability<?>, Object2IntMap<?>> chanceCaches,
boolean isTick, boolean simulated) {
if (contents.isEmpty()) {
return ActionResult.PASS_NO_CONTENTS;
}
RecipeRunner runner = new RecipeRunner(recipe, io, isTick, holder, chanceCaches, simulated);
var result = runner.handle(contents);

Expand Down
Loading