Skip to content

Commit ed00371

Browse files
authored
Fix recipe logic with Undyed Hatches and Distinctness Bypassing (GregTechCEu#3629)
1 parent dcc1d93 commit ed00371

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,11 @@ public static void addToRecipeHandlerMap(RecipeHandlerGroup key, RecipeHandlerLi
353353
map.computeIfAbsent(RecipeHandlerGroupDistinctness.BYPASS_DISTINCT, $ -> new ArrayList<>()).add(handler);
354354
return;
355355
}
356-
// Add undyed RHL's to every group that's not distinct, and also the undyed group itself.
356+
// Add undyed RHL's to every group that's not distinct, bypass, and also the undyed group itself.
357357
if (key.equals(RecipeHandlerGroupColor.UNDYED)) {
358358
for (var entry : map.entrySet()) {
359359
if (entry.getKey().equals(RecipeHandlerGroupDistinctness.BUS_DISTINCT) ||
360+
entry.getKey().equals(RecipeHandlerGroupDistinctness.BYPASS_DISTINCT) ||
360361
entry.getKey().equals(RecipeHandlerGroupColor.UNDYED)) {
361362
continue;
362363
}

src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeRunner.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.gregtechceu.gtceu.api.capability.recipe.IRecipeCapabilityHolder;
55
import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability;
66
import com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerGroup;
7-
import com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerGroupDistinctness;
87
import com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerList;
98
import com.gregtechceu.gtceu.api.recipe.chance.boost.ChanceBoostFunction;
109
import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic;
@@ -20,6 +19,8 @@
2019
import java.util.List;
2120
import java.util.Map;
2221

22+
import static com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerGroupDistinctness.BUS_DISTINCT;
23+
import static com.gregtechceu.gtceu.api.machine.trait.RecipeHandlerGroupDistinctness.BYPASS_DISTINCT;
2324
import static com.gregtechceu.gtceu.api.recipe.RecipeHelper.addToRecipeHandlerMap;
2425

2526
public class RecipeRunner {
@@ -121,21 +122,18 @@ private ActionResult handleContents() {
121122
addToRecipeHandlerMap(handler.getGroup(), handler, handlerGroups);
122123
}
123124
// Specifically check distinct handlers first
124-
for (RecipeHandlerList handler : handlerGroups.getOrDefault(RecipeHandlerGroupDistinctness.BUS_DISTINCT,
125-
Collections.emptyList())) {
125+
for (RecipeHandlerList handler : handlerGroups.getOrDefault(BUS_DISTINCT, Collections.emptyList())) {
126126
// Handle the contents of this handler and also all the bypassed handlers
127127
var res = handler.handleRecipe(io, recipe, searchRecipeContents, true);
128-
for (RecipeHandlerList bypassHandler : handlerGroups.getOrDefault(
129-
RecipeHandlerGroupDistinctness.BYPASS_DISTINCT,
128+
for (RecipeHandlerList bypassHandler : handlerGroups.getOrDefault(BYPASS_DISTINCT,
130129
Collections.emptyList())) {
131130
res = bypassHandler.handleRecipe(io, recipe, res, true);
132131
}
133132
if (res.isEmpty()) {
134133
if (!simulated) {
135134
// Actually consume the contents of this handler and also all the bypassed handlers
136135
recipeContents = handler.handleRecipe(io, recipe, recipeContents, false);
137-
for (RecipeHandlerList bypassHandler : handlerGroups.getOrDefault(
138-
RecipeHandlerGroupDistinctness.BYPASS_DISTINCT,
136+
for (RecipeHandlerList bypassHandler : handlerGroups.getOrDefault(BYPASS_DISTINCT,
139137
Collections.emptyList())) {
140138
recipeContents = bypassHandler.handleRecipe(io, recipe, recipeContents, false);
141139
}
@@ -148,7 +146,7 @@ private ActionResult handleContents() {
148146
// Check the other groups. For every group, try consuming the ingredients,
149147
// see if it succeeds.
150148
for (Map.Entry<RecipeHandlerGroup, List<RecipeHandlerList>> handlerListEntry : handlerGroups.entrySet()) {
151-
if (handlerListEntry.getKey() == RecipeHandlerGroupDistinctness.BUS_DISTINCT) continue;
149+
if (handlerListEntry.getKey().equals(BUS_DISTINCT)) continue;
152150

153151
// List to keep track of the remaining items for this RecipeHandlerGroup
154152
Map<RecipeCapability<?>, List<Object>> copiedRecipeContents = searchRecipeContents;
@@ -162,9 +160,8 @@ private ActionResult handleContents() {
162160
}
163161
}
164162
// If we're already in the bypass_distinct group, don't check it twice.
165-
if (handlerListEntry.getKey() != RecipeHandlerGroupDistinctness.BYPASS_DISTINCT) {
166-
for (RecipeHandlerList bypassHandler : handlerGroups.getOrDefault(
167-
RecipeHandlerGroupDistinctness.BYPASS_DISTINCT,
163+
if (!handlerListEntry.getKey().equals(BYPASS_DISTINCT)) {
164+
for (RecipeHandlerList bypassHandler : handlerGroups.getOrDefault(BYPASS_DISTINCT,
168165
Collections.emptyList())) {
169166
copiedRecipeContents = bypassHandler.handleRecipe(io, recipe, copiedRecipeContents, true);
170167
if (copiedRecipeContents.isEmpty()) {
@@ -189,9 +186,8 @@ private ActionResult handleContents() {
189186
}
190187
// Then go through the handlers that bypass the distinctness system and empty those
191188
// If we're already in the bypass_distinct group, don't check it twice.
192-
if (handlerListEntry.getKey() != RecipeHandlerGroupDistinctness.BYPASS_DISTINCT) {
193-
for (RecipeHandlerList bypassHandler : handlerGroups.getOrDefault(
194-
RecipeHandlerGroupDistinctness.BYPASS_DISTINCT,
189+
if (!handlerListEntry.getKey().equals(BYPASS_DISTINCT)) {
190+
for (RecipeHandlerList bypassHandler : handlerGroups.getOrDefault(BYPASS_DISTINCT,
195191
Collections.emptyList())) {
196192
copiedRecipeContents = bypassHandler.handleRecipe(io, recipe, copiedRecipeContents, false);
197193
if (copiedRecipeContents.isEmpty()) {

0 commit comments

Comments
 (0)