getInputs is redundant with getIngredients

This commit is contained in:
Vincent Lee committed 2020-03-25 13:53:43 -05:00
1 parent ff1d8ca293
commit 80dc95684e
5 files changed
+21 -11

No files matched your search

@@ -21,6 +21,7 @@ import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.CraftingHelper;
@@ -31,12 +32,13 @@ import vazkii.botania.common.crafting.ModRecipeTypes;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
public class RecipeElvenTrade extends AbstractElvenTradeRecipe {
private final ImmutableList<ItemStack> outputs;
private final ImmutableList<Ingredient> inputs;
private final NonNullList<Ingredient> inputs;
public RecipeElvenTrade(ResourceLocation id, ItemStack output, Ingredient... inputs) {
this(id, new ItemStack[] { output }, inputs);
@@ -45,7 +47,8 @@ public class RecipeElvenTrade extends AbstractElvenTradeRecipe {
public RecipeElvenTrade(ResourceLocation id, ItemStack[] outputs, Ingredient... inputs) {
super(id);
this.outputs = ImmutableList.copyOf(outputs);
this.inputs = ImmutableList.copyOf(inputs);
this.inputs = NonNullList.create();
this.inputs.addAll(Arrays.asList(inputs));
}
@Override
@@ -98,8 +101,9 @@ public class RecipeElvenTrade extends AbstractElvenTradeRecipe {
return ModRecipeTypes.ELVEN_TRADE_SERIALIZER;
}
@Nonnull
@Override
public List<Ingredient> getInputs() {
public NonNullList<Ingredient> getIngredients() {
return inputs;
}
@@ -156,8 +160,8 @@ public class RecipeElvenTrade extends AbstractElvenTradeRecipe {
@Override
public void write(PacketBuffer buf, RecipeElvenTrade recipe) {
buf.writeVarInt(recipe.getInputs().size());
for (Ingredient input : recipe.getInputs()) {
buf.writeVarInt(recipe.getIngredients().size());
for (Ingredient input : recipe.getIngredients()) {
input.write(buf);
}
buf.writeVarInt(recipe.getOutputs().size());
@@ -89,7 +89,7 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory<AbstractElvenTr
@Override
public void setIngredients(AbstractElvenTradeRecipe recipe, IIngredients iIngredients) {
ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder();
for (Ingredient i : recipe.getInputs()) {
for (Ingredient i : recipe.getIngredients()) {
builder.add(Arrays.asList(i.getMatchingStacks()));
}
iIngredients.setInputLists(VanillaTypes.ITEM, builder.build());
@@ -41,7 +41,7 @@ public class ElvenTradeProcessor implements IComponentProcessor {
}
recipes = builder.build();
for (AbstractElvenTradeRecipe recipe : recipes) {
List<Ingredient> inputs = recipe.getInputs();
List<Ingredient> inputs = recipe.getIngredients();
for (Ingredient ingredient : inputs) {
int length = ingredient.getMatchingStacks().length;
if (length > longestIngredientSize) {
@@ -86,7 +86,7 @@ public class ElvenTradeProcessor implements IComponentProcessor {
}
private String interweaveIngredients(int inputIndex) {
List<Ingredient> recipes = this.recipes.stream().map(AbstractElvenTradeRecipe::getInputs).map(ingredients -> {
List<Ingredient> recipes = this.recipes.stream().map(AbstractElvenTradeRecipe::getIngredients).map(ingredients -> {
if (inputIndex < ingredients.size()) {
return ingredients.get(inputIndex);
} else {
@@ -6,6 +6,7 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import vazkii.botania.common.block.ModBlocks;
@@ -38,7 +39,9 @@ public abstract class AbstractElvenTradeRecipe implements IRecipe<IInventory> {
/**
* @return Preview of the inputs
*/
public abstract List<Ingredient> getInputs();
@Nonnull
@Override
public abstract NonNullList<Ingredient> getIngredients();
/**
* @return Preview of the outputs
@@ -3,11 +3,13 @@ package vazkii.botania.common.crafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.item.ItemLexicon;
import vazkii.botania.common.item.ModItems;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -23,9 +25,10 @@ public class LexiconElvenTradeRecipe extends AbstractElvenTradeRecipe {
return stack.getItem() == ModItems.lexicon && !ItemNBTHelper.getBoolean(stack, ItemLexicon.TAG_ELVEN_UNLOCK, false);
}
@Nonnull
@Override
public List<Ingredient> getInputs() {
return Collections.singletonList(Ingredient.fromItems(ModItems.lexicon));
public NonNullList<Ingredient> getIngredients() {
return NonNullList.from(Ingredient.fromItems(ModItems.lexicon));
}
@Override