aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java8
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererProvider.java54
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java67
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/ForwardingEntryRenderer.java50
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java11
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java45
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/reason/DisplayAdditionReason.java44
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/registry/display/reason/DisplayAdditionReasons.java91
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java3
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java13
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/plugins/REIPlugin.java27
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java15
-rwxr-xr-xbuild.gradle4
-rw-r--r--fabric/build.gradle2
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/fabric/PluginDetectorImpl.java13
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java11
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java17
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/impl/common/compat/FabricFluidAPISupportPlugin.java20
-rw-r--r--forge/build.gradle16
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java12
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java21
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java5
-rw-r--r--forge/src/main/java/me/shedaniel/rei/impl/client/forge/ErrorDisplayerImpl.java24
-rw-r--r--forge/src/main/resources/META-INF/mods.toml4
-rw-r--r--gradle.properties10
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java23
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java15
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java11
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java13
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/filtering/FilteringContextImpl.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/entry/renderer/EntryRendererRegistryImpl.java66
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java9
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java193
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/EntryListEntry.java71
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/PerformanceEntry.java93
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/SubCategoryListEntry.java177
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java41
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java17
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java130
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java23
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java9
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/InternalWidgets.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java23
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ExclusionZonesImpl.java36
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/search/argument/Argument.java11
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/util/CrashReportUtils.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java14
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/EntryComparatorRegistryImpl.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java79
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/logging/FileLogger.java72
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/logging/Log4JLogger.java49
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/logging/Logger.java110
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/logging/MultiLogger.java55
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/logging/performance/PerformanceLogger.java56
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/logging/performance/PerformanceLoggerImpl.java97
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java165
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/util/IssuesDetector.java4
-rw-r--r--runtime/src/main/resources/assets/roughlyenoughitems/lang/de_de.json11
-rwxr-xr-xruntime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json2
-rw-r--r--runtime/src/main/resources/assets/roughlyenoughitems/lang/fr_fr.json33
66 files changed, 2080 insertions, 249 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java
index 3943a76eb..43819351a 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRenderer.java
@@ -40,9 +40,10 @@ import org.jetbrains.annotations.Nullable;
*
* @param <T> the entry type
* @see BatchedEntryRenderer
+ * @see EntryRendererRegistry
*/
@Environment(EnvType.CLIENT)
-public interface EntryRenderer<T> {
+public interface EntryRenderer<T> extends EntryRendererProvider<T> {
static <T> EntryRenderer<T> empty() {
return ClientInternals.getEmptyEntryRenderer();
}
@@ -58,4 +59,9 @@ public interface EntryRenderer<T> {
default <O> EntryRenderer<O> cast() {
return (EntryRenderer<O>) this;
}
+
+ @Override
+ default EntryRenderer<T> provide(EntryStack<T> entry, EntryRenderer<T> last) {
+ return this;
+ }
} \ No newline at end of file
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererProvider.java
new file mode 100644
index 000000000..659df5cff
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererProvider.java
@@ -0,0 +1,54 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.api.client.entry.renderer;
+
+import me.shedaniel.rei.api.common.entry.EntryStack;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+
+/**
+ * A functional interface to provide {@link EntryRenderer} for {@link EntryStack}.
+ *
+ * @param <T> the entry type
+ * @see EntryRenderer
+ */
+@FunctionalInterface
+@Environment(EnvType.CLIENT)
+public interface EntryRendererProvider<T> {
+ static <T> EntryRendererProvider<T> empty() {
+ return EntryRenderer.empty();
+ }
+
+ /**
+ * Returns a new {@link EntryRenderer} for a specific {@link EntryStack},
+ * a previous {@link EntryRenderer} will be provided, this may be an empty renderer.
+ * {@code null} is not an accepted value, return the previous renderer if this provider
+ * does not modify the renderer.
+ *
+ * @param entry the entry stack to render for, do not store or cache this
+ * @param last the previous entry renderer
+ * @return the new entry renderer, {@code null} is not accepted here
+ */
+ EntryRenderer<T> provide(EntryStack<T> entry, EntryRenderer<T> last);
+}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java
new file mode 100644
index 000000000..95b8981b3
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/EntryRendererRegistry.java
@@ -0,0 +1,67 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.api.client.entry.renderer;
+
+import me.shedaniel.math.Point;
+import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
+import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
+import me.shedaniel.rei.api.common.entry.EntryStack;
+import me.shedaniel.rei.api.common.entry.type.EntryType;
+import me.shedaniel.rei.api.common.plugins.PluginManager;
+import me.shedaniel.rei.api.common.registry.Reloadable;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Registry to transform {@link EntryRenderer} for stacks at a global level.
+ * For specific stacks, you can use {@link me.shedaniel.rei.api.client.util.ClientEntryStacks#setRenderer}
+ */
+@ApiStatus.Experimental
+public interface EntryRendererRegistry extends Reloadable<REIClientPlugin> {
+ static EntryRendererRegistry getInstance() {
+ return PluginManager.getClientInstance().get(EntryRendererRegistry.class);
+ }
+
+ <T> void register(EntryType<T> type, EntryRendererProvider<T> provider);
+
+ default <T> void transformTooltip(EntryType<T> type, TooltipTransformer<T> transformer) {
+ register(type, (entry, last) -> {
+ return new ForwardingEntryRenderer<T>(last) {
+ @Override
+ @Nullable
+ public Tooltip getTooltip(EntryStack<T> entry, Point mouse) {
+ return transformer.transform(entry, mouse, super.getTooltip(entry, mouse));
+ }
+ };
+ });
+ }
+
+ <T> EntryRenderer<T> get(EntryStack<T> stack);
+
+ @FunctionalInterface
+ interface TooltipTransformer<T> {
+ @Nullable
+ Tooltip transform(EntryStack<T> entry, Point mouse, @Nullable Tooltip tooltip);
+ }
+}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/ForwardingEntryRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/ForwardingEntryRenderer.java
new file mode 100644
index 000000000..2c56d5176
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/api/client/entry/renderer/ForwardingEntryRenderer.java
@@ -0,0 +1,50 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.api.client.entry.renderer;
+
+import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.math.Point;
+import me.shedaniel.math.Rectangle;
+import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
+import me.shedaniel.rei.api.common.entry.EntryStack;
+import org.jetbrains.annotations.Nullable;
+
+public abstract class ForwardingEntryRenderer<T> implements EntryRenderer<T> {
+ protected EntryRenderer<T> next;
+
+ public ForwardingEntryRenderer(EntryRenderer<T> next) {
+ this.next = next;
+ }
+
+ @Override
+ public void render(EntryStack<T> entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
+ this.next.render(entry, matrices, bounds, mouseX, mouseY, delta);
+ }
+
+ @Override
+ @Nullable
+ public Tooltip getTooltip(EntryStack<T> entry, Point mouse) {
+ return this.next.getTooltip(entry, mouse);
+ }
+}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java b/api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java
index e65ccc4e1..a6be0beeb 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/plugins/REIClientPlugin.java
@@ -23,6 +23,7 @@
package me.shedaniel.rei.api.client.plugins;
+import me.shedaniel.rei.api.client.entry.renderer.EntryRendererRegistry;
import me.shedaniel.rei.api.client.favorites.FavoriteEntryType;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
@@ -39,6 +40,16 @@ import org.jetbrains.annotations.ApiStatus;
@Environment(EnvType.CLIENT)
public interface REIClientPlugin extends REIPlugin<REIClientPlugin> {
/**
+ * Registers new entry renderers
+ *
+ * @param registry the entry renderer registry
+ */
+ @ApiStatus.OverrideOnly
+ @ApiStatus.Experimental
+ default void registerEntryRenderers(EntryRendererRegistry registry) {
+ }
+
+ /**
* Registers new categories
*
* @param registry the category registry
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java
index 2ecb40967..ad3a2aa18 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/display/DisplayRegistry.java
@@ -25,6 +25,8 @@ package me.shedaniel.rei.api.client.registry.display;
import com.google.common.base.Predicates;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
+import me.shedaniel.rei.api.client.registry.display.reason.DisplayAdditionReason;
+import me.shedaniel.rei.api.client.registry.display.reason.DisplayAdditionReasons;
import me.shedaniel.rei.api.client.registry.display.visibility.DisplayVisibilityPredicate;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
@@ -34,9 +36,11 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeType;
+import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.*;
+import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;
@@ -100,10 +104,20 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> {
* @param object the object to be filled
*/
default void add(Object object) {
+ addWithReason(object, DisplayAdditionReason.NONE);
+ }
+
+ /**
+ * Registers a display by the object provided, to be filled during {@link #tryFillDisplay(Object)}.
+ *
+ * @param object the object to be filled
+ */
+ @ApiStatus.Experimental
+ default void addWithReason(Object object, DisplayAdditionReason... reasons) {
if (object instanceof Display) {
add((Display) object, null);
} else {
- for (Display display : tryFillDisplay(object)) {
+ for (Display display : tryFillDisplay(object, reasons)) {
add(display, object);
}
}
@@ -275,6 +289,21 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> {
* Vanilla {@link Recipe} are by default filled, display filters
* can be used to automatically generate displaies for vanilla {@link Recipe}.
*
+ * @param typeClass the type of {@code T}
+ * @param predicate the predicate of {@code T} and reason
+ * @param filler the filler, taking a {@code T} and returning a {@code D}
+ * @param <T> the type of object
+ * @param <D> the type of display
+ */
+ @ApiStatus.Experimental
+ <T, D extends Display> void registerFiller(Class<T> typeClass, BiPredicate<? extends T, DisplayAdditionReasons> predicate, Function<? extends T, D> filler);
+
+ /**
+ * Registers a display filler, to be filled during {@link #tryFillDisplay(Object)}.
+ * <p>
+ * Vanilla {@link Recipe} are by default filled, display filters
+ * can be used to automatically generate displaies for vanilla {@link Recipe}.
+ *
* @param predicate the predicate of the object
* @param filler the filler, taking an object and returning a {@code D}
* @param <D> the type of display
@@ -288,7 +317,19 @@ public interface DisplayRegistry extends RecipeManagerContext<REIClientPlugin> {
* @param <T> the type of object
* @return the collection of displays
*/
- <T> Collection<Display> tryFillDisplay(T value);
+ default <T> Collection<Display> tryFillDisplay(T value) {
+ return tryFillDisplay(value, DisplayAdditionReason.NONE);
+ }
+
+ /**
+ * Tries to fill displays from {@code T}.
+ *
+ * @param value the object
+ * @param <T> the type of object
+ * @return the collection of displays
+ */
+ @ApiStatus.Experimental
+ <T> Collection<Display> tryFillDisplay(T value, DisplayAdditionReason... reasons);
@Nullable
Object getDisplayOrig