Skip to content

Commit

Permalink
Fix some extra tool ingredients being ignored in small tables (#5193)
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Mar 7, 2024
1 parent a39eb94 commit 3e685d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ public boolean matches(ITinkerStationContainer inv, Level worldIn) {
return false;
}
List<PartRequirement> parts = output.getToolDefinition().getData().getParts();
if (parts.isEmpty()) {
int requiredInputs = parts.size() + ingredients.size();
int maxInputs = inv.getInputCount();
// disallow if we have no inputs, or if we have too few slots
if (requiredInputs == 0 || requiredInputs > maxInputs) {
return false;
}
// each part must match the given slot
Expand All @@ -70,7 +73,7 @@ public boolean matches(ITinkerStationContainer inv, Level worldIn) {
}
}
// remaining slots must match extra requirements
for (; i < inv.getInputCount(); i++) {
for (; i < maxInputs; i++) {
Ingredient ingredient = LogicHelper.getOrDefault(ingredients, i - partSize, Ingredient.EMPTY);
if (!ingredient.test(inv.getInput(i))) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public ToolBuildingRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
String group = GsonHelper.getAsString(json, "group", "");
// output fetch as a modifiable item, its an error if it does not implement that interface or does not have parts
IModifiable item = RecipeHelper.deserializeItem(GsonHelper.getAsString(json, "result"), "result", IModifiable.class);
if (!item.getToolDefinition().isMultipart()) {
throw new JsonSyntaxException("Modifiable item must have tool parts to get a tool building recipe");
}
int resultCount = GsonHelper.getAsInt(json, "result_count", 1);
List<Ingredient> extraRequirements = Collections.emptyList();
if (json.has("extra_requirements")) {
extraRequirements = JsonHelper.parseList(json, "extra_requirements", Ingredient::fromJson);
}
if (!item.getToolDefinition().isMultipart() && extraRequirements.isEmpty()) {
throw new JsonSyntaxException("Modifiable item must have tool parts or extra requirements to use tool building recipes");
}
return new ToolBuildingRecipe(recipeId, group, item, resultCount, extraRequirements);
}

Expand Down

0 comments on commit 3e685d1

Please sign in to comment.