Small fixes
This commit is contained in:
parent
8fc439a24d
commit
01d29a3aa7
3 changed files with 34 additions and 3 deletions
|
@ -26,7 +26,7 @@ public class RecipeBuilder {
|
|||
private boolean shaped = true;
|
||||
private String[] shape = new String[] {"#"};
|
||||
private Map<Character, Ingredient> materialKeys = Maps.newHashMap();
|
||||
private int count;
|
||||
private int count = 1;
|
||||
|
||||
public RecipeBuilder(String name, Item output) {
|
||||
this.name = name;
|
||||
|
@ -48,6 +48,12 @@ public class RecipeBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public RecipeBuilder setList(String shape) {
|
||||
this.shape = new String[] {shape};
|
||||
this.shaped = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecipeBuilder addMaterial(char key, Item value) {
|
||||
materialKeys.put(key, Ingredient.ofItems(value));
|
||||
return this;
|
||||
|
@ -70,11 +76,12 @@ public class RecipeBuilder {
|
|||
|
||||
private DefaultedList<Ingredient> getMaterials(int width, int height) {
|
||||
DefaultedList<Ingredient> materials = DefaultedList.ofSize(width * height, Ingredient.EMPTY);
|
||||
int pos = 0;
|
||||
for (String line: shape) {
|
||||
for (int i = 0; i < width; i++) {
|
||||
char c = line.charAt(i);
|
||||
Ingredient material = materialKeys.get(c);
|
||||
materials.add(material == null ? Ingredient.EMPTY : material);
|
||||
materials.set(pos ++, material == null ? Ingredient.EMPTY : material);
|
||||
}
|
||||
}
|
||||
return materials;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue