use of gnu.trove.iterator.TCharIterator in project Charset by CharsetMC.
the class RecipeReplacement method process.
public void process(Collection<IRecipe> registry) {
for (IRecipe recipe : registry) {
ResourceLocation recipeName = recipe.getRegistryName();
boolean dirty = false;
if (recipe instanceof ShapedRecipes || recipe instanceof ShapelessRecipes || recipe instanceof ShapedOreRecipe || recipe instanceof ShapelessOreRecipe) {
NonNullList<Ingredient> ingredients = recipe.getIngredients();
for (int i = 0; i < ingredients.size(); i++) {
Ingredient ing = ingredients.get(i);
Ingredient ingNew = replaceIngredient(ing);
if (ingNew != null) {
ingredients.set(i, ingNew);
dirty = true;
}
}
} else if (recipe instanceof RecipeCharset) {
TCharObjectMap<Ingredient> charToIngredient = ((RecipeCharset) recipe).charToIngredient;
NonNullList<Ingredient> ingredients = recipe.getIngredients();
for (int i = 0; i < ingredients.size(); i++) {
Ingredient ing = ingredients.get(i);
Ingredient ingNew = replaceIngredient(ing);
if (ingNew != null) {
ingredients.set(i, ingNew);
TCharIterator iterator = charToIngredient.keySet().iterator();
while (iterator.hasNext()) {
char c = iterator.next();
if (charToIngredient.get(c) == ing) {
charToIngredient.put(c, ing);
}
}
dirty = true;
}
}
}
if (dirty) {
ModCharset.logger.info("Successfully edited " + recipeName + "!");
}
}
}
Aggregations