DefaultSmithingDisplay.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * This file is licensed under the MIT License, part of Roughly Enough Items.
  3. * Copyright (c) 2018, 2019, 2020 shedaniel
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. package me.shedaniel.rei.plugin.smithing;
  24. import com.google.common.collect.Lists;
  25. import me.shedaniel.rei.api.EntryStack;
  26. import me.shedaniel.rei.api.RecipeDisplay;
  27. import me.shedaniel.rei.plugin.DefaultPlugin;
  28. import me.shedaniel.rei.utils.CollectionUtils;
  29. import net.minecraft.recipe.SmithingRecipe;
  30. import net.minecraft.util.Identifier;
  31. import org.jetbrains.annotations.NotNull;
  32. import org.jetbrains.annotations.Nullable;
  33. import java.util.Collections;
  34. import java.util.List;
  35. import java.util.Optional;
  36. public class DefaultSmithingDisplay implements RecipeDisplay {
  37. @NotNull
  38. private List<List<EntryStack>> input;
  39. @NotNull
  40. private List<EntryStack> output;
  41. @Nullable
  42. private Identifier location;
  43. public DefaultSmithingDisplay(@NotNull SmithingRecipe recipe) {
  44. this(
  45. Lists.newArrayList(
  46. EntryStack.create(recipe.base),
  47. EntryStack.create(recipe.addition)
  48. ),
  49. Collections.singletonList(EntryStack.create(recipe.getOutput())),
  50. recipe.getId()
  51. );
  52. }
  53. public DefaultSmithingDisplay(@NotNull List<List<EntryStack>> input, @NotNull List<EntryStack> output, @Nullable Identifier location) {
  54. this.input = input;
  55. this.output = output;
  56. if (this.input.size() != 2) throw new IllegalArgumentException("input must have 2 entries.");
  57. this.location = location;
  58. }
  59. @Override
  60. public List<List<EntryStack>> getInputEntries() {
  61. return input;
  62. }
  63. @Override
  64. public List<EntryStack> getOutputEntries() {
  65. return output;
  66. }
  67. @Override
  68. public Identifier getRecipeCategory() {
  69. return DefaultPlugin.SMITHING;
  70. }
  71. @Override
  72. public Optional<Identifier> getRecipeLocation() {
  73. return Optional.ofNullable(location);
  74. }
  75. }