DefaultSmithingDisplay.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package me.shedaniel.rei.plugin.smithing;
  2. import com.google.common.collect.Lists;
  3. import me.shedaniel.rei.api.EntryStack;
  4. import me.shedaniel.rei.api.RecipeDisplay;
  5. import me.shedaniel.rei.plugin.DefaultPlugin;
  6. import me.shedaniel.rei.utils.CollectionUtils;
  7. import net.minecraft.recipe.SmithingRecipe;
  8. import net.minecraft.util.Identifier;
  9. import org.jetbrains.annotations.NotNull;
  10. import org.jetbrains.annotations.Nullable;
  11. import java.util.Collections;
  12. import java.util.List;
  13. import java.util.Optional;
  14. public class DefaultSmithingDisplay implements RecipeDisplay {
  15. @NotNull
  16. private List<List<EntryStack>> input;
  17. @NotNull
  18. private List<EntryStack> output;
  19. @Nullable
  20. private Identifier location;
  21. public DefaultSmithingDisplay(@NotNull SmithingRecipe recipe) {
  22. this(
  23. Lists.newArrayList(
  24. CollectionUtils.map(recipe.base.getMatchingStacksClient(), EntryStack::create),
  25. CollectionUtils.map(recipe.addition.getMatchingStacksClient(), EntryStack::create)
  26. ),
  27. Collections.singletonList(EntryStack.create(recipe.getOutput())),
  28. recipe.getId()
  29. );
  30. }
  31. public DefaultSmithingDisplay(@NotNull List<List<EntryStack>> input, @NotNull List<EntryStack> output, @Nullable Identifier location) {
  32. this.input = input;
  33. this.output = output;
  34. if (this.input.size() != 2) throw new IllegalArgumentException("input must have 2 entries.");
  35. this.location = location;
  36. }
  37. @Override
  38. public List<List<EntryStack>> getInputEntries() {
  39. return input;
  40. }
  41. @Override
  42. public List<EntryStack> getOutputEntries() {
  43. return output;
  44. }
  45. @Override
  46. public Identifier getRecipeCategory() {
  47. return DefaultPlugin.SMITHING;
  48. }
  49. @Override
  50. public Optional<Identifier> getRecipeLocation() {
  51. return Optional.ofNullable(location);
  52. }
  53. }