diff options
Diffstat (limited to 'src/main/java/me/shedaniel/rei/plugin/crafting/DefaultShapedDisplay.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/plugin/crafting/DefaultShapedDisplay.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultShapedDisplay.java b/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultShapedDisplay.java new file mode 100644 index 000000000..20af74515 --- /dev/null +++ b/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultShapedDisplay.java @@ -0,0 +1,60 @@ +/* + * Roughly Enough Items by Danielshe. + * Licensed under the MIT License. + */ + +package me.shedaniel.rei.plugin.crafting; + +import net.minecraft.item.ItemStack; +import net.minecraft.recipe.ShapedRecipe; +import net.minecraft.util.Identifier; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +public class DefaultShapedDisplay implements DefaultCraftingDisplay<ShapedRecipe> { + + private ShapedRecipe display; + private List<List<ItemStack>> input; + private List<ItemStack> output; + + public DefaultShapedDisplay(ShapedRecipe recipe) { + this.display = recipe; + this.input = recipe.getPreviewInputs().stream().map(i -> Arrays.asList(i.getStackArray())).collect(Collectors.toList()); + this.output = Collections.singletonList(recipe.getOutput()); + } + + @Override + public Optional<Identifier> getRecipeLocation() { + return Optional.ofNullable(display).map(ShapedRecipe::getId); + } + + @Override + public List<List<ItemStack>> getInput() { + return input; + } + + @Override + public List<ItemStack> getOutput() { + return output; + } + + @Override + public List<List<ItemStack>> getRequiredItems() { + return input; + } + + @Override + public int getHeight() { + return display.getHeight(); + } + + @Override + public int getWidth() { + return display.getWidth(); + } + +} |
