aboutsummaryrefslogtreecommitdiff
path: root/default-plugin/src/main/java/me/shedaniel/rei/plugin/client
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-08-30 04:59:38 +0800
committershedaniel <daniel@shedaniel.me>2021-08-30 05:01:17 +0800
commit73200d3dd65aff8428e33312ce6a14a1dcc0b797 (patch)
treee6a73948e6bada7e84680d8e56163f6cc0399626 /default-plugin/src/main/java/me/shedaniel/rei/plugin/client
parent40f5f139812cf4a02c61fcd493e5857d77e2990d (diff)
downloadRoughlyEnoughItems-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/client')
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java6
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/anvil/DefaultAnvilCategory.java76
2 files changed, 82 insertions, 0 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
index 2bb9c0925..e469d078c 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
@@ -50,6 +50,7 @@ import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.impl.ClientInternals;
import me.shedaniel.rei.plugin.autocrafting.recipebook.DefaultRecipeBookHandler;
import me.shedaniel.rei.plugin.client.categories.*;
+import me.shedaniel.rei.plugin.client.categories.anvil.DefaultAnvilCategory;
import me.shedaniel.rei.plugin.client.categories.beacon.DefaultBeaconBaseCategory;
import me.shedaniel.rei.plugin.client.categories.beacon.DefaultBeaconPaymentCategory;
import me.shedaniel.rei.plugin.client.categories.cooking.DefaultCookingCategory;
@@ -59,6 +60,8 @@ import me.shedaniel.rei.plugin.client.exclusionzones.DefaultRecipeBookExclusionZ
import me.shedaniel.rei.plugin.client.favorites.GameModeFavoriteEntry;
import me.shedaniel.rei.plugin.client.favorites.WeatherFavoriteEntry;
import me.shedaniel.rei.plugin.common.displays.*;
+import me.shedaniel.rei.plugin.common.displays.anvil.AnvilRecipe;
+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.BrewingRecipe;
@@ -150,6 +153,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
new DefaultCompostingCategory(),
new DefaultStrippingCategory(),
new DefaultSmithingCategory(),
+ new DefaultAnvilCategory(),
new DefaultBeaconBaseCategory(),
new DefaultBeaconPaymentCategory(),
new DefaultTillingCategory(),
@@ -173,6 +177,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
registry.addWorkstations(CAMPFIRE, EntryStacks.of(Items.CAMPFIRE), EntryStacks.of(Items.SOUL_CAMPFIRE));
registry.addWorkstations(FUEL, EntryStacks.of(Items.FURNACE), EntryStacks.of(Items.SMOKER), EntryStacks.of(Items.BLAST_FURNACE));
registry.addWorkstations(BREWING, EntryStacks.of(Items.BREWING_STAND));
+ registry.addWorkstations(ANVIL, EntryStacks.of(Items.ANVIL));
registry.addWorkstations(STONE_CUTTING, EntryStacks.of(Items.STONECUTTER));
registry.addWorkstations(COMPOSTING, EntryStacks.of(Items.COMPOSTER));
registry.addWorkstations(SMITHING, EntryStacks.of(Items.SMITHING_TABLE));
@@ -222,6 +227,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
registry.registerRecipeFiller(CampfireCookingRecipe.class, RecipeType.CAMPFIRE_COOKING, DefaultCampfireDisplay::new);
registry.registerRecipeFiller(StonecutterRecipe.class, RecipeType.STONECUTTING, DefaultStoneCuttingDisplay::new);
registry.registerRecipeFiller(UpgradeRecipe.class, RecipeType.SMITHING, DefaultSmithingDisplay::new);
+ registry.registerFiller(AnvilRecipe.class, DefaultAnvilDisplay::new);
registry.registerFiller(BrewingRecipe.class, DefaultBrewingDisplay::new);
for (Map.Entry<Item, Integer> entry : AbstractFurnaceBlockEntity.getFuel().entrySet()) {
registry.add(new DefaultFuelDisplay(Collections.singletonList(EntryIngredients.of(entry.getKey())), Collections.emptyList(), entry.getValue()));
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/anvil/DefaultAnvilCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/anvil/DefaultAnvilCategory.java
new file mode 100644
index 000000000..c11893ed2
--- /dev/null
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/anvil/DefaultAnvilCategory.java
@@ -0,0 +1,76 @@
+/*
+ * 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.client.categories.anvil;
+
+import com.google.common.collect.Lists;
+import me.shedaniel.math.Point;
+import me.shedaniel.math.Rectangle;
+import me.shedaniel.rei.api.client.gui.Renderer;
+import me.shedaniel.rei.api.client.gui.widgets.Widget;
+import me.shedaniel.rei.api.client.gui.widgets.Widgets;
+import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
+import me.shedaniel.rei.api.common.category.CategoryIdentifier;
+import me.shedaniel.rei.api.common.util.EntryStacks;
+import me.shedaniel.rei.plugin.common.BuiltinPlugin;
+import me.shedaniel.rei.plugin.common.displays.anvil.DefaultAnvilDisplay;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.world.level.block.Blocks;
+
+import java.util.List;
+
+public class DefaultAnvilCategory implements DisplayCategory<DefaultAnvilDisplay> {
+ @Override
+ public CategoryIdentifier<? extends DefaultAnvilDisplay> getCategoryIdentifier() {
+ return BuiltinPlugin.ANVIL;
+ }
+
+ @Override
+ public Component getTitle() {
+ return new TranslatableComponent("block.minecraft.anvil");
+ }
+
+ @Override
+ public Renderer getIcon() {
+ return EntryStacks.of(Blocks.ANVIL);
+ }
+
+ @Override
+ public List<Widget> setupDisplay(DefaultAnvilDisplay display, Rectangle bounds) {
+ Point startPoint = new Point(bounds.getCenterX() - 31, bounds.getCenterY() - 13);
+ List<Widget> widgets = Lists.newArrayList();
+ widgets.add(Widgets.createRecipeBase(bounds));
+ widgets.add(Widgets.createArrow(new Point(startPoint.x + 27, startPoint.y + 4)));
+ widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 5)));
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 - 22, startPoint.y + 5)).entries(display.getInputEntries().get(0)).markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 4, startPoint.y + 5)).entries(display.getInputEntries().get(1)).markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 5)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput());
+ return widgets;
+ }
+
+ @Override
+ public int getDisplayHeight() {
+ return 36;
+ }
+}