From 02d1d95dd54285cc1237d1b5016401274a5ae5f0 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 25 Mar 2021 18:15:16 +0800 Subject: Refactor Default Plugin packages, fix favorites Signed-off-by: shedaniel --- .../autocrafting/DefaultRecipeBookHandler.java | 4 +- .../beacon/base/DefaultBeaconBaseCategory.java | 182 ----------- .../beacon/base/DefaultBeaconBaseDisplay.java | 64 ---- .../payment/DefaultBeaconPaymentCategory.java | 182 ----------- .../payment/DefaultBeaconPaymentDisplay.java | 64 ---- .../plugin/blasting/DefaultBlastingDisplay.java | 51 ---- .../rei/plugin/brewing/BrewingRecipe.java | 39 --- .../rei/plugin/brewing/DefaultBrewingCategory.java | 84 ------ .../rei/plugin/brewing/DefaultBrewingDisplay.java | 90 ------ .../plugin/brewing/RegisteredBrewingRecipe.java | 39 --- .../rei/plugin/client/DefaultClientPlugin.java | 101 ++++--- .../client/categories/DefaultBrewingCategory.java | 85 ++++++ .../client/categories/DefaultCampfireCategory.java | 81 +++++ .../categories/DefaultCompostingCategory.java | 124 ++++++++ .../client/categories/DefaultFuelCategory.java | 118 ++++++++ .../categories/DefaultInformationCategory.java | 216 +++++++++++++ .../client/categories/DefaultPathingCategory.java | 76 +++++ .../client/categories/DefaultSmithingCategory.java | 76 +++++ .../categories/DefaultStoneCuttingCategory.java | 80 +++++ .../categories/DefaultStrippingCategory.java | 76 +++++ .../client/categories/DefaultTillingCategory.java | 76 +++++ .../beacon/DefaultBeaconBaseCategory.java | 183 +++++++++++ .../beacon/DefaultBeaconPaymentCategory.java | 183 +++++++++++ .../categories/cooking/DefaultCookingCategory.java | 121 ++++++++ .../crafting/DefaultCraftingCategory.java | 112 +++++++ .../client/favorites/GameModeFavoriteEntry.java | 289 ++++++++++++++++++ .../client/favorites/WeatherFavoriteEntry.java | 335 +++++++++++++++++++++ .../shedaniel/rei/plugin/common/BuiltinPlugin.java | 24 +- .../shedaniel/rei/plugin/common/DefaultPlugin.java | 41 +-- .../common/campfire/DefaultCampfireCategory.java | 80 ----- .../common/campfire/DefaultCampfireDisplay.java | 73 ----- .../composting/DefaultCompostingCategory.java | 123 -------- .../composting/DefaultCompostingDisplay.java | 77 ----- .../common/cooking/DefaultCookingCategory.java | 120 -------- .../common/cooking/DefaultCookingDisplay.java | 94 ------ .../common/crafting/DefaultCraftingCategory.java | 110 ------- .../common/crafting/DefaultCraftingDisplay.java | 100 ------ .../common/crafting/DefaultCustomDisplay.java | 96 ------ .../common/crafting/DefaultShapedDisplay.java | 79 ----- .../common/crafting/DefaultShapelessDisplay.java | 79 ----- .../common/displays/DefaultCampfireDisplay.java | 73 +++++ .../common/displays/DefaultCompostingDisplay.java | 77 +++++ .../plugin/common/displays/DefaultFuelDisplay.java | 63 ++++ .../common/displays/DefaultInformationDisplay.java | 132 ++++++++ .../common/displays/DefaultPathingDisplay.java | 63 ++++ .../common/displays/DefaultSmithingDisplay.java | 66 ++++ .../displays/DefaultStoneCuttingDisplay.java | 59 ++++ .../common/displays/DefaultStrippingDisplay.java | 63 ++++ .../common/displays/DefaultTillingDisplay.java | 63 ++++ .../displays/beacon/DefaultBeaconBaseDisplay.java | 49 +++ .../displays/beacon/DefaultBeaconDisplay.java | 50 +++ .../beacon/DefaultBeaconPaymentDisplay.java | 49 +++ .../common/displays/brewing/BrewingRecipe.java | 39 +++ .../displays/brewing/DefaultBrewingDisplay.java | 94 ++++++ .../displays/cooking/DefaultBlastingDisplay.java | 50 +++ .../displays/cooking/DefaultCookingDisplay.java | 94 ++++++ .../displays/cooking/DefaultSmeltingDisplay.java | 50 +++ .../displays/cooking/DefaultSmokingDisplay.java | 47 +++ .../displays/crafting/DefaultCraftingDisplay.java | 100 ++++++ .../displays/crafting/DefaultCustomDisplay.java | 96 ++++++ .../displays/crafting/DefaultShapedDisplay.java | 79 +++++ .../displays/crafting/DefaultShapelessDisplay.java | 79 +++++ .../stonecutting/DefaultStoneCuttingCategory.java | 79 ----- .../stonecutting/DefaultStoneCuttingDisplay.java | 59 ---- .../containers/CraftingGridMenuInfoWrapper.java | 73 ----- .../shedaniel/rei/plugin/favorites/Animator.java | 97 ------ .../plugin/favorites/GameModeFavoriteEntry.java | 288 ------------------ .../rei/plugin/favorites/WeatherFavoriteEntry.java | 334 -------------------- .../rei/plugin/fuel/DefaultFuelCategory.java | 118 -------- .../rei/plugin/fuel/DefaultFuelDisplay.java | 63 ---- .../information/DefaultInformationCategory.java | 215 ------------- .../information/DefaultInformationDisplay.java | 102 ------- .../rei/plugin/pathing/DefaultPathingCategory.java | 75 ----- .../rei/plugin/pathing/DefaultPathingDisplay.java | 75 ----- .../rei/plugin/pathing/DummyShovelItem.java | 41 --- .../plugin/smelting/DefaultSmeltingDisplay.java | 51 ---- .../plugin/smithing/DefaultSmithingCategory.java | 75 ----- .../plugin/smithing/DefaultSmithingDisplay.java | 66 ---- .../rei/plugin/smoking/DefaultSmokingDisplay.java | 48 --- .../plugin/stripping/DefaultStrippingCategory.java | 75 ----- .../plugin/stripping/DefaultStrippingDisplay.java | 63 ---- .../rei/plugin/stripping/DummyAxeItem.java | 40 --- .../rei/plugin/tilling/DefaultTillingCategory.java | 75 ----- .../rei/plugin/tilling/DefaultTillingDisplay.java | 63 ---- .../shedaniel/rei/plugin/tilling/DummyHoeItem.java | 41 --- 85 files changed, 3854 insertions(+), 4124 deletions(-) delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/base/DefaultBeaconBaseCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/base/DefaultBeaconBaseDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/payment/DefaultBeaconPaymentCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/payment/DefaultBeaconPaymentDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/BrewingRecipe.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/RegisteredBrewingRecipe.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCampfireCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultFuelCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultPathingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultStoneCuttingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultStrippingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultTillingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/cooking/DefaultCookingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/crafting/DefaultCraftingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/campfire/DefaultCampfireCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/campfire/DefaultCampfireDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/composting/DefaultCompostingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/composting/DefaultCompostingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/cooking/DefaultCookingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/cooking/DefaultCookingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/crafting/DefaultCraftingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/crafting/DefaultCraftingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/crafting/DefaultCustomDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/crafting/DefaultShapedDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/crafting/DefaultShapelessDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultCampfireDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultCompostingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultFuelDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultInformationDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultPathingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultStoneCuttingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultStrippingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultTillingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/beacon/DefaultBeaconBaseDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/beacon/DefaultBeaconDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/beacon/DefaultBeaconPaymentDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/brewing/BrewingRecipe.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/brewing/DefaultBrewingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/cooking/DefaultBlastingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/cooking/DefaultCookingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/cooking/DefaultSmeltingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/cooking/DefaultSmokingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultCraftingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultCustomDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultShapedDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultShapelessDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/stonecutting/DefaultStoneCuttingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/stonecutting/DefaultStoneCuttingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/containers/CraftingGridMenuInfoWrapper.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/Animator.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/GameModeFavoriteEntry.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/favorites/WeatherFavoriteEntry.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/fuel/DefaultFuelCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/fuel/DefaultFuelDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/information/DefaultInformationDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/pathing/DefaultPathingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/pathing/DefaultPathingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/pathing/DummyShovelItem.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/smithing/DefaultSmithingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/smithing/DefaultSmithingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/stripping/DefaultStrippingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/stripping/DefaultStrippingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/stripping/DummyAxeItem.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/tilling/DefaultTillingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/tilling/DefaultTillingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/tilling/DummyHoeItem.java (limited to 'default-plugin') diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java index 797073814..07884806d 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java @@ -27,8 +27,8 @@ import me.shedaniel.rei.api.client.ClientHelper; import me.shedaniel.rei.api.client.registry.transfer.TransferHandler; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.display.SimpleMenuDisplay; -import me.shedaniel.rei.plugin.common.cooking.DefaultCookingDisplay; -import me.shedaniel.rei.plugin.common.crafting.DefaultCraftingDisplay; +import me.shedaniel.rei.plugin.common.displays.cooking.DefaultCookingDisplay; +import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCraftingDisplay; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screens.Screen; diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/base/DefaultBeaconBaseCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/base/DefaultBeaconBaseCategory.java deleted file mode 100644 index 7e27410c4..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/base/DefaultBeaconBaseCategory.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.beacon.base; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.clothconfig2.ClothConfigInitializer; -import me.shedaniel.clothconfig2.api.ScissorsHandler; -import me.shedaniel.clothconfig2.api.ScrollingContainer; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.REIHelper; -import me.shedaniel.rei.api.client.gui.DisplayRenderer; -import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.client.gui.widgets.Slot; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; -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.api.common.util.CollectionUtils; -import me.shedaniel.rei.plugin.common.BuiltinPlugin; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.util.Mth; -import net.minecraft.world.level.block.Blocks; - -import java.util.List; -import java.util.Objects; - -public class DefaultBeaconBaseCategory implements DisplayCategory { - @Override - public CategoryIdentifier getCategoryIdentifier() { - return BuiltinPlugin.BEACON_BASE; - } - - @Override - public Component getTitle() { - return new TranslatableComponent("category.rei.beacon_base"); - } - - @Override - public Renderer getIcon() { - return EntryStacks.of(Blocks.BEACON); - } - - @Override - public DisplayRenderer getDisplayRenderer(DefaultBeaconBaseDisplay display) { - Component name = getTitle(); - return new DisplayRenderer() { - @Override - public int getHeight() { - return 10 + Minecraft.getInstance().font.lineHeight; - } - - @Override - public void render(PoseStack matrices, Rectangle rectangle, int mouseX, int mouseY, float delta) { - Minecraft.getInstance().font.draw(matrices, name, rectangle.x + 5, rectangle.y + 6, -1); - } - }; - } - - @Override - public List setupDisplay(DefaultBeaconBaseDisplay display, Rectangle bounds) { - List widgets = Lists.newArrayList(); - widgets.add(Widgets.createSlot(new Point(bounds.getCenterX() - 8, bounds.y + 3)).entry(EntryStacks.of(Blocks.BEACON))); - Rectangle rectangle = new Rectangle(bounds.getCenterX() - (bounds.width / 2) - 1, bounds.y + 23, bounds.width + 2, bounds.height - 28); - widgets.add(Widgets.createSlotBase(rectangle)); - widgets.add(new ScrollableSlotsWidget(rectangle, CollectionUtils.map(display.getEntries(), t -> Widgets.createSlot(new Point(0, 0)).disableBackground().entry(t)))); - return widgets; - } - - @Override - public int getDisplayHeight() { - return 140; - } - - @Override - public int getFixedDisplaysPerPage() { - return 1; - } - - private static class ScrollableSlotsWidget extends WidgetWithBounds { - private Rectangle bounds; - private List widgets; - private final ScrollingContainer scrolling = new ScrollingContainer() { - @Override - public Rectangle getBounds() { - Rectangle bounds = ScrollableSlotsWidget.this.getBounds(); - return new Rectangle(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2); - } - - @Override - public int getMaxScrollHeight() { - return Mth.ceil(widgets.size() / 8f) * 18; - } - }; - - public ScrollableSlotsWidget(Rectangle bounds, List widgets) { - this.bounds = Objects.requireNonNull(bounds); - this.widgets = Lists.newArrayList(widgets); - } - - @Override - public boolean mouseScrolled(double double_1, double double_2, double double_3) { - if (containsMouse(double_1, double_2)) { - scrolling.offset(ClothConfigInitializer.getScrollStep() * -double_3, true); - return true; - } - return false; - } - - @Override - public Rectangle getBounds() { - return bounds; - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (scrolling.updateDraggingState(mouseX, mouseY, button)) - return true; - return super.mouseClicked(mouseX, mouseY, button); - } - - @Override - public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { - if (scrolling.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) - return true; - return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - scrolling.updatePosition(delta); - Rectangle innerBounds = scrolling.getScissorBounds(); - ScissorsHandler.INSTANCE.scissor(innerBounds); - for (int y = 0; y < Mth.ceil(widgets.size() / 8f); y++) { - for (int x = 0; x < 8; x++) { - int index = y * 8 + x; - if (widgets.size() <= index) - break; - Slot widget = widgets.get(index); - widget.getBounds().setLocation(bounds.x + 1 + x * 18, (int) (bounds.y + 1 + y * 18 - scrolling.scrollAmount)); - widget.render(matrices, mouseX, mouseY, delta); - } - } - ScissorsHandler.INSTANCE.removeLastScissor(); - ScissorsHandler.INSTANCE.scissor(scrolling.getBounds()); - scrolling.renderScrollBar(0xff000000, 1, REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); - ScissorsHandler.INSTANCE.removeLastScissor(); - } - - @Override - public List children() { - return widgets; - } - } -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/base/DefaultBeaconBaseDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/base/DefaultBeaconBaseDisplay.java deleted file mode 100644 index e7c5a53a0..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/base/DefaultBeaconBaseDisplay.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.beacon.base; - -import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.display.Display; -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.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.world.item.ItemStack; - -import java.util.Collections; -import java.util.List; - -@Environment(EnvType.CLIENT) -public class DefaultBeaconBaseDisplay implements Display { - private EntryIngredient entries; - - public DefaultBeaconBaseDisplay(List entries) { - this.entries = EntryIngredients.ofItemStacks(entries); - } - - @Override - public List getInputEntries() { - return Collections.singletonList(entries); - } - - public EntryIngredient getEntries() { - return entries; - } - - @Override - public List getOutputEntries() { - return Collections.emptyList(); - } - - @Override - public CategoryIdentifier getCategoryIdentifier() { - return BuiltinPlugin.BEACON_BASE; - } -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/payment/DefaultBeaconPaymentCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/payment/DefaultBeaconPaymentCategory.java deleted file mode 100644 index d1f146bda..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/payment/DefaultBeaconPaymentCategory.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.beacon.payment; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.vertex.PoseStack; -import me.shedaniel.clothconfig2.ClothConfigInitializer; -import me.shedaniel.clothconfig2.api.ScissorsHandler; -import me.shedaniel.clothconfig2.api.ScrollingContainer; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.REIHelper; -import me.shedaniel.rei.api.client.gui.DisplayRenderer; -import me.shedaniel.rei.api.client.gui.Renderer; -import me.shedaniel.rei.api.client.gui.widgets.Slot; -import me.shedaniel.rei.api.client.gui.widgets.Widget; -import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds; -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.api.common.util.CollectionUtils; -import me.shedaniel.rei.plugin.common.BuiltinPlugin; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.util.Mth; -import net.minecraft.world.level.block.Blocks; - -import java.util.List; -import java.util.Objects; - -public class DefaultBeaconPaymentCategory implements DisplayCategory { - @Override - public CategoryIdentifier getCategoryIdentifier() { - return BuiltinPlugin.BEACON_PAYMENT; - } - - @Override - public Component getTitle() { - return new TranslatableComponent("category.rei.beacon_payment"); - } - - @Override - public Renderer getIcon() { - return EntryStacks.of(Blocks.BEACON); - } - - @Override - public DisplayRenderer getDisplayRenderer(DefaultBeaconPaymentDisplay display) { - Component name = getTitle(); - return new DisplayRenderer() { - @Override - public int getHeight() { - return 10 + Minecraft.getInstance().font.lineHeight; - } - - @Override - public void render(PoseStack matrices, Rectangle rectangle, int mouseX, int mouseY, float delta) { - Minecraft.getInstance().font.draw(matrices, name, rectangle.x + 5, rectangle.y + 6, -1); - } - }; - } - - @Override - public List setupDisplay(DefaultBeaconPaymentDisplay display, Rectangle bounds) { - List widgets = Lists.newArrayList(); - widgets.add(Widgets.createSlot(new Point(bounds.getCenterX() - 8, bounds.y + 3)).entry(EntryStacks.of(Blocks.BEACON))); - Rectangle rectangle = new Rectangle(bounds.getCenterX() - (bounds.width / 2) - 1, bounds.y + 23, bounds.width + 2, bounds.height - 28); - widgets.add(Widgets.createSlotBase(rectangle)); - widgets.add(new ScrollableSlotsWidget(rectangle, CollectionUtils.map(display.getEntries(), t -> Widgets.createSlot(new Point(0, 0)).disableBackground().entry(t)))); - return widgets; - } - - @Override - public int getDisplayHeight() { - return 140; - } - - @Override - public int getFixedDisplaysPerPage() { - return 1; - } - - private static class ScrollableSlotsWidget extends WidgetWithBounds { - private Rectangle bounds; - private List widgets; - private final ScrollingContainer scrolling = new ScrollingContainer() { - @Override - public Rectangle getBounds() { - Rectangle bounds = ScrollableSlotsWidget.this.getBounds(); - return new Rectangle(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2); - } - - @Override - public int getMaxScrollHeight() { - return Mth.ceil(widgets.size() / 8f) * 18; - } - }; - - public ScrollableSlotsWidget(Rectangle bounds, List widgets) { - this.bounds = Objects.requireNonNull(bounds); - this.widgets = Lists.newArrayList(widgets); - } - - @Override - public boolean mouseScrolled(double double_1, double double_2, double double_3) { - if (containsMouse(double_1, double_2)) { - scrolling.offset(ClothConfigInitializer.getScrollStep() * -double_3, true); - return true; - } - return false; - } - - @Override - public Rectangle getBounds() { - return bounds; - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (scrolling.updateDraggingState(mouseX, mouseY, button)) - return true; - return super.mouseClicked(mouseX, mouseY, button); - } - - @Override - public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { - if (scrolling.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) - return true; - return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY); - } - - @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - scrolling.updatePosition(delta); - Rectangle innerBounds = scrolling.getScissorBounds(); - ScissorsHandler.INSTANCE.scissor(innerBounds); - for (int y = 0; y < Mth.ceil(widgets.size() / 8f); y++) { - for (int x = 0; x < 8; x++) { - int index = y * 8 + x; - if (widgets.size() <= index) - break; - Slot widget = widgets.get(index); - widget.getBounds().setLocation(bounds.x + 1 + x * 18, (int) (bounds.y + 1 + y * 18 - scrolling.scrollAmount)); - widget.render(matrices, mouseX, mouseY, delta); - } - } - ScissorsHandler.INSTANCE.removeLastScissor(); - ScissorsHandler.INSTANCE.scissor(scrolling.getBounds()); - scrolling.renderScrollBar(0xff000000, 1, REIHelper.getInstance().isDarkThemeEnabled() ? 0.8f : 1f); - ScissorsHandler.INSTANCE.removeLastScissor(); - } - - @Override - public List children() { - return widgets; - } - } -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/payment/DefaultBeaconPaymentDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/payment/DefaultBeaconPaymentDisplay.java deleted file mode 100644 index 157ea6474..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/beacon/payment/DefaultBeaconPaymentDisplay.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.beacon.payment; - -import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.display.Display; -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.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.world.item.ItemStack; - -import java.util.Collections; -import java.util.List; - -@Environment(EnvType.CLIENT) -public class DefaultBeaconPaymentDisplay implements Display { - private EntryIngredient entries; - - public DefaultBeaconPaymentDisplay(List entries) { - this.entries = EntryIngredients.ofItemStacks(entries); - } - - @Override - public List getInputEntries() { - return Collections.singletonList(entries); - } - - public EntryIngredient getEntries() { - return entries; - } - - @Override - public List getOutputEntries() { - return Collections.emptyList(); - } - - @Override - public CategoryIdentifier getCategoryIdentifier() { - return BuiltinPlugin.BEACON_PAYMENT; - } -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java deleted file mode 100644 index 36aaa9881..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingDisplay.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.blasting; - -import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.plugin.common.BuiltinPlugin; -import me.shedaniel.rei.plugin.common.cooking.DefaultCookingDisplay; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.item.crafting.BlastingRecipe; - -import java.util.List; - -@Environment(EnvType.CLIENT) -public class DefaultBlastingDisplay extends DefaultCookingDisplay { - public DefaultBlastingDisplay(BlastingRecipe recipe) { - super(recipe); - } - - public DefaultBlastingDisplay(List input, List output, CompoundTag tag) { - super(input, output, tag); - } - - @Override - public CategoryIdentifier getCategoryIdentifier() { - return BuiltinPlugin.BLASTING; - } -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/BrewingRecipe.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/BrewingRecipe.java deleted file mode 100644 index caa743d13..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/BrewingRecipe.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.brewing; - -import net.minecraft.world.item.Item; -import net.minecraft.world.item.crafting.Ingredient; - -public class BrewingRecipe { - public final Item input; - public final Ingredient ingredient; - public final Item output; - - public BrewingRecipe(Item input, Ingredient ingredient, Item output) { - this.input = input; - this.ingredient = ingredient; - this.output = output; - } -} \ No newline at end of file diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java deleted file mode 100644 index 6358c0f2b..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.brewing; - -import com.google.common.collect.Lists; -import me.shedaniel.math.Point; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.client.REIHelper; -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 net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.Minecraft; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.util.Mth; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.block.Blocks; - -import java.util.List; - -@Environment(EnvType.CLIENT) -public class DefaultBrewingCategory implements DisplayCategory { - @Override - public CategoryIdentifier getCategoryIdentifier() { - return BuiltinPlugin.BREWING; - } - - @Override - public Renderer getIcon() { - return EntryStacks.of(Blocks.BREWING_STAND); - } - - @Override - public Component getTitle() { - return new TranslatableComponent("category.rei.brewing"); - } - - @Override - public List setupDisplay(DefaultBrewingDisplay display, Rectangle bounds) { - Point startPoint = new Point(bounds.getCenterX() - 52, bounds.getCenterY() - 29); - List widgets = Lists.newArrayList(); - widgets.add(Widgets.createRecipeBase(bounds)); - widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { - Minecraft.getInstance().getTextureManager().bind(REIHelper.getInstance().getDefaultDisplayTexture()); - helper.blit(matrices, startPoint.x, startPoint.y, 0, 108, 103, 59); - int width = Mth.ceil(System.currentTimeMillis() / 250d % 18d); - helper.blit(matrices, startPoint.x + 44, startPoint.y + 28, 103, 163, width, 4); - })); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 1)).entry(EntryStacks.of(Items.BLAZE_POWDER)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 40, startPoint.y + 1)).entries(display.getInputEntries().get(0)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 63, startPoint.y + 1)).entries(display.getInputEntries().get(1)).disableBackground().markInput()); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 40, startPoint.y + 35)).entries(display.getOutput(0)).disableBackground().markOutput()); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 63, startPoint.y + 42)).entries(display.getOutput(1)).disableBackground().markOutput()); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 86, startPoint.y + 35)).entries(display.getOutput(2)).disableBackground().markOutput()); - return widgets; - } -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java deleted file mode 100644 index 2458b8e3d..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingDisplay.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.brewing; - -import com.google.common.collect.Lists; -import me.shedaniel.rei.api.common.category.CategoryIdentifier; -import me.shedaniel.rei.api.common.display.Display; -import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.entry.EntryStack; -import me.shedaniel.rei.api.common.util.EntryStacks; -import me.shedaniel.rei.plugin.common.BuiltinPlugin; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.ChatFormatting; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import org.jetbrains.annotations.ApiStatus; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Environment(EnvType.CLIENT) -public class DefaultBrewingDisplay implements Display { - private EntryStack output; - private EntryIngredient reactant, input; - - @ApiStatus.Internal - public DefaultBrewingDisplay(Ingredient input, Ingredient reactant, ItemStack output) { - ItemStack[] inputItems = input.getItems(); - List> i = new ArrayList<>(inputItems.length); - for (ItemStack inputItem : inputItems) { - i.add(EntryStacks.of(inputItem).tooltip(new TranslatableComponent("category.rei.brewing.input").withStyle(ChatFormatting.YELLOW))); - } - this.input = EntryIngredient.of(i); - ItemStack[] reactantStacks = reactant.getItems(); - List> r = new ArrayList<>(reactantStacks.length); - for (ItemStack stack : reactantStacks) { - r.add(EntryStacks.of(stack).tooltip(new TranslatableComponent("category.rei.brewing.reactant").withStyle(ChatFormatting.YELLOW))); - } - this.reactant = EntryIngredient.of(r); - this.output = EntryStacks.of(output).tooltip(new TranslatableComponent("category.rei.brewing.result").withStyle(ChatFormatting.YELLOW)); - } - - @Override - public List getInputEntries() { - return Lists.newArrayList(input, reactant); - } - - @Override - public List getOutputEntries() { - return Collections.singletonList(EntryIngredient.of(output)); - } - - @Override - public CategoryIdentifier getCategoryIdentifier() { - return BuiltinPlugin.BREWING; - } - - public List> getOutput(int slot) { - List> stack = new ArrayList<>(); - for (int i = 0; i < slot * 2; i++) - stack.add(EntryStack.empty()); - for (int i = 0; i < 6 - slot * 2; i++) - stack.add(output); - return stack; - } -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/RegisteredBrewingRecipe.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/RegisteredBrewingRecipe.java deleted file mode 100644 index 0a4a34846..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/brewing/RegisteredBrewingRecipe.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is licensed under the MIT License, part of Roughly Enough Items. - * Copyright (c) 2018, 2019, 2020 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.brewing; - -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; - -public class RegisteredBrewingRecipe { - public final Ingredient input; - public final Ingredient ingredient; - public final ItemStack output; - - public RegisteredBrewingRecipe(Ingredient input, Ingredient ingredient, ItemStack output) { - this.input = input; - this.ingredient = ingredient; - this.output = output; - } -} \ No newline at end of file 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 b05868492..2088d523b 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 @@ -42,51 +42,31 @@ import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry; import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; -import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.ClientInternals; import me.shedaniel.rei.plugin.autocrafting.DefaultRecipeBookHandler; -import me.shedaniel.rei.plugin.beacon.base.DefaultBeaconBaseCategory; -import me.shedaniel.rei.plugin.beacon.base.DefaultBeaconBaseDisplay; -import me.shedaniel.rei.plugin.beacon.payment.DefaultBeaconPaymentCategory; -import me.shedaniel.rei.plugin.beacon.payment.DefaultBeaconPaymentDisplay; -import me.shedaniel.rei.plugin.blasting.DefaultBlastingDisplay; -import me.shedaniel.rei.plugin.brewing.DefaultBrewingCategory; -import me.shedaniel.rei.plugin.brewing.DefaultBrewingDisplay; -import me.shedaniel.rei.plugin.brewing.RegisteredBrewingRecipe; +import me.shedaniel.rei.plugin.client.categories.*; +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; +import me.shedaniel.rei.plugin.client.categories.crafting.DefaultCraftingCategory; import me.shedaniel.rei.plugin.client.exclusionzones.DefaultPotionEffectExclusionZones; import me.shedaniel.rei.plugin.client.exclusionzones.DefaultRecipeBookExclusionZones; -import me.shedaniel.rei.plugin.common.campfire.DefaultCampfireCategory; -import me.shedaniel.rei.plugin.common.campfire.DefaultCampfireDisplay; -import me.shedaniel.rei.plugin.common.composting.DefaultCompostingCategory; -import me.shedaniel.rei.plugin.common.composting.DefaultCompostingDisplay; -import me.shedaniel.rei.plugin.common.cooking.DefaultCookingCategory; -import me.shedaniel.rei.plugin.common.crafting.DefaultCraftingCategory; -import me.shedaniel.rei.plugin.common.crafting.DefaultCustomDisplay; -import me.shedaniel.rei.plugin.common.crafting.DefaultShapedDisplay; -import me.shedaniel.rei.plugin.common.crafting.DefaultShapelessDisplay; -import me.shedaniel.rei.plugin.common.stonecutting.DefaultStoneCuttingCategory; -import me.shedaniel.rei.plugin.common.stonecutting.DefaultStoneCuttingDisplay; -import me.shedaniel.rei.plugin.favorites.GameModeFavoriteEntry; -import me.shedaniel.rei.plugin.favorites.WeatherFavoriteEntry; -import me.shedaniel.rei.plugin.fuel.DefaultFuelCategory; -import me.shedaniel.rei.plugin.fuel.DefaultFuelDisplay; -import me.shedaniel.rei.plugin.information.DefaultInformationCategory; -import me.shedaniel.rei.plugin.information.DefaultInformationDisplay; -import me.shedaniel.rei.plugin.pathing.DefaultPathingCategory; -import me.shedaniel.rei.plugin.pathing.DefaultPathingDisplay; -import me.shedaniel.rei.plugin.pathing.DummyShovelItem; -import me.shedaniel.rei.plugin.smelting.DefaultSmeltingDisplay; -import me.shedaniel.rei.plugin.smithing.DefaultSmithingCategory; -import me.shedaniel.rei.plugin.smithing.DefaultSmithingDisplay; -import me.shedaniel.rei.plugin.smoking.DefaultSmokingDisplay; -import me.shedaniel.rei.plugin.stripping.DefaultStrippingCategory; -import me.shedaniel.rei.plugin.stripping.DefaultStrippingDisplay; -import me.shedaniel.rei.plugin.stripping.DummyAxeItem; -import me.shedaniel.rei.plugin.tilling.DefaultTillingCategory; -import me.shedaniel.rei.plugin.tilling.DefaultTillingDisplay; -import me.shedaniel.rei.plugin.tilling.DummyHoeItem; +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.beacon.DefaultBeaconBaseDisplay; +import me.shedaniel.rei.plugin.common.displays.beacon.DefaultBeaconPaymentDisplay; +import me.shedaniel.rei.plugin.common.displays.brewing.BrewingRecipe; +import me.shedaniel.rei.plugin.common.displays.brewing.DefaultBrewingDisplay; +import me.shedaniel.rei.plugin.common.displays.cooking.DefaultBlastingDisplay; +import me.shedaniel.rei.plugin.common.displays.cooking.DefaultSmeltingDisplay; +import me.shedaniel.rei.plugin.common.displays.cooking.DefaultSmokingDisplay; +import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay; +import me.shedaniel.rei.plugin.common.displays.crafting.DefaultShapedDisplay; +import me.shedaniel.rei.plugin.common.displays.crafting.DefaultShapelessDisplay; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; @@ -108,8 +88,10 @@ import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.GameType; import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.ComposterBlock; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; import org.jetbrains.annotations.ApiStatus; @@ -123,10 +105,10 @@ import java.util.stream.Stream; @ApiStatus.Internal public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin { public DefaultClientPlugin() { - ClientInternals.attachInstance((Supplier) () ->this, "builtinClientPlugin"); + ClientInternals.attachInstance((Supplier) () -> this, "builtinClientPlugin"); } - public static void registerBrewingRecipe(RegisteredBrewingRecipe recipe) { + public static void registerBrewingRecipe(BrewingRecipe recipe) { DisplayRegistry.getInstance().registerDisplay(new DefaultBrewingDisplay(recipe.input, recipe.ingredient, recipe.output)); } @@ -136,7 +118,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin @Override public void registerBrewingRecipe(Ingredient input, Ingredient ingredient, ItemStack output) { - registerBrewingRecipe(new RegisteredBrewingRecipe(input, ingredient, output)); + registerBrewingRecipe(new BrewingRecipe(input, ingredient, output)); } @Override @@ -148,7 +130,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin public void registerEntries(EntryRegistry registry) { for (Item item : Registry.ITEM) { try { - registry.registerEntries(EntryStacks.ofItemStacks(registry.appendStacksForItem(item))); + registry.registerEntries(EntryIngredients.ofItemStacks(registry.appendStacksForItem(item))); } catch (Exception ignored) { registry.registerEntry(EntryStacks.of(item)); } @@ -359,7 +341,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin registry.getOrCrateSection(new TranslatableComponent(GameModeFavoriteEntry.TRANSLATION_KEY)) .add(Stream.concat( Arrays.stream(GameType.values()) - .filter(type -> type != GameType.NOT_SET), + .filter(type -> type.getId() >= 0), Stream.of((GameType) null) ).map(GameModeFavoriteEntry.Type.INSTANCE::fromArgs).toArray(FavoriteEntry[]::new)); registry.register(WeatherFavoriteEntry.ID, WeatherFavoriteEntry.Type.INSTANCE); @@ -374,4 +356,35 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin public int getPriority() { return -100; } + + public static class DummyShovelItem extends ShovelItem { + public DummyShovelItem(Tier tier, float f, float g, Properties properties) { + super(tier, f, g, properties); + } + + public static Map getPathBlocksMap() { + return FLATTENABLES; + } + } + + public static class DummyAxeItem extends AxeItem { + public DummyAxeItem(Tier tier, float f, float g, Properties properties) { + super(tier, f, g, properties); + } + + public static Map getStrippedBlocksMap() { + return STRIPABLES; + } + } + + public static class DummyHoeItem extends HoeItem { + public DummyHoeItem(Tier tier, int i, float f, Properties properties) { + super(tier, i, f, properties); + } + + public static Map getTilledBlocksMap() { + return TILLABLES; + } + } + } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java new file mode 100644 index 000000000..42434df3a --- /dev/null +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultBrewingCategory.java @@ -0,0 +1,85 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 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