From 23c820ea583052744232e84a6c99114223c43a69 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 25 Mar 2021 02:50:16 +0800 Subject: Refactor MenuInfo, split client and server apis, new dual PluginManager system, remove @NotNull Signed-off-by: shedaniel --- .../me/shedaniel/rei/plugin/DefaultPlugin.java | 442 --------------------- .../plugin/DefaultPotionEffectExclusionZones.java | 61 --- .../plugin/DefaultRecipeBookExclusionZones.java | 56 --- .../rei/plugin/DefaultServerContainerPlugin.java | 40 -- .../autocrafting/DefaultRecipeBookHandler.java | 30 +- .../beacon/base/DefaultBeaconBaseCategory.java | 37 +- .../beacon/base/DefaultBeaconBaseDisplay.java | 17 +- .../payment/DefaultBeaconPaymentCategory.java | 38 +- .../payment/DefaultBeaconPaymentDisplay.java | 16 +- .../plugin/blasting/DefaultBlastingDisplay.java | 19 +- .../rei/plugin/brewing/DefaultBrewingCategory.java | 20 +- .../rei/plugin/brewing/DefaultBrewingDisplay.java | 18 +- .../plugin/campfire/DefaultCampfireCategory.java | 80 ---- .../plugin/campfire/DefaultCampfireDisplay.java | 85 ---- .../rei/plugin/client/BuiltinClientPlugin.java | 53 +++ .../rei/plugin/client/DefaultClientPlugin.java | 377 ++++++++++++++++++ .../DefaultPotionEffectExclusionZones.java | 61 +++ .../DefaultRecipeBookExclusionZones.java | 56 +++ .../shedaniel/rei/plugin/common/BuiltinPlugin.java | 61 +++ .../shedaniel/rei/plugin/common/DefaultPlugin.java | 129 ++++++ .../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 ++++ .../stonecutting/DefaultStoneCuttingCategory.java | 79 ++++ .../stonecutting/DefaultStoneCuttingDisplay.java | 59 +++ .../composting/DefaultCompostingCategory.java | 122 ------ .../composting/DefaultCompostingDisplay.java | 85 ---- .../containers/CraftingContainerInfoWrapper.java | 77 ---- .../containers/CraftingGridMenuInfoWrapper.java | 73 ++++ .../rei/plugin/cooking/DefaultCookingCategory.java | 116 ------ .../rei/plugin/cooking/DefaultCookingDisplay.java | 101 ----- .../plugin/crafting/DefaultCraftingCategory.java | 122 ------ .../plugin/crafting/DefaultCraftingDisplay.java | 72 ---- .../rei/plugin/crafting/DefaultCustomDisplay.java | 110 ----- .../rei/plugin/crafting/DefaultShapedDisplay.java | 80 ---- .../plugin/crafting/DefaultShapelessDisplay.java | 84 ---- .../plugin/favorites/GameModeFavoriteEntry.java | 27 +- .../rei/plugin/favorites/WeatherFavoriteEntry.java | 27 +- .../rei/plugin/fuel/DefaultFuelCategory.java | 24 +- .../rei/plugin/fuel/DefaultFuelDisplay.java | 39 +- .../information/DefaultInformationCategory.java | 29 +- .../information/DefaultInformationDisplay.java | 19 +- .../rei/plugin/pathing/DefaultPathingCategory.java | 18 +- .../rei/plugin/pathing/DefaultPathingDisplay.java | 24 +- .../plugin/smelting/DefaultSmeltingDisplay.java | 19 +- .../plugin/smithing/DefaultSmithingCategory.java | 27 +- .../plugin/smithing/DefaultSmithingDisplay.java | 55 +-- .../rei/plugin/smoking/DefaultSmokingDisplay.java | 19 +- .../stonecutting/DefaultStoneCuttingCategory.java | 79 ---- .../stonecutting/DefaultStoneCuttingDisplay.java | 78 ---- .../plugin/stripping/DefaultStrippingCategory.java | 23 +- .../plugin/stripping/DefaultStrippingDisplay.java | 46 +-- .../rei/plugin/tilling/DefaultTillingCategory.java | 22 +- .../rei/plugin/tilling/DefaultTillingDisplay.java | 47 +-- 62 files changed, 2288 insertions(+), 2241 deletions(-) delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultServerContainerPlugin.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/BuiltinClientPlugin.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/exclusionzones/DefaultPotionEffectExclusionZones.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/client/exclusionzones/DefaultRecipeBookExclusionZones.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/BuiltinPlugin.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/DefaultPlugin.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/campfire/DefaultCampfireCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/campfire/DefaultCampfireDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/composting/DefaultCompostingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/composting/DefaultCompostingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/cooking/DefaultCookingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/cooking/DefaultCookingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/crafting/DefaultCraftingCategory.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/crafting/DefaultCraftingDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/crafting/DefaultCustomDisplay.java create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/crafting/DefaultShapedDisplay.java create 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/stonecutting/DefaultStoneCuttingCategory.java create 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/composting/DefaultCompostingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/containers/CraftingContainerInfoWrapper.java create 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/cooking/DefaultCookingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/cooking/DefaultCookingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCustomDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultShapedDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultShapelessDisplay.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/stonecutting/DefaultStoneCuttingCategory.java delete mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/stonecutting/DefaultStoneCuttingDisplay.java (limited to 'default-plugin/src') diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java deleted file mode 100644 index 5bd37fb6a..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java +++ /dev/null @@ -1,442 +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; - -import com.google.common.collect.Iterators; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import it.unimi.dsi.fastutil.objects.Object2FloatMap; -import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; -import it.unimi.dsi.fastutil.objects.ReferenceSet; -import me.shedaniel.architectury.hooks.FluidStackHooks; -import me.shedaniel.architectury.platform.Platform; -import me.shedaniel.architectury.utils.NbtType; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.REIHelper; -import me.shedaniel.rei.api.favorites.FavoriteEntry; -import me.shedaniel.rei.api.favorites.FavoriteEntryType; -import me.shedaniel.rei.api.fluid.FluidSupportProvider; -import me.shedaniel.rei.api.ingredient.EntryIngredient; -import me.shedaniel.rei.api.ingredient.entry.comparison.ItemComparator; -import me.shedaniel.rei.api.ingredient.entry.comparison.ItemComparatorRegistry; -import me.shedaniel.rei.api.ingredient.util.EntryIngredients; -import me.shedaniel.rei.api.ingredient.util.EntryStacks; -import me.shedaniel.rei.api.plugins.BuiltinPlugin; -import me.shedaniel.rei.api.plugins.REIPlugin; -import me.shedaniel.rei.api.registry.category.CategoryRegistry; -import me.shedaniel.rei.api.registry.display.DisplayRegistry; -import me.shedaniel.rei.api.registry.entry.EntryRegistry; -import me.shedaniel.rei.api.registry.screen.DisplayBoundsProvider; -import me.shedaniel.rei.api.registry.screen.ExclusionZones; -import me.shedaniel.rei.api.registry.screen.ScreenRegistry; -import me.shedaniel.rei.api.registry.transfer.TransferHandlerRegistry; -import me.shedaniel.rei.api.subsets.SubsetsRegistry; -import me.shedaniel.rei.api.util.CollectionUtils; -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.campfire.DefaultCampfireCategory; -import me.shedaniel.rei.plugin.campfire.DefaultCampfireDisplay; -import me.shedaniel.rei.plugin.composting.DefaultCompostingCategory; -import me.shedaniel.rei.plugin.composting.DefaultCompostingDisplay; -import me.shedaniel.rei.plugin.cooking.DefaultCookingCategory; -import me.shedaniel.rei.plugin.crafting.DefaultCraftingCategory; -import me.shedaniel.rei.plugin.crafting.DefaultCustomDisplay; -import me.shedaniel.rei.plugin.crafting.DefaultShapedDisplay; -import me.shedaniel.rei.plugin.crafting.DefaultShapelessDisplay; -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.stonecutting.DefaultStoneCuttingCategory; -import me.shedaniel.rei.plugin.stonecutting.DefaultStoneCuttingDisplay; -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 net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.gui.screens.inventory.*; -import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; -import net.minecraft.core.Registry; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.BlockTags; -import net.minecraft.tags.ItemTags; -import net.minecraft.tags.Tag; -import net.minecraft.tags.TagCollection; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.item.*; -import net.minecraft.world.item.alchemy.Potion; -import net.minecraft.world.item.alchemy.PotionBrewing; -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.ComposterBlock; -import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; -import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.material.FluidState; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.ApiStatus; - -import java.util.*; -import java.util.function.Function; -import java.util.function.ToLongFunction; -import java.util.function.UnaryOperator; -import java.util.stream.Stream; - -import static me.shedaniel.rei.impl.Internals.attachInstance; - -@Environment(EnvType.CLIENT) -@ApiStatus.Internal -public class DefaultPlugin implements REIPlugin, BuiltinPlugin { - private static final Logger LOGGER = LogManager.getFormatterLogger("REI/DefaultPlugin"); - public static final ResourceLocation CRAFTING = BuiltinPlugin.CRAFTING; - public static final ResourceLocation SMELTING = BuiltinPlugin.SMELTING; - public static final ResourceLocation SMOKING = BuiltinPlugin.SMOKING; - public static final ResourceLocation BLASTING = BuiltinPlugin.BLASTING; - public static final ResourceLocation CAMPFIRE = BuiltinPlugin.CAMPFIRE; - public static final ResourceLocation STONE_CUTTING = BuiltinPlugin.STONE_CUTTING; - public static final ResourceLocation STRIPPING = BuiltinPlugin.STRIPPING; - public static final ResourceLocation BREWING = BuiltinPlugin.BREWING; - public static final ResourceLocation COMPOSTING = BuiltinPlugin.COMPOSTING; - public static final ResourceLocation FUEL = BuiltinPlugin.FUEL; - public static final ResourceLocation SMITHING = BuiltinPlugin.SMITHING; - public static final ResourceLocation BEACON = BuiltinPlugin.BEACON; - public static final ResourceLocation BEACON_PAYMENT = BuiltinPlugin.BEACON_PAYMENT; - public static final ResourceLocation TILLING = BuiltinPlugin.TILLING; - public static final ResourceLocation PATHING = BuiltinPlugin.PATHING; - public static final ResourceLocation INFO = BuiltinPlugin.INFO; - private static final ResourceLocation DISPLAY_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/display.png"); - private static final ResourceLocation DISPLAY_TEXTURE_DARK = new ResourceLocation("roughlyenoughitems", "textures/gui/display_dark.png"); - - public static ResourceLocation getDisplayTexture() { - return REIHelper.getInstance().getDefaultDisplayTexture(); - } - - public DefaultPlugin() { - attachInstance(this, BuiltinPlugin.class); - } - - public static void registerBrewingRecipe(RegisteredBrewingRecipe recipe) { - DisplayRegistry.getInstance().registerDisplay(new DefaultBrewingDisplay(recipe.input, recipe.ingredient, recipe.output)); - } - - public static void registerInfoDisplay(DefaultInformationDisplay display) { - DisplayRegistry.getInstance().registerDisplay(display); - } - - @Override - public void registerBrewingRecipe(Ingredient input, Ingredient ingredient, ItemStack output) { - registerBrewingRecipe(new RegisteredBrewingRecipe(input, ingredient, output)); - } - - @Override - public void registerInformation(EntryIngredient ingredient, Component name, UnaryOperator> textBuilder) { - registerInfoDisplay(DefaultInformationDisplay.createFromEntries(ingredient, name).lines(textBuilder.apply(Lists.newArrayList()))); - } - - @Override - public void registerEntries(EntryRegistry registry) { - for (Item item : Registry.ITEM) { - try { - registry.registerEntries(EntryStacks.ofItemStacks(registry.appendStacksForItem(item))); - } catch (Exception ignored) { - registry.registerEntry(EntryStacks.of(item)); - } - } - for (Fluid fluid : Registry.FLUID) { - FluidState state = fluid.defaultFluidState(); - if (!state.isEmpty() && state.isSource()) { - registry.registerEntry(EntryStacks.of(fluid)); - } - } - } - - @Override - public void registerItemComparators(ItemComparatorRegistry registry) { - ToLongFunction nbtHasher = ItemComparator.nbtHasher(); - Function enchantmentTag = stack -> { - CompoundTag tag = stack.getTag(); - if (tag == null) return null; - if (!tag.contains("Enchantments", NbtType.LIST)) return null; - return tag.getList("Enchantments", NbtType.COMPOUND); - }; - registry.register(stack -> nbtHasher.applyAsLong(enchantmentTag.apply(stack)), Items.ENCHANTED_BOOK); - registry.registerNbt(Items.POTION); - registry.registerNbt(Items.SPLASH_POTION); - registry.registerNbt(Items.LINGERING_POTION); - registry.registerNbt(Items.TIPPED_ARROW); - } - - @Override - public void registerCategories(CategoryRegistry registry) { - registry.register( - new DefaultCraftingCategory(), - new DefaultCookingCategory(SMELTING, EntryStacks.of(Items.FURNACE), "category.rei.smelting"), - new DefaultCookingCategory(SMOKING, EntryStacks.of(Items.SMOKER), "category.rei.smoking"), - new DefaultCookingCategory(BLASTING, EntryStacks.of(Items.BLAST_FURNACE), "category.rei.blasting"), new DefaultCampfireCategory(), - new DefaultStoneCuttingCategory(), - new DefaultFuelCategory(), - new DefaultBrewingCategory(), - new DefaultCompostingCategory(), - new DefaultStrippingCategory(), - new DefaultSmithingCategory(), - new DefaultBeaconBaseCategory(), - new DefaultBeaconPaymentCategory(), - new DefaultTillingCategory(), - new DefaultPathingCategory(), - new DefaultInformationCategory() - ); - - registry.removePlusButton(FUEL); - registry.removePlusButton(COMPOSTING); - registry.removePlusButton(BEACON); - registry.removePlusButton(BEACON_PAYMENT); - registry.removePlusButton(INFO); - registry.removePlusButton(STRIPPING); - registry.removePlusButton(TILLING); - registry.removePlusButton(PATHING); - - registry.addWorkstations(CRAFTING, EntryStacks.of(Items.CRAFTING_TABLE)); - registry.addWorkstations(SMELTING, EntryStacks.of(Items.FURNACE)); - registry.addWorkstations(SMOKING, EntryStacks.of(Items.SMOKER)); - registry.addWorkstations(BLASTING, EntryStacks.of(Items.BLAST_FURNACE)); - 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(STONE_CUTTING, EntryStacks.of(Items.STONECUTTER)); - registry.addWorkstations(COMPOSTING, EntryStacks.of(Items.COMPOSTER)); - registry.addWorkstations(SMITHING, EntryStacks.of(Items.SMITHING_TABLE)); - registry.addWorkstations(BEACON, EntryStacks.of(Items.BEACON)); - registry.addWorkstations(BEACON_PAYMENT, EntryStacks.of(Items.BEACON)); - - Set axes = Sets.newHashSet(), hoes = Sets.newHashSet(), shovels = Sets.newHashSet(); - EntryRegistry.getInstance().getEntryStacks().filter(stack -> stack.getValueType() == ItemStack.class).map(stack -> ((ItemStack) stack.getValue()).getItem()).forEach(item -> { - if (item instanceof AxeItem && axes.add(item)) { - registry.addWorkstations(STRIPPING, EntryStacks.of(item)); - } - if (item instanceof HoeItem && hoes.add(item)) { - registry.addWorkstations(TILLING, EntryStacks.of(item)); - } - if (item instanceof ShovelItem && shovels.add(item)) { - registry.addWorkstations(PATHING, EntryStacks.of(item)); - } - }); - TagCollection itemTagCollection = Minecraft.getInstance().getConnection().getTags().getItems(); - Tag axesTag = itemTagCollection.getTag(new ResourceLocation("c", "axes")); - if (axesTag != null) { - for (Item item : axesTag.getValues()) { - if (axes.add(item)) registry.addWorkstations(STRIPPING, EntryStacks.of(item)); - } - } - Tag hoesTag = itemTagCollection.getTag(new ResourceLocation("c", "hoes")); - if (hoesTag != null) { - for (Item item : hoesTag.getValues()) { - if (hoes.add(item)) registry.addWorkstations(TILLING, EntryStacks.of(item)); - } - } - Tag shovelsTag = itemTagCollection.getTag(new ResourceLocation("c", "shovels")); - if (shovelsTag != null) { - for (Item item : shovelsTag.getValues()) { - if (shovels.add(item)) registry.addWorkstations(PATHING, EntryStacks.of(item)); - } - } - } - - @Override - public void registerDisplays(DisplayRegistry registry) { - registry.registerFiller(ShapelessRecipe.class, DefaultShapelessDisplay::new); - registry.registerFiller(ShapedRecipe.class, DefaultShapedDisplay::new); - registry.registerFiller(SmeltingRecipe.class, DefaultSmeltingDisplay::new); - registry.registerFiller(SmokingRecipe.class, DefaultSmokingDisplay::new); - registry.registerFiller(BlastingRecipe.class, DefaultBlastingDisplay::new); - registry.registerFiller(CampfireCookingRecipe.class, DefaultCampfireDisplay::new); - registry.registerFiller(StonecutterRecipe.class, DefaultStoneCuttingDisplay::new); - registry.registerFiller(UpgradeRecipe.class, DefaultSmithingDisplay::new); - for (Map.Entry entry : AbstractFurnaceBlockEntity.getFuel().entrySet()) { - registry.registerDisplay(new DefaultFuelDisplay(EntryIngredients.of(entry.getKey()), entry.getValue())); - } - EntryIngredient arrowStack = EntryIngredient.of(EntryStacks.of(Items.ARROW)); - ReferenceSet registeredPotions = new ReferenceOpenHashSet<>(); - EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValue() == Items.LINGERING_POTION).forEach(entry -> { - ItemStack itemStack = (ItemStack) entry.getValue(); - Potion potion = PotionUtils.getPotion(itemStack); - if (registeredPotions.add(potion)) { - List input = new ArrayList<>(); - for (int i = 0; i < 4; i++) - input.add(arrowStack); - input.add(EntryIngredient.of(EntryStacks.of(itemStack))); - for (int i = 0; i < 4; i++) - input.add(arrowStack); - ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8); - PotionUtils.setPotion(outputStack, potion); - PotionUtils.setCustomEffects(outputStack, PotionUtils.getCustomEffects(itemStack)); - EntryIngredient output = EntryIngredient.of(EntryStacks.of(outputStack)); - registry.registerDisplay(new DefaultCustomDisplay(null, input, output)); - } - }); - if (ComposterBlock.COMPOSTABLES.isEmpty()) - ComposterBlock.bootStrap(); - Object2FloatMap compostables = ComposterBlock.COMPOSTABLES; - int i = 0; - Iterator>> iterator = Iterators.partition(compostables.object2FloatEntrySet().stream().sorted(Map.Entry.comparingByValue()).iterator(), 48); - while (iterator.hasNext()) { - List> entries = iterator.next(); - registry.registerDisplay(new DefaultCompostingDisplay(i, entries, compostables, new ItemStack(Items.BONE_MEAL))); - i++; - } - DummyAxeItem.getStrippedBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> { - registry.registerDisplay(new DefaultStrippingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue()))); - }); - DummyHoeItem.getTilledBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> { - registry.registerDisplay(new DefaultTillingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue().getBlock()))); - }); - DummyShovelItem.getPathBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> { - registry.registerDisplay(new DefaultPathingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue().getBlock()))); - }); - registry.registerDisplay(new DefaultBeaconBaseDisplay(CollectionUtils.map(Lists.newArrayList(BlockTags.BEACON_BASE_BLOCKS.getValues()), ItemStack::new))); - registry.registerDisplay(new DefaultBeaconPaymentDisplay(CollectionUtils.map(Lists.newArrayList(ItemTags.BEACON_PAYMENT_ITEMS.getValues()), ItemStack::new))); - if (Platform.isFabric()) { - Set potions = Sets.newLinkedHashSet(); - for (Ingredient container : PotionBrewing.ALLOWED_CONTAINERS) { - for (PotionBrewing.Mix mix : PotionBrewing.POTION_MIXES) { - Potion from = mix.from; - Ingredient ingredient = mix.ingredient; - Potion to = mix.to; - Ingredient base = Ingredient.of(Arrays.stream(container.getItems()) - .map(ItemStack::copy) - .map(stack -> PotionUtils.setPotion(stack, from))); - ItemStack output = Arrays.stream(container.getItems()) - .map(ItemStack::copy) - .map(stack -> PotionUtils.setPotion(stack, to)) - .findFirst().orElse(ItemStack.EMPTY); - registerBrewingRecipe(base, ingredient, output); - potions.add(from); - potions.add(to); - } - } - for (Potion potion : potions) { - for (PotionBrewing.Mix mix : PotionBrewing.CONTAINER_MIXES) { - Item from = mix.from; - Ingredient ingredient = mix.ingredient; - Item to = mix.to; - Ingredient base = Ingredient.of(PotionUtils.setPotion(new ItemStack(from), potion)); - ItemStack output = PotionUtils.setPotion(new ItemStack(to), potion); - registerBrewingRecipe(base, ingredient, output); - } - } - } - } - - @Override - public void registerExclusionZones(ExclusionZones zones) { - zones.register(EffectRenderingInventoryScreen.class, new DefaultPotionEffectExclusionZones()); - zones.register(RecipeUpdateListener.class, new DefaultRecipeBookExclusionZones()); - } - - @Override - public void registerScreens(ScreenRegistry registry) { - registry.registerDecider(new DisplayBoundsProvider>() { - @Override - public Rectangle getScreenBounds(AbstractContainerScreen screen) { - return new Rectangle(screen.leftPos, screen.topPos, screen.imageWidth, screen.imageHeight); - } - - @Override - public boolean isHandingScreen(Class screen) { - return AbstractContainerScreen.class.isAssignableFrom(screen); - } - }); - - registry.registerContainerClickArea(new Rectangle(88, 32, 28, 23), CraftingScreen.class, CRAFTING); - registry.registerContainerClickArea(new Rectangle(137, 29, 10, 13), InventoryScreen.class, CRAFTING); - registry.registerContainerClickArea(new Rectangle(97, 16, 14, 30), BrewingStandScreen.class, BREWING); - registry.registerContainerClickArea(new Rectangle(78, 32, 28, 23), FurnaceScreen.class, SMELTING); - registry.registerContainerClickArea(new Rectangle(78, 32, 28, 23), SmokerScreen.class, SMOKING); - registry.registerContainerClickArea(new Rectangle(78, 32, 28, 23), BlastFurnaceScreen.class, BLASTING); - } - - @Override - public void registerFluidSupport(FluidSupportProvider support) { - support.register(entry -> { - ItemStack stack = entry.getValue(); - if (stack.getItem() instanceof BucketItem) - return InteractionResultHolder.success(Stream.of(EntryStacks.of(((BucketItem) stack.getItem()).content, FluidStackHooks.bucketAmount()))); - return InteractionResultHolder.pass(null); - }); - } - - @Override - public void registerTransferHandlers(TransferHandlerRegistry registry) { - registry.register(new DefaultRecipeBookHandler()); - } - - @Override - public void registerFavorites(FavoriteEntryType.Registry registry) { - registry.register(GameModeFavoriteEntry.ID, GameModeFavoriteEntry.Type.INSTANCE); - registry.getOrCrateSection(new TranslatableComponent(GameModeFavoriteEntry.TRANSLATION_KEY)) - .add(Stream.concat( - Arrays.stream(GameType.values()) - .filter(type -> type != GameType.NOT_SET), - Stream.of((GameType) null) - ).map(GameModeFavoriteEntry.Type.INSTANCE::fromArgs).toArray(FavoriteEntry[]::new)); - registry.register(WeatherFavoriteEntry.ID, WeatherFavoriteEntry.Type.INSTANCE); - registry.getOrCrateSection(new TranslatableComponent(WeatherFavoriteEntry.TRANSLATION_KEY)) - .add(Stream.concat( - Arrays.stream(WeatherFavoriteEntry.Weather.values()), - Stream.of((WeatherFavoriteEntry.Weather) null) - ).map(WeatherFavoriteEntry.Type.INSTANCE::fromArgs).toArray(FavoriteEntry[]::new)); - } - - @Override - public int getPriority() { - return -100; - } - -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java deleted file mode 100644 index 49f8bad48..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java +++ /dev/null @@ -1,61 +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; - -import com.google.common.collect.Ordering; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.registry.screen.ExclusionZonesProvider; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; -import net.minecraft.world.effect.MobEffectInstance; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -@Environment(EnvType.CLIENT) -public class DefaultPotionEffectExclusionZones implements ExclusionZonesProvider> { - @Override - public Collection provide(EffectRenderingInventoryScreen screen) { - if (!screen.doRenderEffects) - return Collections.emptyList(); - Collection activePotionEffects = Minecraft.getInstance().player.getActiveEffects(); - if (activePotionEffects.isEmpty()) - return Collections.emptyList(); - List zones = new ArrayList<>(); - int x = screen.leftPos - 124; - int y = screen.topPos; - int height = 33; - if (activePotionEffects.size() > 5) - height = 132 / (activePotionEffects.size() - 1); - for (MobEffectInstance instance : Ordering.natural().sortedCopy(activePotionEffects)) { - zones.add(new Rectangle(x, y, 166, height)); - y += height; - } - return zones; - } -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java deleted file mode 100644 index 0e3b3c956..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java +++ /dev/null @@ -1,56 +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; - -import com.google.common.collect.Lists; -import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.registry.screen.ExclusionZonesProvider; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; -import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent; -import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; -import net.minecraft.world.inventory.RecipeBookMenu; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -@Environment(EnvType.CLIENT) -public class DefaultRecipeBookExclusionZones implements ExclusionZonesProvider { - @Override - public Collection provide(RecipeUpdateListener screen) { - if (!(screen instanceof AbstractContainerScreen) || !(((AbstractContainerScreen) screen).getMenu() instanceof RecipeBookMenu) || - !Minecraft.getInstance().player.getRecipeBook().isOpen(((RecipeBookMenu) ((AbstractContainerScreen) screen).getMenu()).getRecipeBookType())) - return Collections.emptyList(); - RecipeBookComponent recipeBookWidget = screen.getRecipeBookComponent(); - AbstractContainerScreen containerScreen = (AbstractContainerScreen) screen; - List l = Lists.newArrayList(new Rectangle(containerScreen.leftPos - 4 - 145, containerScreen.topPos, 4 + 145 + 30, containerScreen.imageHeight)); - int size = recipeBookWidget.tabButtons.size(); - if (size > 0) - l.add(new Rectangle(containerScreen.leftPos - 4 - 145 - 30, containerScreen.topPos, 30, size * 27)); - return l; - } -} diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultServerContainerPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultServerContainerPlugin.java deleted file mode 100644 index 20a6f6b8c..000000000 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/DefaultServerContainerPlugin.java +++ /dev/null @@ -1,40 +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; - -import me.shedaniel.rei.api.server.ContainerInfoHandler; -import me.shedaniel.rei.plugin.containers.CraftingContainerInfoWrapper; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.inventory.*; - -public class DefaultServerContainerPlugin implements Runnable { - @Override - public void run() { - ContainerInfoHandler.registerContainerInfo(new ResourceLocation("minecraft", "plugins/crafting"), CraftingContainerInfoWrapper.create(CraftingMenu.class)); - ContainerInfoHandler.registerContainerInfo(new ResourceLocation("minecraft", "plugins/crafting"), CraftingContainerInfoWrapper.create(InventoryMenu.class)); - ContainerInfoHandler.registerContainerInfo(new ResourceLocation("minecraft", "plugins/smelting"), CraftingContainerInfoWrapper.create(FurnaceMenu.class)); - ContainerInfoHandler.registerContainerInfo(new ResourceLocation("minecraft", "plugins/smoking"), CraftingContainerInfoWrapper.create(SmokerMenu.class)); - ContainerInfoHandler.registerContainerInfo(new ResourceLocation("minecraft", "plugins/blasting"), CraftingContainerInfoWrapper.create(BlastFurnaceMenu.class)); - } -} 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 5c46645dc..797073814 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 @@ -23,34 +23,32 @@ package me.shedaniel.rei.plugin.autocrafting; -import me.shedaniel.rei.api.ClientHelper; -import me.shedaniel.rei.api.registry.display.Display; -import me.shedaniel.rei.api.registry.display.TransferDisplay; -import me.shedaniel.rei.api.registry.transfer.TransferHandler; -import me.shedaniel.rei.plugin.cooking.DefaultCookingDisplay; -import me.shedaniel.rei.plugin.crafting.DefaultCraftingDisplay; +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 net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener; -import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.inventory.CraftingMenu; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.inventory.RecipeBookMenu; import net.minecraft.world.item.crafting.Recipe; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class DefaultRecipeBookHandler implements TransferHandler { - @NotNull @Override - public Result handle(@NotNull Context context) { - if (context.getDisplay() instanceof TransferDisplay && ClientHelper.getInstance().canUseMovePackets()) + public Result handle(Context context) { + if (context.getDisplay() instanceof SimpleMenuDisplay && ClientHelper.getInstance().canUseMovePackets()) return Result.createNotApplicable(); Display display = context.getDisplay(); - if (!(context.getContainer() instanceof RecipeBookMenu)) + if (!(context.getMenu() instanceof RecipeBookMenu)) return Result.createNotApplicable(); - RecipeBookMenu container = (RecipeBookMenu) context.getContainer(); + RecipeBookMenu container = (RecipeBookMenu) context.getMenu(); if (container == null) return Result.createNotApplicable(); if (display instanceof DefaultCraftingDisplay) { @@ -68,9 +66,9 @@ public class DefaultRecipeBookHandler implements TransferHandler { return Result.createNotApplicable(); Recipe recipe = (craftingDisplay).getOptionalRecipe().get(); if (craftingDisplay.getHeight() > h || craftingDisplay.getWidth() > w) - return Result.createFailed(I18n.get("error.rei.transfer.too_small", h, w)); + return Result.createFailed(new TranslatableComponent("error.rei.transfer.too_small", h, w)); if (!context.getMinecraft().player.getRecipeBook().contains(recipe)) - return Result.createFailed(I18n.get("error.rei.recipe.not.unlocked")); + return Result.createFailed(new TranslatableComponent("error.rei.recipe.not.unlocked")); if (!context.isActuallyCrafting()) return Result.createSuccessful(); context.getMinecraft().setScreen(context.getContainerScreen()); @@ -84,7 +82,7 @@ public class DefaultRecipeBookHandler implements TransferHandler { if (defaultDisplay.getOptionalRecipe().isPresent()) { Recipe recipe = (defaultDisplay).getOptionalRecipe().get(); if (!context.getMinecraft().player.getRecipeBook().contains(recipe)) - return Result.createFailed(I18n.get("error.rei.recipe.not.unlocked")); + return Result.createFailed(new TranslatableComponent("error.rei.recipe.not.unlocked")); if (!context.isActuallyCrafting()) return Result.createSuccessful(); context.getMinecraft().setScreen(context.getContainerScreen()); 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 index 5c7d1cd1f..c9d29c584 100644 --- 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 @@ -30,48 +30,46 @@ 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.REIHelper; -import me.shedaniel.rei.api.gui.DisplayRenderer; -import me.shedaniel.rei.api.gui.Renderer; -import me.shedaniel.rei.api.gui.widgets.Slot; -import me.shedaniel.rei.api.gui.widgets.Widget; -import me.shedaniel.rei.api.gui.widgets.WidgetWithBounds; -import me.shedaniel.rei.api.gui.widgets.Widgets; -import me.shedaniel.rei.api.ingredient.util.EntryStacks; -import me.shedaniel.rei.api.registry.display.DisplayCategory; -import me.shedaniel.rei.api.util.CollectionUtils; -import me.shedaniel.rei.plugin.DefaultPlugin; +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.ingredient.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.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.level.block.Blocks; -import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.Objects; public class DefaultBeaconBaseCategory implements DisplayCategory { @Override - public @NotNull ResourceLocation getIdentifier() { - return DefaultPlugin.BEACON; + public CategoryIdentifier getCategoryIdentifier() { + return BuiltinPlugin.BEACON_BASE; } @Override - public @NotNull Component getTitle() { + public Component getTitle() { return new TranslatableComponent("category.rei.beacon_base"); } @Override - @NotNull public Renderer getIcon() { return EntryStacks.of(Blocks.BEACON); } @Override - public @NotNull DisplayRenderer getDisplayRenderer(DefaultBeaconBaseDisplay display) { + public DisplayRenderer getDisplayRenderer(DefaultBeaconBaseDisplay display) { Component name = getTitle(); return new DisplayRenderer() { @Override @@ -87,7 +85,7 @@ public class DefaultBeaconBaseCategory implements DisplayCategory setupDisplay(DefaultBeaconBaseDisplay display, Rectangle bounds) { + 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); @@ -136,7 +134,6 @@ public class DefaultBeaconBaseCategory implements DisplayCategory getResultingEntries() { + public List getOutputEntries() { return Collections.emptyList(); } @Override - public @NotNull ResourceLocation getCategoryIdentifier() { - return DefaultPlugin.BEACON; + 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 index 690062ec7..32ca31de3 100644 --- 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 @@ -30,47 +30,46 @@ 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.REIHelper; -import me.shedaniel.rei.api.gui.DisplayRenderer; -import me.shedaniel.rei.api.gui.Renderer; -import me.shedaniel.rei.api.gui.widgets.Slot; -import me.shedaniel.rei.api.gui.widgets.Widget; -import me.shedaniel.rei.api.gui.widgets.WidgetWithBounds; -import me.shedaniel.rei.api.gui.widgets.Widgets; -import me.shedaniel.rei.api.ingredient.util.EntryStacks; -import me.shedaniel.rei.api.registry.display.DisplayCategory; -import me.shedaniel.rei.api.util.CollectionUtils; -import me.shedaniel.rei.plugin.DefaultPlugin; +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.ingredient.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.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.level.block.Blocks; -import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.Objects; public class DefaultBeaconPaymentCategory implements DisplayCategory { @Override - public @NotNull ResourceLocation getIdentifier() { - return DefaultPlugin.BEACON_PAYMENT; + public CategoryIdentifier getCategoryIdentifier() { + return BuiltinPlugin.BEACON_PAYMENT; } @Override - public @NotNull Component getTitle() { + public Component getTitle() { return new TranslatableComponent("category.rei.beacon_payment"); } @Override - public @NotNull Renderer getIcon() { + public Renderer getIcon() { return EntryStacks.of(Blocks.BEACON); } @Override - public @NotNull DisplayRenderer getDisplayRenderer(DefaultBeaconPaymentDisplay display) { + public DisplayRenderer getDisplayRenderer(DefaultBeaconPaymentDisplay display) { Component name = getTitle(); return new DisplayRenderer() { @Override @@ -86,7 +85,7 @@ public class DefaultBeaconPaymentCategory implements DisplayCategory setupDisplay(DefaultBeaconPaymentDisplay display, Rectangle bounds) { + 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); @@ -135,7 +134,6 @@ public class DefaultBeaconPaymentCategory implements DisplayCategory getResultingEntries() { + public List getOutputEntries() { return Collections.emptyList(); } @Override - public ResourceLocation getCategoryIdentifier() { - return DefaultPlugin.BEACON_PAYMENT; + 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 index b579fbc3f..a51a69e60 100644 --- 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 @@ -23,13 +23,16 @@ package me.shedaniel.rei.plugin.blasting; -import me.shedaniel.rei.plugin.DefaultPlugin; -import me.shedaniel.rei.plugin.cooking.DefaultCookingDisplay; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.ingredient.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.resources.ResourceLocation; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.crafting.BlastingRecipe; -import org.jetbrains.annotations.NotNull; + +import java.util.List; @Environment(EnvType.CLIENT) public class DefaultBlastingDisplay extends DefaultCookingDisplay { @@ -37,8 +40,12 @@ public class DefaultBlastingDisplay extends DefaultCookingDisplay { super(recipe); } + public DefaultBlastingDisplay(List input, List output, CompoundTag tag) { + super(input, output, tag); + } + @Override - public @NotNull ResourceLocation getCategoryIdentifier() { - return DefaultPlugin.BLASTING; + public CategoryIdentifier getCategoryIdentifier() { + return BuiltinPlugin.BLASTING; } } 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 index 57f3a52e0..0c386d38f 100644 --- 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 @@ -26,19 +26,19 @@ 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.REIHelper; -import me.shedaniel.rei.api.gui.Renderer; -import me.shedaniel.rei.api.gui.widgets.Widget; -import me.shedaniel.rei.api.gui.widgets.Widgets; -import me.shedaniel.rei.api.ingredient.util.EntryStacks; -import me.shedaniel.rei.api.registry.display.DisplayCategory; -import me.shedaniel.rei.plugin.DefaultPlugin; +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.ingredient.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.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Blocks; @@ -48,8 +48,8 @@ import java.util.List; @Environment(EnvType.CLIENT) public class DefaultBrewingCategory implements DisplayCategory { @Override - public ResourceLocation getIdentifier() { - return DefaultPlugin.BREWING; + public CategoryIdentifier getCategoryIdentifier() { + return BuiltinPlugin.BREWING; } @Override 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 index be45551b2..33563aad4 100644 --- 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 @@ -24,16 +24,16 @@ package me.shedaniel.rei.plugin.brewing; import com.google.common.collect.Lists; -import me.shedaniel.rei.api.ingredient.EntryIngredient; -import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.api.ingredient.util.EntryStacks; -import me.shedaniel.rei.api.registry.display.Display; -import me.shedaniel.rei.plugin.DefaultPlugin; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.ingredient.EntryIngredient; +import me.shedaniel.rei.api.common.ingredient.EntryStack; +import me.shedaniel.rei.api.common.ingredient.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.ch