From 5e2eccadbd91171c01cdb209d1338bcfb7786b1c Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 2 Jan 2020 14:31:16 +0800 Subject: 3.3 Fix #58 Close #134 Close #158 Fix #227 --- build.gradle | 2 +- gradle.properties | 4 +- .../me/shedaniel/rei/REIModMenuEntryPoint.java | 6 +- .../me/shedaniel/rei/RoughlyEnoughItemsCore.java | 61 +++-- .../shedaniel/rei/RoughlyEnoughItemsNetwork.java | 6 +- .../me/shedaniel/rei/api/AutoTransferHandler.java | 78 +++--- .../me/shedaniel/rei/api/BaseBoundsHandler.java | 12 +- .../me/shedaniel/rei/api/ButtonAreaSupplier.java | 6 +- .../java/me/shedaniel/rei/api/ClientHelper.java | 69 ++--- .../java/me/shedaniel/rei/api/ConfigManager.java | 18 +- .../java/me/shedaniel/rei/api/ConfigObject.java | 133 ++++++---- .../java/me/shedaniel/rei/api/DisplayHelper.java | 41 +-- .../rei/api/DisplayVisibilityHandler.java | 6 +- .../java/me/shedaniel/rei/api/EntryRegistry.java | 28 +-- src/main/java/me/shedaniel/rei/api/EntryStack.java | 93 +++---- .../me/shedaniel/rei/api/LiveRecipeGenerator.java | 8 +- .../java/me/shedaniel/rei/api/ObjectHolder.java | 14 +- .../java/me/shedaniel/rei/api/REIPluginEntry.java | 8 +- .../java/me/shedaniel/rei/api/RecipeCategory.java | 24 +- .../java/me/shedaniel/rei/api/RecipeDisplay.java | 12 +- .../java/me/shedaniel/rei/api/RecipeHelper.java | 74 +++--- .../shedaniel/rei/api/TransferRecipeDisplay.java | 8 +- .../rei/api/annotations/Experimental.java | 3 +- .../me/shedaniel/rei/api/annotations/Internal.java | 3 +- .../shedaniel/rei/api/annotations/ToBeRemoved.java | 3 +- .../me/shedaniel/rei/api/plugins/REIPluginV0.java | 16 +- .../shedaniel/rei/gui/ConfigReloadingScreen.java | 10 +- .../shedaniel/rei/gui/ContainerScreenOverlay.java | 124 ++++----- .../me/shedaniel/rei/gui/OverlaySearchField.java | 26 +- .../shedaniel/rei/gui/PreRecipeViewingScreen.java | 24 +- .../me/shedaniel/rei/gui/RecipeViewingScreen.java | 85 ++++--- .../rei/gui/VillagerRecipeViewingScreen.java | 62 ++--- .../shedaniel/rei/gui/config/ItemCheatingMode.java | 2 +- .../shedaniel/rei/gui/config/ItemListOrdering.java | 10 +- .../rei/gui/config/ItemListOrderingConfig.java | 12 +- .../shedaniel/rei/gui/config/RecipeScreenType.java | 2 +- .../rei/gui/config/SearchFieldLocation.java | 2 +- .../shedaniel/rei/gui/credits/CreditsScreen.java | 14 +- .../me/shedaniel/rei/gui/entries/RecipeEntry.java | 42 ++-- .../rei/gui/entries/SimpleRecipeEntry.java | 22 +- .../rei/gui/widget/AutoCraftingButtonWidget.java | 22 +- .../me/shedaniel/rei/gui/widget/ButtonWidget.java | 44 ++-- .../rei/gui/widget/CategoryBaseWidget.java | 8 +- .../rei/gui/widget/ClickableLabelWidget.java | 34 +-- .../gui/widget/CraftableToggleButtonWidget.java | 16 +- .../shedaniel/rei/gui/widget/DraggableWidget.java | 26 +- .../shedaniel/rei/gui/widget/EntryListWidget.java | 278 ++++++++++----------- .../me/shedaniel/rei/gui/widget/EntryWidget.java | 63 ++--- .../rei/gui/widget/FavoritesListWidget.java | 145 ++++++----- .../me/shedaniel/rei/gui/widget/LabelWidget.java | 42 ++-- .../me/shedaniel/rei/gui/widget/PanelWidget.java | 32 +-- .../me/shedaniel/rei/gui/widget/QueuedTooltip.java | 26 +- .../rei/gui/widget/RecipeArrowWidget.java | 10 +- .../shedaniel/rei/gui/widget/RecipeBaseWidget.java | 6 +- .../rei/gui/widget/RecipeChoosePageWidget.java | 40 +-- .../shedaniel/rei/gui/widget/SlotBaseWidget.java | 10 +- .../me/shedaniel/rei/gui/widget/TabWidget.java | 24 +- .../shedaniel/rei/gui/widget/TextFieldWidget.java | 188 +++++++------- .../java/me/shedaniel/rei/gui/widget/Widget.java | 8 +- .../shedaniel/rei/gui/widget/WidgetWithBounds.java | 14 +- .../me/shedaniel/rei/impl/AbstractEntryStack.java | 18 +- .../shedaniel/rei/impl/BaseBoundsHandlerImpl.java | 30 +-- .../me/shedaniel/rei/impl/ClientHelperImpl.java | 135 +++++----- .../me/shedaniel/rei/impl/ConfigManagerImpl.java | 99 +++++--- .../me/shedaniel/rei/impl/ConfigObjectImpl.java | 260 ++++++++++--------- .../me/shedaniel/rei/impl/DisplayHelperImpl.java | 32 +-- .../me/shedaniel/rei/impl/EmptyEntryStack.java | 55 ++-- .../me/shedaniel/rei/impl/EntryRegistryImpl.java | 32 +-- .../me/shedaniel/rei/impl/FluidEntryStack.java | 44 ++-- .../java/me/shedaniel/rei/impl/ItemEntryStack.java | 146 +++++------ .../me/shedaniel/rei/impl/ObjectHolderImpl.java | 4 +- .../me/shedaniel/rei/impl/RecipeHelperImpl.java | 119 +++++---- .../java/me/shedaniel/rei/impl/ScreenHelper.java | 43 ++-- .../java/me/shedaniel/rei/impl/SearchArgument.java | 39 ++- src/main/java/me/shedaniel/rei/impl/Weather.java | 14 +- .../rei/listeners/RecipeBookGuiHooks.java | 8 +- .../rei/mixin/MixinBrewingRecipeRegistry.java | 28 +-- .../me/shedaniel/rei/mixin/MixinItemRenderer.java | 2 +- .../me/shedaniel/rei/mixin/MixinItemStack.java | 6 +- .../rei/plugin/DefaultAutoCraftingPlugin.java | 8 +- .../me/shedaniel/rei/plugin/DefaultPlugin.java | 56 ++--- .../plugin/DefaultRecipeBookExclusionZones.java | 4 +- .../plugin/blasting/DefaultBlastingDisplay.java | 4 +- .../rei/plugin/brewing/DefaultBrewingCategory.java | 10 +- .../rei/plugin/brewing/DefaultBrewingDisplay.java | 14 +- .../plugin/campfire/DefaultCampfireDisplay.java | 20 +- .../composting/DefaultCompostingCategory.java | 18 +- .../containers/CraftingContainerInfoWrapper.java | 16 +- .../rei/plugin/cooking/DefaultCookingDisplay.java | 22 +- .../plugin/crafting/DefaultCraftingCategory.java | 14 +- .../plugin/crafting/DefaultCraftingDisplay.java | 14 +- .../rei/plugin/crafting/DefaultCustomDisplay.java | 26 +- .../rei/plugin/crafting/DefaultShapedDisplay.java | 20 +- .../plugin/crafting/DefaultShapelessDisplay.java | 20 +- .../plugin/smelting/DefaultSmeltingDisplay.java | 4 +- .../rei/plugin/smoking/DefaultSmokingDisplay.java | 4 +- .../stonecutting/DefaultStoneCuttingCategory.java | 12 +- .../plugin/stripping/DefaultStrippingDisplay.java | 16 +- .../rei/plugin/stripping/DummyAxeItem.java | 2 +- .../me/shedaniel/rei/server/ContainerInfo.java | 10 +- .../shedaniel/rei/server/ContainerInfoHandler.java | 6 +- .../me/shedaniel/rei/server/InputSlotCrafter.java | 65 +++-- .../java/me/shedaniel/rei/server/RecipeFinder.java | 128 +++++----- .../me/shedaniel/rei/server/RecipeGridAligner.java | 16 +- .../shedaniel/rei/tests/plugin/REITestPlugin.java | 12 +- .../me/shedaniel/rei/utils/CollectionUtils.java | 78 +++--- .../java/me/shedaniel/rei/utils/ExecutorUtil.java | 18 -- .../assets/roughlyenoughitems/lang/en_us.json | 17 +- 108 files changed, 1979 insertions(+), 1998 deletions(-) delete mode 100644 src/main/java/me/shedaniel/rei/utils/ExecutorUtil.java diff --git a/build.gradle b/build.gradle index 1ed9970f4..21724777f 100755 --- a/build.gradle +++ b/build.gradle @@ -77,7 +77,7 @@ dependencies { compile "org.lwjgl:lwjgl-jemalloc:3.2.1" compileOnly "com.google.code.findbugs:jsr305:3.0.2" compileOnly 'org.jetbrains:annotations:15.0' - modRuntime("com.lettuce.fudge:notenoughcrashes:1.0.12+1.15") { + modRuntime("com.lettuce.fudge:notenoughcrashes:1.1.5+1.15.1") { transitive = false } } diff --git a/gradle.properties b/gradle.properties index 386277404..f8b3014fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ -mod_version=3.2.33 +mod_version=3.3.0 minecraft_version=1.15 yarn_version=1.15+build.1 fabricloader_version=0.7.2+build.174 cloth_events_version=1.1.0 -cloth_config_version=2.5.3 +cloth_config_version=2.6.5 modmenu_version=1.8.0+build.16 fabric_api=0.4.20+build.273-1.15 autoconfig1u=1.2.4 diff --git a/src/main/java/me/shedaniel/rei/REIModMenuEntryPoint.java b/src/main/java/me/shedaniel/rei/REIModMenuEntryPoint.java index ef7e9b160..5c04233d2 100644 --- a/src/main/java/me/shedaniel/rei/REIModMenuEntryPoint.java +++ b/src/main/java/me/shedaniel/rei/REIModMenuEntryPoint.java @@ -12,15 +12,15 @@ import net.minecraft.client.gui.screen.Screen; import java.util.function.Function; public class REIModMenuEntryPoint implements ModMenuApi { - + @Override public String getModId() { return "roughlyenoughitems"; } - + @Override public Function getConfigScreenFactory() { return parent -> ConfigManager.getInstance().getConfigScreen(parent); } - + } diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index dad49fefc..100cd75bb 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -56,48 +56,43 @@ import java.util.concurrent.atomic.AtomicLong; @Internal public class RoughlyEnoughItemsCore implements ClientModInitializer { - - @Internal - public static final Logger LOGGER; - @SuppressWarnings("deprecation") - private static final RecipeHelper RECIPE_HELPER = new RecipeHelperImpl(); - @SuppressWarnings("deprecation") - private static final EntryRegistry ENTRY_REGISTRY = new EntryRegistryImpl(); - @SuppressWarnings("deprecation") - private static final DisplayHelper DISPLAY_HELPER = new DisplayHelperImpl(); + + @Internal public static final Logger LOGGER; + @SuppressWarnings("deprecation") private static final RecipeHelper RECIPE_HELPER = new RecipeHelperImpl(); + @SuppressWarnings("deprecation") private static final EntryRegistry ENTRY_REGISTRY = new EntryRegistryImpl(); + @SuppressWarnings("deprecation") private static final DisplayHelper DISPLAY_HELPER = new DisplayHelperImpl(); private static final Map plugins = Maps.newHashMap(); private static final ExecutorService SYNC_RECIPES = Executors.newSingleThreadScheduledExecutor(r -> new Thread(r, "REI-SyncRecipes")); private static ConfigManager configManager; - + static { LOGGER = LogManager.getFormatterLogger("REI"); } - + @Deprecated public static RecipeHelper getRecipeHelper() { return RECIPE_HELPER; } - + @Deprecated public static ConfigManager getConfigManager() { return configManager; } - + @Deprecated public static EntryRegistry getEntryRegistry() { return ENTRY_REGISTRY; } - + @Deprecated public static DisplayHelper getDisplayHelper() { return DISPLAY_HELPER; } - + /** * Registers a REI plugin * - * @param identifier the identifier of the plugin - * @param plugin the plugin instance + * @param plugin the plugin instance * @return the plugin itself * @deprecated Check REI wiki */ @@ -107,18 +102,18 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { RoughlyEnoughItemsCore.LOGGER.debug("[REI] Registered plugin %s from %s", plugin.getPluginIdentifier().toString(), plugin.getClass().getSimpleName()); return plugin; } - + public static List getPlugins() { return new LinkedList<>(plugins.values()); } - + public static Optional getPluginIdentifier(REIPluginEntry plugin) { for (Identifier identifier : plugins.keySet()) if (identifier != null && plugins.get(identifier).equals(plugin)) return Optional.of(identifier); return Optional.empty(); } - + public static boolean hasPermissionToUsePackets() { try { MinecraftClient.getInstance().getNetworkHandler().getCommandSource().hasPermissionLevel(0); @@ -127,7 +122,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { return true; } } - + public static boolean hasOperatorPermission() { try { return MinecraftClient.getInstance().getNetworkHandler().getCommandSource().hasPermissionLevel(1); @@ -135,11 +130,11 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { return true; } } - + public static boolean canUsePackets() { return ClientSidePacketRegistry.INSTANCE.canServerReceive(RoughlyEnoughItemsNetwork.CREATE_ITEMS_PACKET) && ClientSidePacketRegistry.INSTANCE.canServerReceive(RoughlyEnoughItemsNetwork.DELETE_ITEMS_PACKET); } - + @Internal @Deprecated public static void syncRecipes(AtomicLong lastSync) { @@ -157,19 +152,19 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { ((RecipeHelperImpl) RecipeHelper.getInstance()).recipesLoaded(recipeManager); } } - + @SuppressWarnings("deprecation") @Override public void onInitializeClient() { configManager = new ConfigManagerImpl(); - + registerClothEvents(); discoverPluginEntries(); for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) { if (modContainer.getMetadata().containsCustomValue("roughlyenoughitems:plugins")) RoughlyEnoughItemsCore.LOGGER.error("[REI] REI plugin from " + modContainer.getMetadata().getId() + " is not loaded because it is too old!"); } - + ClientSidePacketRegistry.INSTANCE.register(RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, (packetContext, packetByteBuf) -> { ItemStack stack = packetByteBuf.readItemStack(); String player = packetByteBuf.readString(32767); @@ -181,7 +176,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { RecipeBookWidget recipeBookGui = ((RecipeBookProvider) currentScreen).getRecipeBookGui(); RecipeBookGhostSlots ghostSlots = ((RecipeBookGuiHooks) recipeBookGui).rei_getGhostSlots(); ghostSlots.reset(); - + List> input = Lists.newArrayList(); int mapSize = packetByteBuf.readInt(); for (int i = 0; i < mapSize; i++) { @@ -192,7 +187,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } input.add(list); } - + ghostSlots.addSlot(Ingredient.ofItems(Items.STONE), 381203812, 12738291); CraftingTableContainer container = ((CraftingTableScreen) currentScreen).getContainer(); for (int i = 0; i < input.size(); i++) { @@ -205,7 +200,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { } }); } - + @SuppressWarnings("deprecation") private void discoverPluginEntries() { for (REIPluginEntry reiPlugin : FabricLoader.getInstance().getEntrypoints("rei_plugins", REIPluginEntry.class)) { @@ -226,18 +221,18 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { RoughlyEnoughItemsCore.LOGGER.error("[REI] Can't load REI plugins from %s: %s", reiPlugin.getClass(), e.getLocalizedMessage()); } } - + // Test Only loadTestPlugins(); } - + @SuppressWarnings("deprecation") private void loadTestPlugins() { if (System.getProperty("rei.test", "false").equals("true")) { registerPlugin(new REITestPlugin()); } } - + @SuppressWarnings("deprecation") private void registerClothEvents() { final Identifier recipeButtonTex = new Identifier("textures/gui/recipe_button.png"); @@ -317,5 +312,5 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer { return ActionResult.PASS; }); } - + } diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java index 3c70a34c5..27fc73615 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java @@ -27,13 +27,13 @@ import java.util.List; import java.util.Map; public class RoughlyEnoughItemsNetwork implements ModInitializer { - + public static final Identifier DELETE_ITEMS_PACKET = new Identifier("roughlyenoughitems", "delete_item"); public static final Identifier CREATE_ITEMS_PACKET = new Identifier("roughlyenoughitems", "create_item"); public static final Identifier CREATE_ITEMS_MESSAGE_PACKET = new Identifier("roughlyenoughitems", "ci_msg"); public static final Identifier MOVE_ITEMS_PACKET = new Identifier("roughlyenoughitems", "move_items"); public static final Identifier NOT_ENOUGH_ITEMS_PACKET = new Identifier("roughlyenoughitems", "og_not_enough"); - + @Override public void onInitialize() { FabricLoader.getInstance().getEntrypoints("rei_containers", Runnable.class).forEach(Runnable::run); @@ -103,5 +103,5 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer { } }); } - + } diff --git a/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java b/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java index 54b7e542d..c8e761e25 100644 --- a/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java +++ b/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java @@ -16,89 +16,89 @@ import net.minecraft.container.Container; import java.util.function.Supplier; public interface AutoTransferHandler { - + default double getPriority() { return 0d; } - + Result handle(Context context); - - public interface Result { + + interface Result { static Result createSuccessful() { return new ResultImpl(); } - + static Result createNotApplicable() { return new ResultImpl(false); } - + static Result createFailed(String errorKey) { return new ResultImpl(errorKey, new IntArrayList(), 1744764928); } - + static Result createFailedCustomButtonColor(String errorKey, int color) { return new ResultImpl(errorKey, new IntArrayList(), color); } - + static Result createFailed(String errorKey, IntList redSlots) { return new ResultImpl(errorKey, redSlots, 1744764928); } - + static Result createFailedCustomButtonColor(String errorKey, IntList redSlots, int color) { return new ResultImpl(errorKey, redSlots, color); } - + int getColor(); - + boolean isSuccessful(); - + boolean isApplicable(); - + String getErrorKey(); - + IntList getIntegers(); } - - public interface Context { + + interface Context { static Context create(boolean actuallyCrafting, AbstractContainerScreen containerScreen, RecipeDisplay recipeDisplay) { return new ContextImpl(actuallyCrafting, containerScreen, () -> recipeDisplay); } - + default MinecraftClient getMinecraft() { return MinecraftClient.getInstance(); } - + boolean isActuallyCrafting(); - + AbstractContainerScreen getContainerScreen(); - + RecipeDisplay getRecipe(); - + default Container getContainer() { return getContainerScreen().getContainer(); } - + default ContainerScreenOverlay getOverlay() { return ScreenHelper.getLastOverlay(); } } - - public final class ResultImpl implements Result { + + final class ResultImpl implements Result { private boolean successful, applicable; private String errorKey; private IntList integers = new IntArrayList(); private int color; - + private ResultImpl() { this.successful = true; this.applicable = true; } - + public ResultImpl(boolean applicable) { this.successful = false; this.applicable = applicable; } - + public ResultImpl(String errorKey, IntList integers, int color) { this.successful = false; this.applicable = true; @@ -107,58 +107,58 @@ public interface AutoTransferHandler { this.integers = integers; this.color = color; } - + @Override public int getColor() { return color; } - + @Override public boolean isSuccessful() { return successful; } - + @Override public boolean isApplicable() { return applicable; } - + @Override public String getErrorKey() { return errorKey; } - + @Override public IntList getIntegers() { return integers; } } - - public final class ContextImpl implements Context { + + final class ContextImpl implements Context { boolean actuallyCrafting; AbstractContainerScreen containerScreen; Supplier recipeDisplaySupplier; - + private ContextImpl(boolean actuallyCrafting, AbstractContainerScreen containerScreen, Supplier recipeDisplaySupplier) { this.actuallyCrafting = actuallyCrafting; this.containerScreen = containerScreen; this.recipeDisplaySupplier = recipeDisplaySupplier; } - + @Override public boolean isActuallyCrafting() { return actuallyCrafting; } - + @Override public AbstractContainerScreen getContainerScreen() { return containerScreen; } - + @Override public RecipeDisplay getRecipe() { return recipeDisplaySupplier.get(); } } - + } diff --git a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java index 0a4011f2d..84b8574a6 100644 --- a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java +++ b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java @@ -26,16 +26,16 @@ public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler getCurrentExclusionZones(Class currentScreenClass, boolean isOnRightSide) { return getExclusionZones(currentScreenClass, false); } - + @Deprecated default List getCurrentExclusionZones(Class currentScreenClass, boolean isOnRightSide, boolean sort) { return getExclusionZones(currentScreenClass, sort); } - + List getExclusionZones(Class currentScreenClass, boolean sort); - + int supplierSize(); - + /** * Register an exclusion zone * @@ -51,7 +51,7 @@ public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler screenClass, Supplier> supplier); - + } diff --git a/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java b/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java index b3af06c01..8ec5f3527 100644 --- a/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java +++ b/src/main/java/me/shedaniel/rei/api/ButtonAreaSupplier.java @@ -8,7 +8,7 @@ package me.shedaniel.rei.api; import me.shedaniel.math.api.Rectangle; public interface ButtonAreaSupplier { - + /** * Declares the button bounds * @@ -16,7 +16,7 @@ public interface ButtonAreaSupplier { * @return the bounds of the button */ Rectangle get(Rectangle bounds); - + /** * Declares the button text * @@ -25,5 +25,5 @@ public interface ButtonAreaSupplier { default String getButtonText() { return "+"; } - + } diff --git a/src/main/java/me/shedaniel/rei/api/ClientHelper.java b/src/main/java/me/shedaniel/rei/api/ClientHelper.java index 6e33eba30..08ab4fcab 100644 --- a/src/main/java/me/shedaniel/rei/api/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/api/ClientHelper.java @@ -22,14 +22,14 @@ public interface ClientHelper { static ClientHelper getInstance() { return ClientHelperImpl.instance; } - + /** * Checks if cheating is enabled * * @return whether cheating is enabled */ boolean isCheating(); - + /** * Sets current cheating mode * Should save the config in {@link ConfigManager}. @@ -37,9 +37,9 @@ public interface ClientHelper { * @param cheating the new cheating mode */ void setCheating(boolean cheating); - + List getInventoryItemsTypes(); - + /** * Opens a recipe viewing screen: * Opens {@link me.shedaniel.rei.gui.PreRecipeViewingScreen} if not set @@ -49,12 +49,12 @@ public interface ClientHelper { * @param map the map of recipes */ void openRecipeViewingScreen(Map, List> map); - + /** * Registers REI's keybinds using Fabric API. */ void registerFabricKeyBinds(); - + /** * Tries to cheat stack using either packets or commands. * @@ -62,11 +62,11 @@ public interface ClientHelper { * @return whether it failed */ boolean tryCheatingEntry(EntryStack stack); - + default boolean tryCheatingStack(ItemStack stack) { return tryCheatingEntry(EntryStack.create(stack)); } - + /** * Finds recipe for the stack and opens the recipe screen. * @@ -74,11 +74,11 @@ public interface ClientHelper { * @return whether the stack has any recipes to show */ boolean executeRecipeKeyBind(EntryStack stack); - + default boolean executeRecipeKeyBind(ItemStack stack) { return executeRecipeKeyBind(EntryStack.create(stack)); } - + /** * Finds usage for the stack and opens the recipe screen. * @@ -86,15 +86,11 @@ public interface ClientHelper { * @return whether the stack has any usages to show */ boolean executeUsageKeyBind(EntryStack stack); - + default boolean executeUsageKeyBind(ItemStack stack) { return executeUsageKeyBind(EntryStack.create(stack)); } - - FabricKeyBinding getFocusSearchFieldKeyBinding(); - - FabricKeyBinding getCopyRecipeIdentifierKeyBinding(); - + /** * Gets the mod from an item * @@ -102,12 +98,12 @@ public interface ClientHelper { * @return the mod name */ String getModFromItem(Item item); - + /** * Tries to delete the player's cursor item */ void sendDeletePacket(); - + /** * Gets the formatted mod from an item * @@ -115,7 +111,7 @@ public interface ClientHelper { * @return the mod name with blue and italic formatting */ String getFormattedModFromItem(Item item); - + /** * Gets the formatted mod from an identifier * @@ -123,7 +119,7 @@ public interface ClientHelper { * @return the mod name with blue and italic formatting */ String getFormattedModFromIdentifier(Identifier identifier); - + /** * Gets the mod from an identifier * @@ -131,42 +127,15 @@ public interface ClientHelper { * @return the mod name */ String getModFromIdentifier(Identifier identifier); - - FabricKeyBinding[] getREIKeyBindings(); - - /** - * @return the recipe keybind, defaulted R - */ - FabricKeyBinding getRecipeKeyBinding(); - - /** - * @return the usage keybind, defaulted U - */ - FabricKeyBinding getUsageKeyBinding(); - - /** - * @return the hide keybind, defaulted O - */ - FabricKeyBinding getHideKeyBinding(); - - /** - * @return the previous page keybind, defaulted not set - */ - FabricKeyBinding getPreviousPageKeyBinding(); - - /** - * @return the next page keybind, defaulted not set - */ - FabricKeyBinding getNextPageKeyBinding(); - + /** * Finds all recipes and open them in a recipe screen. * * @return whether there are any recipes to show */ boolean executeViewAllRecipesKeyBind(); - + boolean executeViewAllRecipesFromCategory(Identifier category); - + boolean executeViewAllRecipesFromCategories(List categories); } diff --git a/src/main/java/me/shedaniel/rei/api/ConfigManager.java b/src/main/java/me/shedaniel/rei/api/ConfigManager.java index 26b5bf218..ca11825ba 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigManager.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigManager.java @@ -11,19 +11,19 @@ import net.minecraft.client.gui.screen.Screen; import java.util.List; public interface ConfigManager { - + @SuppressWarnings("deprecation") static ConfigManager getInstance() { return RoughlyEnoughItemsCore.getConfigManager(); } - + List getFavorites(); - + /** * Saves the config. */ void saveConfig(); - + /** * Gets the config instance * @@ -32,26 +32,26 @@ public interface ConfigManager { */ @Deprecated ConfigObject getConfig(); - + /** * Gets if craftable only filter is enabled * * @return whether craftable only filter is enabled */ boolean isCraftableOnlyEnabled(); - + /** * Toggles the craftable only filter */ void toggleCraftableOnly(); - + /** * Opens the config screen * * @param parent the screen shown before */ void openConfigScreen(Screen parent); - + /** * Gets the config screen * @@ -59,5 +59,5 @@ public interface ConfigManager { * @return the config screen */ Screen getConfigScreen(Screen parent); - + } diff --git a/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/src/main/java/me/shedaniel/rei/api/ConfigObject.java index ac807ec03..ca3adc5a2 100644 --- a/src/main/java/me/shedaniel/rei/api/ConfigObject.java +++ b/src/main/java/me/shedaniel/rei/api/ConfigObject.java @@ -5,10 +5,12 @@ package me.shedaniel.rei.api; +import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.rei.gui.config.ItemCheatingMode; import me.shedaniel.rei.gui.config.ItemListOrdering; import me.shedaniel.rei.gui.config.RecipeScreenType; import me.shedaniel.rei.gui.config.SearchFieldLocation; +import me.shedaniel.rei.impl.ConfigObjectImpl; import net.minecraft.client.util.InputUtil; import java.lang.annotation.ElementType; @@ -17,108 +19,137 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; public interface ConfigObject { - + @SuppressWarnings("deprecation") static ConfigObject getInstance() { return ConfigManager.getInstance().getConfig(); } - + boolean isLighterButtonHover(); - + void setLighterButtonHover(boolean lighterButtonHover); - + boolean isOverlayVisible(); - + void setOverlayVisible(boolean overlayVisible); - + boolean isCheating(); - + void setCheating(boolean cheating); - + ItemListOrdering getItemListOrdering(); - + boolean isItemListAscending(); - + boolean isUsingDarkTheme(); - + boolean isToastDisplayedOnCopyIdentifier(); - + @Deprecated default boolean doesRenderEntryExtraOverlay() { return doesRenderEntryEnchantmentGlint(); } - + boolean doesRenderEntryEnchantmentGlint(); - + boolean isEntryListWidgetScrolled(); - + boolean shouldAppendModNames(); - + RecipeScreenType getRecipeScreenType(); - + void setRecipeScreenType(RecipeScreenType recipeScreenType); - + boolean isLoadingDefaultPlugin(); - + SearchFieldLocation getSearchFieldLocation(); - + boolean isLeftHandSidePanel(); - + boolean isCraftableFilterEnabled(); - + String getGamemodeCommand(); - + String getGiveCommand(); - + String getWeatherCommand(); - + int getMaxRecipePerPage(); - + boolean doesShowUtilsButtons(); - + boolean doesDisableRecipeBook(); - + boolean doesFixTabCloseContainer(); - + boolean areClickableRecipeArrowsEnabled(); - + ItemCheatingMode getItemCheatingMode(); - + boolean isUsingLightGrayRecipeBorder(); - + boolean doesVillagerScreenHavePermanentScrollBar(); - + boolean doesRegisterRecipesInAnotherThread(); - + boolean doesSnapToRows(); - + boolean isFavoritesEnabled(); - + boolean doDisplayFavoritesTooltip(); - + boolean doDisplayFavoritesOnTheLeft(); - + boolean doesFastEntryRendering(); - + boolean doDebugRenderTimeRequired(); - + boolean doSearchFavorites(); - - InputUtil.KeyCode getFavoriteKeybind(); - + + @Deprecated + default InputUtil.KeyCode getFavoriteKeybind() { + return getFavoriteKeyCode().getKeyCode(); + } + + ModifierKeyCode getFavoriteKeyCode(); + + ModifierKeyCode getRecipeKeybind(); + + ModifierKeyCode getUsageKeybind(); + + ModifierKeyCode getHideKeybind(); + + ModifierKeyCode getPreviousPageKeybind(); + + ModifierKeyCode getNextPageKeybind(); + + ModifierKeyCode getFocusSearchFieldKeybind(); + + ModifierKeyCode getCopyRecipeIdentifierKeybind(); + + double getEntrySize(); + + @Deprecated + abstract ConfigObjectImpl.General getGeneral(); + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) - public @interface AddInFrontKeyCode { - } - + @interface AddInFrontKeyCode {} + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) - public @interface DontApplyFieldName { - } - + @interface DontApplyFieldName {} + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) - public @interface UseEnumSelectorInstead { + @interface UseEnumSelectorInstead {} + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.FIELD}) + @interface UsePercentage { + double min(); + + double max(); } - + } diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index 25c04295d..4314b0e7c 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -11,16 +11,17 @@ import me.shedaniel.rei.gui.config.SearchFieldLocation; import net.minecraft.util.ActionResult; import java.util.List; +import java.util.function.Supplier; import static net.minecraft.util.ActionResult.PASS; public interface DisplayHelper { - + @SuppressWarnings("deprecation") static DisplayHelper getInstance() { return RoughlyEnoughItemsCore.getDisplayHelper(); } - + /** * Gets the sorted version of all responsible bounds handlers * @@ -29,14 +30,14 @@ public interface DisplayHelper { * @see DisplayHelper#getResponsibleBoundsHandler(Class) for the unsorted version */ List> getSortedBoundsHandlers(Class screenClass); - + /** * Gets all registered bounds handlers * * @return the list of registered bounds handlers */ List> getAllBoundsHandlers(); - + /** * Gets all responsible bounds handlers * @@ -45,29 +46,29 @@ public interface DisplayHelper { * @see DisplayHelper#getSortedBoundsHandlers(Class) for the sorted version */ DisplayBoundsHandler getResponsibleBoundsHandler(Class screenClass); - + /** * Registers a bounds handler * * @param handler the handler to register */ void registerBoundsHandler(DisplayBoundsHandler handler); - + /** * Gets the base bounds handler api for exclusion zones * * @return the base bounds handler */ BaseBoundsHandler getBaseBoundsHandler(); - - public static interface DisplayBoundsHandler { + + interface DisplayBoundsHandler { /** * Gets the base supported class for the bounds handler * * @return the base class */ Class getBaseSupportedClass(); - + /** * Gets the left bounds of the overlay * @@ -75,7 +76,7 @@ public interface DisplayHelper { * @return the left bounds */ Rectangle getLeftBounds(T screen); - + /** * Gets the right bounds of the overlay * @@ -83,7 +84,7 @@ public interface DisplayHelper { * @return the right bounds */ Rectangle getRightBounds(T screen); - + /** * Checks if item slot can fit the screen * @@ -92,12 +93,12 @@ public interface DisplayHelper { * @param screen the current screen * @param fullBounds the current bounds * @return whether the item slot can fit - * @see BaseBoundsHandler#registerExclusionZones(Class, BaseBoundsHandler.ExclusionZoneSupplier) for easier api + * @see BaseBoundsHandler#registerExclusionZones(Class, Supplier) for easier api */ default ActionResult canItemSlotWidgetFit(int left, int top, T screen, Rectangle fullBounds) { return PASS; } - + /** * Checks if item slot can fit the screen * @@ -113,7 +114,7 @@ public interface DisplayHelper { default ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, T screen, Rectangle fullBounds) { return canItemSlotWidgetFit(left, top, screen, fullBounds); } - + /** * Checks if mouse is inside the overlay * @@ -127,7 +128,7 @@ public interface DisplayHelper { default ActionResult isInZone(boolean isOnRightSide, double mouseX, double mouseY) { return isInZone(mouseX, mouseY); } - + /** * Checks if mouse is inside the overlay * @@ -138,7 +139,7 @@ public interface DisplayHelper { default ActionResult isInZone(double mouseX, double mouseY) { return PASS; } - + /** * Gets the item list bounds by the overlay bounds * @@ -148,12 +149,12 @@ public interface DisplayHelper { default Rectangle getItemListArea(Rectangle rectangle) { return new Rectangle(rectangle.x + 1, rectangle.y + 2 + (ConfigObject.getInstance().getSearchFieldLocation() == SearchFieldLocation.TOP_SIDE ? 24 : 0) + (ConfigObject.getInstance().isEntryListWidgetScrolled() ? 0 : 22), rectangle.width - 2, rectangle.height - (ConfigObject.getInstance().getSearchFieldLocation() != SearchFieldLocation.CENTER ? 27 + 22 : 27) + (!ConfigObject.getInstance().isEntryListWidgetScrolled() ? 0 : 22)); } - + default Rectangle getFavoritesListArea(Rectangle rectangle) { int offset = 31 + (ConfigObject.getInstance().doesShowUtilsButtons() ? 25 : 0); return new Rectangle(rectangle.x + 1, rectangle.y + 2 + offset, rectangle.width - 2, rectangle.height - 5 - offset); } - + /** * Checks if REI should recalculate the overlay bounds * @@ -164,7 +165,7 @@ public interface DisplayHelper { default boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) { return false; } - + /** * Gets the priority of the handler, the higher it is, the earlier it is called. * @@ -174,5 +175,5 @@ public interface DisplayHelper { return 0f; } } - + } diff --git a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java index 388929cda..5e6cde696 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java @@ -8,7 +8,7 @@ package me.shedaniel.rei.api; import net.minecraft.util.ActionResult; public interface DisplayVisibilityHandler { - + /** * Gets the priority of the handler * @@ -17,7 +17,7 @@ public interface DisplayVisibilityHandler { default float getPriority() { return 0f; } - + /** * Handles the visibility of the display. * {@link ActionResult#PASS} to pass the handling to another handler @@ -29,5 +29,5 @@ public interface DisplayVisibilityHandler { * @return the visibility */ ActionResult handleDisplay(RecipeCategory category, RecipeDisplay display); - + } diff --git a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java index 06a9cca1f..01539e374 100644 --- a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java +++ b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java @@ -15,21 +15,21 @@ import java.util.Collection; import java.util.List; public interface EntryRegistry { - + @SuppressWarnings("deprecation") static EntryRegistry getInstance() { return RoughlyEnoughItemsCore.getEntryRegistry(); } - + /** * Gets the current modifiable stacks list * * @return a stacks list */ List getStacksList(); - + List appendStacksForItem(Item item); - + /** * Gets all possible stacks from an item * @@ -37,11 +37,11 @@ public interface EntryRegistry { * @return the array of possible stacks */ ItemStack[] getAllStacksFromItem(Item item); - + default void registerEntry(EntryStack stack) { registerEntryAfter(null, stack); } - + /** * Registers an new stack to the entry list * @@ -51,7 +51,7 @@ public interface EntryRegistry { default void registerEntryAfter(EntryStack afterEntry, EntryStack stack) { registerEntryAfter(afterEntry, stack, true); } - + /** * Registers an new stack to the entry list * @@ -61,10 +61,10 @@ public interface EntryRegistry { */ @Deprecated void registerEntryAfter(EntryStack afterEntry, EntryStack stack, boolean checkAlreadyContains); - - + + void queueRegisterEntryAfter(EntryStack afterEntry, Collection stacks); - + /** * Registers multiple stacks to the item list * @@ -74,7 +74,7 @@ public interface EntryRegistry { default void registerEntriesAfter(EntryStack afterStack, EntryStack... stacks) { registerEntriesAfter(afterStack, Arrays.asList(stacks)); } - + /** * Registers multiple stacks to the item list * @@ -82,7 +82,7 @@ public interface EntryRegistry { * @param stacks the stacks to register */ void registerEntriesAfter(EntryStack afterStack, Collection stacks); - + /** * Registers multiple stacks to the item list * @@ -91,7 +91,7 @@ public interface EntryRegistry { default void registerEntries(EntryStack... stacks) { registerEntriesAfter(null, stacks); } - + /** * Checks if a stack is already registered * @@ -101,5 +101,5 @@ public interface EntryRegistry { default boolean alreadyContain(EntryStack stack) { return CollectionUtils.anyMatchEqualsAll(getStacksList(), stack); } - + } diff --git a/src/main/java/me/shedaniel/rei/api/EntryStack.java b/src/main/java/me/shedaniel/rei/api/EntryStack.java index 8fd4a135a..1fd04a1d9 100644 --- a/src/main/java/me/shedaniel/rei/api/EntryStack.java +++ b/src/main/java/me/shedaniel/rei/api/EntryStack.java @@ -32,27 +32,27 @@ import java.util.function.Supplier; @SuppressWarnings("deprecation") public interface EntryStack { - + static EntryStack empty() { return EmptyEntryStack.EMPTY; } - + static EntryStack create(Fluid fluid) { return new FluidEntryStack(fluid); } - + static EntryStack create(Fluid fluid, int amount) { return new FluidEntryStack(fluid, amount); } - + static EntryStack create(ItemStack stack) { return new ItemEntryStack(stack); } - + static EntryStack create(ItemConvertible item) { return new ItemEntryStack(new ItemStack(item)); } - + @Internal @Deprecated static EntryStack readFromJson(JsonElement jsonElement) { @@ -73,7 +73,7 @@ public interface EntryStack { return EntryStack.empty(); } } - + @Internal @Deprecated @Nullable @@ -102,83 +102,85 @@ public interface EntryStack { return null; } } - + Optional getIdentifier(); - + EntryStack.Type getType(); - + int getAmount(); - + void setAmount(int amount); - + boolean isEmpty(); - + EntryStack copy(); - + Object getObject(); - + boolean equals(EntryStack stack, boolean ignoreTags, boolean ignoreAmount); - + boolean equalsIgnoreTagsAndAmount(EntryStack stack); - + boolean equalsIgnoreTags(EntryStack stack); - + boolean equalsIgnoreAmount(EntryStack stack); - + boolean equalsAll(EntryStack stack); - - /** {@link #hashCode()} for {@link #equalsAll(EntryStack)}. */ + + /** + * {@link #hashCode()} for {@link #equalsAll(EntryStack)}. + */ default int hashOfAll() { return hashCode(); } - + int getZ(); - + void setZ(int z); - + default ItemStack getItemStack() { if (getType() == Type.ITEM) return (ItemStack) getObject(); return null; } - + default Item getItem() { if (getType() == Type.ITEM) return ((ItemStack) getObject()).getItem(); return null; } - + default Fluid getFluid() { if (getType() == Type.FLUID) return (Fluid) getObject(); return null; } - + EntryStack setting(Settings settings, T value); - + EntryStack removeSetting(Settings settings); - + EntryStack clearSettings(); - + default EntryStack addSetting(Settings settings, T value) { return setting(settings, value); } - + ObjectHolder getSetting(Settings settings); - + @Nullable QueuedTooltip getTooltip(int mouseX, int mouseY); - + void render(Rectangle bounds, int mouseX, int mouseY, float delta); - - public static enum Type { + + enum Type { ITEM, FLUID, EMPTY, RENDER } - - public static class Settings { + + class Settings { public static final Supplier TRUE = () -> true; public static final Supplier FALSE = () -> false; public static final Settings> RENDER = new Settings(TRUE); @@ -188,30 +190,29 @@ public interface EntryStack { public static final Settings> RENDER_COUNTS = new Settings(TRUE); public static final Settings>> TOOLTIP_APPEND_EXTRA = new Settings>>(stack -> Collections.emptyList()); public static final Settings> COUNTS = new Settings>(stack -> null); - + private T defaultValue; - + public Settings(T defaultValue) { this.defaultValue = defaultValue; } - + public T getDefaultValue() { return defaultValue; } - + public static class Item { public static final Settings> RENDER_ENCHANTMENT_GLINT = new Settings(TRUE); - @Deprecated - public static final Settings> RENDER_OVERLAY = RENDER_ENCHANTMENT_GLINT; - + @Deprecated public static final Settings> RENDER_OVERLAY = RENDER_ENCHANTMENT_GLINT; + private Item() { } } - + public static class Fluid { // Return null to disable public static final Settings> AMOUNT_TOOLTIP = new Settings>(stack -> I18n.translate("tooltip.rei.fluid_amount", stack.getAmount())); - + private Fluid() { } } diff --git a/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java b/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java index 8d7886273..588010042 100644 --- a/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java +++ b/src/main/java/me/shedaniel/rei/api/LiveRecipeGenerator.java @@ -11,15 +11,15 @@ import java.util.List; import java.util.Optional; public interface LiveRecipeGenerator { - + Identifier getCategoryIdentifier(); - + default Optional> getRecipeFor(EntryStack entry) { return Optional.empty(); } - + default Optional> getUsageFor(EntryStack entry) { return Optional.empty(); } - + } diff --git a/src/main/java/me/shedaniel/rei/api/ObjectHolder.java b/src/main/java/me/shedaniel/rei/api/ObjectHolder.java index f2c0f9048..bf1dd3b5d 100644 --- a/src/main/java/me/shedaniel/rei/api/ObjectHolder.java +++ b/src/main/java/me/shedaniel/rei/api/ObjectHolder.java @@ -12,36 +12,36 @@ public interface ObjectHolder { static ObjectHolder of(T o) { return new ObjectHolderImpl<>(o); } - + @Deprecated default int intValue() { return (int) (Object) value(); } - + @Deprecated default long longValue() { return (long) (Object) value(); } - + @Deprecated default boolean booleanValue() { return (boolean) (Object) value(); } - + @Deprecated default float floatValue() { return (float) (Object) value(); } - + @Deprecated default double doubleValue() { return (double) (Object) value(); } - + @Deprecated default String stringValue() { return (String) value(); } - + T value(); } \ No newline at end of file diff --git a/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java b/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java index a5b1dc33b..cdc5574cf 100644 --- a/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java +++ b/src/main/java/me/shedaniel/rei/api/REIPluginEntry.java @@ -13,11 +13,11 @@ import net.minecraft.util.Identifier; * Get base class of a REI plugin. */ public interface REIPluginEntry { - + default SemanticVersion getMinimumVersion() throws VersionParsingException { return null; } - + /** * Gets the priority of the plugin. * @@ -26,12 +26,12 @@ public interface REIPluginEntry { default int getPriority() { return 0; } - + /** * Get the identifier of the plugin * * @return the identifier */ Identifier getPluginIdentifier(); - + } diff --git a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java index b3f6d4bea..f212a3db2 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java @@ -22,14 +22,14 @@ import java.util.function.Supplier; public interface RecipeCategory { - + /** * Gets the identifier of the category, must be unique * * @return the unique identifier of the category */ Identifier getIdentifier(); - + /** * Gets the renderer of the icon, allowing developers to render things other than items * @@ -38,14 +38,14 @@ public interface RecipeCategory { default EntryStack getLogo() { return EntryStack.empty(); } - + /** * Gets the category name * * @return the name */ String getCategoryName(); - + /** * Gets the recipe renderer for the category, used in {@link me.shedaniel.rei.gui.VillagerRecipeViewingScreen} for rendering simple recipes * @@ -56,7 +56,7 @@ public interface RecipeCategory { default RecipeEntry getSimpleRenderer(T recipe) { return SimpleRecipeEntry.create(recipe::getInputEntries, recipe::getOutputEntries); } - + /** * Setup the widgets for displaying the recipe * @@ -67,7 +67,7 @@ public interface RecipeCategory { default List setupDisplay(Supplier recipeDisplaySupplier, Rectangle bounds) { return Collections.singletonList(new RecipeBaseWidget(bounds)); } - + /** * Draws the category background, used in {@link RecipeViewingScreen} * @@ -86,7 +86,7 @@ public interface RecipeCategory { DrawableHelper.fill(bounds.x + 17, bounds.y + 21, bounds.x + bounds.width - 17, bounds.y + 33, 0xFF9E9E9E); } } - + /** * Gets the recipe display height * @@ -95,7 +95,7 @@ public interface RecipeCategory { default int getDisplayHeight() { return 66; } - + /** * Gets the recipe display width * @@ -105,7 +105,7 @@ public interface RecipeCategory { default int getDisplayWidth(T display) { return 150; } - + /** * Gets the maximum recipe per page. * @@ -114,7 +114,7 @@ public interface RecipeCategory { default int getMaximumRecipePerPage() { return 99; } - + /** * Gets the fixed amount of recipes per page. * @@ -124,7 +124,7 @@ public interface RecipeCategory { default int getFixedRecipesPerPage() { return -1; } - + /** * Gets whether the category will check tags, useful for potions * @@ -135,5 +135,5 @@ public interface RecipeCategory { default boolean checkTags() { return false; } - + } diff --git a/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java b/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java index 139132a73..328d28973 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeDisplay.java @@ -12,17 +12,17 @@ import java.util.List; import java.util.Optional; public interface RecipeDisplay { - + /** * @return a list of inputs */ List> getInputEntries(); - + /** * @return a list of outputs */ List getOutputEntries(); - + /** * Gets the required items used in craftable filters * @@ -31,14 +31,14 @@ public interface RecipeDisplay { default List> getRequiredEntries() { return Collections.emptyList(); } - + /** * Gets the recipe display category identifier * * @return the identifier of the category */ Identifier getRecipeCategory(); - + /** * Gets the recipe location from datapack * @@ -47,5 +47,5 @@ public interface RecipeDisplay { default Optional getRecipeLocation() { return Optional.empty(); } - + } diff --git a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java index ae3541e86..448f00d9e 100644 --- a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java +++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java @@ -19,28 +19,28 @@ import java.util.function.Function; import java.util.function.Predicate; public interface RecipeHelper { - + @SuppressWarnings("deprecation") static RecipeHelper getInstance() { return RoughlyEnoughItemsCore.getRecipeHelper(); } - + AutoTransferHandler registerAutoCraftingHandler(AutoTransferHandler handler); - + List getSortedAutoCraftingHandler(); - + /** * Gets the total recipe count registered * * @return the recipe count */ int getRecipeCount(); - + /** * @return a list of sorted recipes */ List getAllSortedRecipes(); - + /** * Gets all craftable items from materials. * @@ -48,14 +48,14 @@ public interface RecipeHelper { * @return the list of craftable entries */ List findCraftableEntriesByItems(List inventoryItems); - + /** * Registers a category * * @param category the category to register */ void registerCategory(RecipeCategory category); - + /** * Registers the working stations of a category * @@ -63,7 +63,7 @@ public interface RecipeHelper { * @param workingStations the working stations */ void registerWorkingStations(Identifier category, List... workingStations); - + /** * Registers the working stations of a category * @@ -71,9 +71,9 @@ public interface RecipeHelper { * @param workingStations the working stations */ void registerWorkingStations(Identifier category, EntryStack... workingStations); - + List> getWorkingStations(Identifier category); - + /** * Registers a recipe display * @@ -81,7 +81,7 @@ public interface RecipeHelper { * @param display the recipe display */ void registerDisplay(Identifier categoryIdentifier, RecipeDisplay display); - + /** * Gets a map of recipes for an entry * @@ -89,23 +89,23 @@ public interface RecipeHelper { * @return the map of recipes */ Map, List> getRecipesFor(EntryStack stack); - + RecipeCategory getCategory(Identifier identifier); - + /** * Gets the vanilla recipe manager * * @return the recipe manager */ RecipeManager getRecipeManager(); - + /** * Gets all registered categories * * @return the list of categories */ List> getAllCategories(); - + /** * Gets a map of usages for an entry * @@ -113,7 +113,7 @@ public interface RecipeHelper { * @return the map of recipes */ Map, List> getUsagesFor(EntryStack stack); - + /** * Gets the optional of the auto crafting button area from a category * @@ -121,7 +121,7 @@ public interface RecipeHelper { * @return the optional of auto crafting button area */ Optional getAutoCraftButtonArea(RecipeCategory category); - + /** * Registers a auto crafting button area * @@ -129,7 +129,7 @@ public interface RecipeHelper { * @param rectangle the button area */ void registerAutoCraftButtonArea(Identifier category, ButtonAreaSupplier rectangle); - + /** * Removes the auto crafting button * @@ -138,37 +138,37 @@ public interface RecipeHelper { default void removeAutoCraftButton(Identifier category) { registerAutoCraftButtonArea(category, bounds -> null); } - + /** * Gets the map of all recipes visible to the player * * @return the map of recipes */ Map, List> getAllRecipes(); - + List getAllRecipesFromCategory(RecipeCategory category); - + /** * Registers a recipe visibility handler * * @param visibilityHandler the handler to be registered */ void registerRecipeVisibilityHandler(DisplayVisibilityHandler visibilityHandler); - + /** * Unregisters a recipe visibility handler * * @param visibilityHandler the handler to be unregistered */ void unregisterRecipeVisibilityHandler(DisplayVisibilityHandler visibilityHandler); - + /** * Gets an unmodifiable list of recipe visibility handlers * * @return the unmodifiable list of handlers */ List getDisplayVisibilityHandlers(); - + /** * Checks if the display is visible by asking recipe visibility handlers * @@ -179,7 +179,7 @@ public interface RecipeHelper { */ @Deprecated boolean isDisplayVisible(RecipeDisplay display, boolean respectConfig); - + /** * Checks if the display is visible by asking recipe visibility handlers * @@ -187,9 +187,9 @@ public interface RecipeHelper { * @return whether the display should be visible */ boolean isDisplayVisible(RecipeDisplay display); - + > void registerRecipes(Identifier category, Predicate recipeFilter, Function mappingFunction); - + /** * Registers a live recipe generator. * @@ -197,24 +197,24 @@ public interface RecipeHelper { * @apiNote Still work in progress */ void registerLiveRecipeGenerator(LiveRecipeGenerator liveRecipeGenerator); - + void registerScreenClickArea(Rectangle rectangle, Class> screenClass, Identifier... categories); - + > void registerRecipes(Identifier category, Class recipeClass, Function mappingFunction); - + > void registerRecipes(Identifier category, Function recipeFilter, Function mappingFunction); - + List getScreenClickAreas(); - + boolean arePluginsLoading(); - + interface ScreenClickArea { Class getScreenClass(); - + Rectangle getRectangle(); - + Identifier[] getCategories(); } - + } diff --git a/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java b/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java index 63b1d7810..40b65488f 100644 --- a/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java +++ b/src/main/java/me/shedaniel/rei/api/TransferRecipeDisplay.java @@ -11,11 +11,11 @@ import net.minecraft.container.Container; import java.util.List; public interface TransferRecipeDisplay extends RecipeDisplay { - + int getWidth(); - + int getHeight(); - + List> getOrganisedInputEntries(ContainerInfo containerInfo, Container container); - + } diff --git a/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java b/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java index 043b0daae..e1c3f73f4 100644 --- a/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java +++ b/src/main/java/me/shedaniel/rei/api/annotations/Experimental.java @@ -13,5 +13,4 @@ import static java.lang.annotation.ElementType.*; @Retention(RetentionPolicy.RUNTIME) @Target(value = {CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE}) -public @interface Experimental { -} +public @interface Experimental {} diff --git a/src/main/java/me/shedaniel/rei/api/annotations/Internal.java b/src/main/java/me/shedaniel/rei/api/annotations/Internal.java index 4b120c1de..137286971 100644 --- a/src/main/java/me/shedaniel/rei/api/annotations/Internal.java +++ b/src/main/java/me/shedaniel/rei/api/annotations/Internal.java @@ -13,5 +13,4 @@ import static java.lang.annotation.ElementType.*; @Retention(RetentionPolicy.RUNTIME) @Target(value = {CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE}) -public @interface Internal { -} +public @interfa