format all the things!

This commit is contained in:
jaredlll08 committed 2015-08-31 19:15:35 +02:00
1 parent 54ec75fd3d
commit b36c6dade6
377 files changed
+6833 -6772

No files matched your search

@@ -20,34 +20,34 @@ public class ShapelessRecipe implements ICraftingRecipe {
private final IItemStack output;
private final IRecipeFunction function;
private final IIngredient[] ingredients;
public ShapelessRecipe(IItemStack output, IIngredient[] ingredients, IRecipeFunction function) {
this.output = output;
this.function = function;
this.ingredients = ingredients;
}
public int getSize() {
return ingredients.length;
}
public IIngredient[] getIngredients() {
return ingredients;
}
public IItemStack getOutput() {
return output;
}
@Override
public boolean matches(ICraftingInventory inventory) {
return matchShapeless(ingredients, inventory) != null;
}
@Override
public IItemStack getCraftingResult(ICraftingInventory inventory) {
RecipeMatching matching = matchShapeless(ingredients, inventory);
IItemStack actualOutput = output;
if (function != null) {
Map<String, IItemStack> map = new HashMap<String, IItemStack>();
@@ -56,21 +56,21 @@ public class ShapelessRecipe implements ICraftingRecipe {
map.put(ingredients[i].getMark(), matching.inputs[i]);
}
}
actualOutput = function.process(actualOutput, map, new CraftingInfo(inventory, null));
}
if (actualOutput == null) {
return null;
}
return actualOutput;
}
@Override
public void applyTransformers(ICraftingInventory inventory, IPlayer byPlayer) {
RecipeMatching matching = matchShapeless(ingredients, inventory);
for (int i = 0; i < ingredients.length; i++) {
IIngredient ingredient = ingredients[i];
IItemStack transformed = ingredient.applyTransform(matching.inputs[i], byPlayer);
@@ -79,27 +79,27 @@ public class ShapelessRecipe implements ICraftingRecipe {
}
}
}
@Override
public String toCommandString() {
StringBuilder result = new StringBuilder();
result.append("recipes.addShapeless(");
result.append(output);
result.append(", [");
for (int i = 0; i < ingredients.length; i++) {
if (i > 0)
result.append(", ");
result.append(ingredients[i]);
}
result.append("]);");
return result.toString();
}
/**
* Reorders ingredients to match the given shapeless recipe.
*
@@ -116,34 +116,36 @@ public class ShapelessRecipe implements ICraftingRecipe {
numItems++;
}
}
if (numItems != recipe.length) {
return null;
}
IItemStack[] matched = new IItemStack[recipe.length];
int[] indices = new int[recipe.length];
outer: for (int i = 0; i < ingredients.getSize(); i++) {
IItemStack ingredient = ingredients.getStack(i);
if (ingredient == null) continue;
if (ingredient == null)
continue;
for (int j = 0; j < recipe.length; j++) {
if (matched[j] != null) continue;
if (matched[j] != null)
continue;
if (recipe[j].matches(ingredient)) {
matched[j] = ingredient;
indices[j] = i;
continue outer;
}
}
return null;
}
return new RecipeMatching(matched, indices);
}
@Override
public boolean hasTransformers() {
for (IIngredient ingredient : ingredients) {
@@ -151,10 +153,10 @@ public class ShapelessRecipe implements ICraftingRecipe {
return true;
}
}
return false;
}
private static class RecipeMatching {
public final IItemStack[] inputs;
public final int[] indices;