Small fix and add toString for debugging

This commit is contained in:
LLytho 2022-07-14 00:24:37 +02:00
parent b9a4e8f26e
commit b9ca0dbfc7
3 changed files with 19 additions and 5 deletions

View file

@ -1,5 +1,6 @@
package com.almostreliable.unified.recipe;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@ -13,19 +14,25 @@ public class DuplicateLink {
}
void updateMaster(RawRecipe master) {
4 = {DuplicateLink@28142} Objects.requireNonNull(master);
Objects.requireNonNull(master);
addDuplicate(master);
this.currentMaster = master;
}
void addDuplicate(RawRecipe recipe) {
if(recipe == null) {
String s = "";
}
recipes.add(recipe);
}
public RawRecipe getMaster() {
return currentMaster;
}
public Set<RawRecipe> getRecipes() {
return Collections.unmodifiableSet(recipes);
}
@Override
public String toString() {
return "Link{currentMaster=" + currentMaster + ", recipes=" + recipes.size() + "}";
}
}

View file

@ -17,7 +17,6 @@ public class RawRecipe {
@Nullable private DuplicateLink duplicateLink;
@Nullable private JsonObject transformedRecipe;
public RawRecipe(ResourceLocation id, JsonObject originalRecipe) {
this.id = id;
this.originalRecipe = originalRecipe;
@ -109,4 +108,11 @@ public class RawRecipe {
return null;
}
@Override
public String toString() {
String duplicate = duplicateLink != null ? " (duplicate)" : "";
String transformed = transformedRecipe != null ? " (transformed)" : "";
return String.format("['%s'] %s%s%s", type, id, duplicate, transformed);
}
}

View file

@ -54,6 +54,7 @@ public class RecipeTransformer {
}
}
// TODO remove later
List<DuplicateLink> duplicateLinks = rawRecipes
.stream()
.map(RawRecipe::getDuplicateLink)