Skip to content

Commit

Permalink
Use singletonList for single subtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Jul 25, 2018
1 parent 9d3ee43 commit 1f94189
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
@@ -1,7 +1,6 @@
package mezz.jei.plugins.vanilla.furnace;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import it.unimi.dsi.fastutil.ints.Int2BooleanArrayMap;
Expand All @@ -27,10 +26,15 @@ public static List<FuelRecipe> getFuelRecipes(IIngredientRegistry ingredientRegi
List<FuelRecipe> fuelRecipes = new ArrayList<>(fuelStacks.size());
for (ItemStack fuelStack : fuelStacks) {
int burnTime = TileEntityFurnace.getItemBurnTime(fuelStack);
List<ItemStack> fuels = stackHelper.getSubtypes(fuelStack);
fuels.removeIf(itemStack -> TileEntityFurnace.getItemBurnTime(itemStack) != burnTime);
List<ItemStack> subtypes = stackHelper.getSubtypes(fuelStack);
List<ItemStack> fuels = new ArrayList<>();
for (ItemStack subtype : subtypes) {
if (TileEntityFurnace.getItemBurnTime(subtype) == burnTime) {
fuels.add(subtype);
}
}
if (fuels.isEmpty()) {
fuels = Collections.singletonList(fuelStack);
fuels.add(fuelStack);
}
if (fuels.size() <= 1) {
int[] oreIDs = OreDictionary.getOreIDs(fuelStack);
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/mezz/jei/startup/StackHelper.java
Expand Up @@ -215,9 +215,7 @@ public List<ItemStack> getSubtypes(@Nullable ItemStack itemStack) {
}

if (itemStack.getItemDamage() != OreDictionary.WILDCARD_VALUE) {
List<ItemStack> subtypes = new ArrayList<>();
subtypes.add(itemStack);
return subtypes;
return Collections.singletonList(itemStack);
}

return getSubtypes(itemStack.getItem(), itemStack.getCount());
Expand Down

0 comments on commit 1f94189

Please sign in to comment.