diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-08-30 04:59:38 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-08-30 05:01:17 +0800 |
| commit | 73200d3dd65aff8428e33312ce6a14a1dcc0b797 (patch) | |
| tree | e6a73948e6bada7e84680d8e56163f6cc0399626 /default-plugin/src/main/java/me/shedaniel/rei/plugin/common | |
| parent | 40f5f139812cf4a02c61fcd493e5857d77e2990d (diff) | |
| download | RoughlyEnoughItems-73200d3dd65aff8428e33312ce6a14a1dcc0b797.tar.gz RoughlyEnoughItems-73200d3dd65aff8428e33312ce6a14a1dcc0b797.tar.bz2 RoughlyEnoughItems-73200d3dd65aff8428e33312ce6a14a1dcc0b797.zip | |
Support anvil recipes
Diffstat (limited to 'default-plugin/src/main/java/me/shedaniel/rei/plugin/common')
3 files changed, 86 insertions, 1 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/BuiltinPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/BuiltinPlugin.java index 94617a5a9..b0dfa5be7 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/BuiltinPlugin.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/BuiltinPlugin.java @@ -25,6 +25,7 @@ package me.shedaniel.rei.plugin.common; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.plugin.common.displays.*; +import me.shedaniel.rei.plugin.common.displays.anvil.DefaultAnvilDisplay; import me.shedaniel.rei.plugin.common.displays.beacon.DefaultBeaconBaseDisplay; import me.shedaniel.rei.plugin.common.displays.beacon.DefaultBeaconPaymentDisplay; import me.shedaniel.rei.plugin.common.displays.brewing.DefaultBrewingDisplay; @@ -45,6 +46,7 @@ public interface BuiltinPlugin { CategoryIdentifier<DefaultCompostingDisplay> COMPOSTING = CategoryIdentifier.of("minecraft", "plugins/composting"); CategoryIdentifier<DefaultFuelDisplay> FUEL = CategoryIdentifier.of("minecraft", "plugins/fuel"); CategoryIdentifier<DefaultSmithingDisplay> SMITHING = CategoryIdentifier.of("minecraft", "plugins/smithing"); + CategoryIdentifier<DefaultAnvilDisplay> ANVIL = CategoryIdentifier.of("minecraft", "plugins/anvil"); CategoryIdentifier<DefaultBeaconBaseDisplay> BEACON_BASE = CategoryIdentifier.of("minecraft", "plugins/beacon_base"); CategoryIdentifier<DefaultBeaconPaymentDisplay> BEACON_PAYMENT = CategoryIdentifier.of("minecraft", "plugins/beacon_payment"); CategoryIdentifier<DefaultTillingDisplay> TILLING = CategoryIdentifier.of("minecraft", "plugins/tilling"); diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/AnvilRecipe.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/AnvilRecipe.java index 550199a62..8c8543475 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/AnvilRecipe.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/AnvilRecipe.java @@ -23,18 +23,39 @@ package me.shedaniel.rei.plugin.common.displays.anvil; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.Nullable; import java.util.List; public class AnvilRecipe { + @Nullable + private final ResourceLocation id; private final List<ItemStack> leftInput; private final List<ItemStack> rightInputs; private final List<ItemStack> outputs; - public AnvilRecipe(List<ItemStack> leftInput, List<ItemStack> rightInputs, List<ItemStack> outputs) { + public AnvilRecipe(@Nullable ResourceLocation id, List<ItemStack> leftInput, List<ItemStack> rightInputs, List<ItemStack> outputs) { + this.id = id; this.leftInput = leftInput; this.rightInputs = rightInputs; this.outputs = outputs; } + + public ResourceLocation getId() { + return id; + } + + public List<ItemStack> getLeftInput() { + return leftInput; + } + + public List<ItemStack> getRightInputs() { + return rightInputs; + } + + public List<ItemStack> getOutputs() { + return outputs; + } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/DefaultAnvilDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/DefaultAnvilDisplay.java new file mode 100644 index 000000000..654d0bdc2 --- /dev/null +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/DefaultAnvilDisplay.java @@ -0,0 +1,62 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.shedaniel.rei.plugin.common.displays.anvil; + +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.basic.BasicDisplay; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.plugin.common.BuiltinPlugin; +import net.minecraft.resources.ResourceLocation; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +public class DefaultAnvilDisplay extends BasicDisplay { + public DefaultAnvilDisplay(AnvilRecipe recipe) { + this( + Arrays.asList( + EntryIngredients.ofItemStacks(recipe.getLeftInput()), + EntryIngredients.ofItemStacks(recipe.getRightInputs()) + ), + Collections.singletonList(EntryIngredients.ofItemStacks(recipe.getOutputs())), + Optional.ofNullable(recipe.getId()) + ); + } + + public DefaultAnvilDisplay(List<EntryIngredient> inputs, List<EntryIngredient> outputs, Optional<ResourceLocation> location) { + super(inputs, outputs, location); + } + + @Override + public CategoryIdentifier<?> getCategoryIdentifier() { + return BuiltinPlugin.ANVIL; + } + + public static BasicDisplay.Serializer<DefaultAnvilDisplay> serializer() { + return BasicDisplay.Serializer.ofSimple(DefaultAnvilDisplay::new); + } +} |
