Skip to content

Commit bf200e3

Browse files
authored
Add index check to getRecipeType() (#4859)
1 parent 8923673 commit bf200e3

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/com/gregtechceu/gtceu/api/machine/WorkableTieredMachine.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ public boolean keepSubscribing() {
197197
}
198198

199199
public GTRecipeType getRecipeType() {
200-
return recipeTypes[activeRecipeType];
200+
int index = activeRecipeType >= 0 && activeRecipeType < recipeTypes.length ? activeRecipeType : 0;
201+
return recipeTypes[index];
201202
}
202203

203204
/**

src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/WorkableMultiblockMachine.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ public void setWorkingEnabled(boolean isWorkingAllowed) {
290290
}
291291

292292
public GTRecipeType getRecipeType() {
293-
return recipeTypes[activeRecipeType];
293+
int index = activeRecipeType >= 0 && activeRecipeType < recipeTypes.length ? activeRecipeType : 0;
294+
return recipeTypes[index];
294295
}
295296

296297
/**

0 commit comments

Comments
 (0)