Rename allTypes to make it more intuitive

This commit is contained in:
Christian Koop 2020-04-17 16:41:00 +02:00 committed by Brianna
parent e77d89173f
commit c65ac98f71

View File

@ -96,7 +96,7 @@ public class ModuleAutoCrafting extends Module {
if (crafterEjection && !freeSlotAfterRemovingIngredients) { if (crafterEjection && !freeSlotAfterRemovingIngredients) {
// TODO: Recode. Why specifically eject ingredients (allMaterials). // TODO: Recode. Why specifically eject ingredients (allMaterials).
// And why not eject when we checked crafting is possible // And why not eject when we checked crafting is possible
final List<Material> allMaterials = getRecipes(toCraft).getAllMaterials(); final List<Material> allMaterials = getRecipes(toCraft).getPossibleIngredientTypes();
if (Stream.of(hopperCache.cachedInventory) if (Stream.of(hopperCache.cachedInventory)
.allMatch(item -> item != null && allMaterials.stream().anyMatch(mat -> mat == item.getType()))) { .allMatch(item -> item != null && allMaterials.stream().anyMatch(mat -> mat == item.getType()))) {
// Crafter can't function if there's nowhere to put the output // Crafter can't function if there's nowhere to put the output
@ -167,7 +167,7 @@ public class ModuleAutoCrafting extends Module {
public List<Material> getBlockedItems(Hopper hopper) { public List<Material> getBlockedItems(Hopper hopper) {
ItemStack itemStack = getAutoCrafting(hopper); ItemStack itemStack = getAutoCrafting(hopper);
if (itemStack != null && itemStack.getType() != Material.AIR) { if (itemStack != null && itemStack.getType() != Material.AIR) {
return getRecipes(itemStack).getAllMaterials(); return getRecipes(itemStack).getPossibleIngredientTypes();
} }
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
@ -250,10 +250,9 @@ public class ModuleAutoCrafting extends Module {
} }
final static class Recipes { final static class Recipes {
// we don't actually care about the shape, just the materials used
private final List<SimpleRecipe> recipes = new ArrayList<>(); private final List<SimpleRecipe> recipes = new ArrayList<>();
private final List<Material> allTypes = new ArrayList<>(); // Used for the blacklist to ensure that items are not going to get transferred
private final List<Material> possibleIngredientTypes = new ArrayList<>();
public Recipes() { public Recipes() {
} }
@ -266,8 +265,8 @@ public class ModuleAutoCrafting extends Module {
return Collections.unmodifiableList(recipes); return Collections.unmodifiableList(recipes);
} }
public List<Material> getAllMaterials() { public List<Material> getPossibleIngredientTypes() {
return Collections.unmodifiableList(allTypes); return Collections.unmodifiableList(possibleIngredientTypes);
} }
public void addRecipe(Recipe recipe) { public void addRecipe(Recipe recipe) {
@ -284,16 +283,15 @@ public class ModuleAutoCrafting extends Module {
this.recipes.add(simpleRecipe); this.recipes.add(simpleRecipe);
// TODO: Find out what allTypes is actually for o.0 // Keep a list of all possible ingredients.
// Also keep a tally of what materials are possible for this craftable
for (SimpleRecipe.SimpleIngredient ingredient : simpleRecipe.ingredients) { for (SimpleRecipe.SimpleIngredient ingredient : simpleRecipe.ingredients) {
if (!allTypes.contains(ingredient.item.getType())) { if (!possibleIngredientTypes.contains(ingredient.item.getType())) {
allTypes.add(ingredient.item.getType()); possibleIngredientTypes.add(ingredient.item.getType());
} }
for (ItemStack material : ingredient.alternativeTypes) { for (ItemStack material : ingredient.alternativeTypes) {
if (!allTypes.contains(material.getType())) { if (!possibleIngredientTypes.contains(material.getType())) {
allTypes.add(material.getType()); possibleIngredientTypes.add(material.getType());
} }
} }
} }