aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-06-18 20:07:38 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-06-18 20:07:38 +0800
commit609c2238e12ad9835c449cd9f9da842ca747d5dc (patch)
tree87d52715819b31543afe88137cd196ce6d7e9cad /src/main/java
parent4f3a2eae017efe3ff6896f5c01d58c7b1a27d814 (diff)
downloadRoughlyEnoughItems-609c2238e12ad9835c449cd9f9da842ca747d5dc.tar.gz
RoughlyEnoughItems-609c2238e12ad9835c449cd9f9da842ca747d5dc.tar.bz2
RoughlyEnoughItems-609c2238e12ad9835c449cd9f9da842ca747d5dc.zip
nah let's break everyone's plugins
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java14
-rw-r--r--src/main/java/me/shedaniel/rei/api/DisplayHelper.java8
-rw-r--r--src/main/java/me/shedaniel/rei/api/DisplaySettings.java44
-rw-r--r--src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java10
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeCategory.java61
-rw-r--r--src/main/java/me/shedaniel/rei/api/RecipeHelper.java8
-rw-r--r--src/main/java/me/shedaniel/rei/api/Renderable.java77
-rw-r--r--src/main/java/me/shedaniel/rei/api/Renderer.java65
-rw-r--r--src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java10
-rw-r--r--src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java20
-rw-r--r--src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java20
-rw-r--r--src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java4
-rw-r--r--src/main/java/me/shedaniel/rei/gui/config/DisplayVisibility.java13
-rw-r--r--src/main/java/me/shedaniel/rei/gui/renderables/SimpleRecipeRenderer.java6
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/SlotWidget.java7
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java26
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultPotionEffectExclusionZones.java6
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/DefaultRecipeBookExclusionZones.java7
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/blasting/DefaultBlastingCategory.java5
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/brewing/DefaultBrewingCategory.java3
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/campfire/DefaultCampfireCategory.java3
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/composting/DefaultCompostingCategory.java32
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java3
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/smelting/DefaultSmeltingCategory.java5
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/smoking/DefaultSmokingCategory.java5
-rw-r--r--src/main/java/me/shedaniel/rei/plugin/stonecutting/DefaultStoneCuttingCategory.java23
26 files changed, 153 insertions, 332 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java
index 7d311609f..cfdb29282 100644
--- a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java
+++ b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java
@@ -9,6 +9,7 @@ import net.minecraft.client.gui.screen.Screen;
import java.awt.*;
import java.util.List;
+import java.util.function.Function;
public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Screen> {
/**
@@ -24,17 +25,8 @@ public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Sc
* Register an exclusion zone
*
* @param screenClass the screen
- * @param supplier the exclusion zone supplier
+ * @param supplier the exclusion zone supplier, isOnRightSide -> the list of exclusion zones
*/
- void registerExclusionZones(Class<?> screenClass, ExclusionZoneSupplier supplier);
+ void registerExclusionZones(Class<?> screenClass, Function<Boolean, List<Rectangle>> supplier);
- public static interface ExclusionZoneSupplier {
- /**
- * Gets the current exclusion zones
- *
- * @param isOnRightSide whether the user has set the overlay to the right
- * @return the list of exclusion zones
- */
- List<Rectangle> apply(boolean isOnRightSide);
- }
}
diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java
index 755ca84b3..53d35a3dd 100644
--- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java
+++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java
@@ -22,14 +22,14 @@ public interface DisplayHelper {
* @return the sorted list of responsible bounds handlers
* @see DisplayHelper#getResponsibleBoundsHandler(Class) for the unsorted version
*/
- List<DisplayBoundsHandler> getSortedBoundsHandlers(Class screenClass);
+ List<DisplayBoundsHandler<?>> getSortedBoundsHandlers(Class<?> screenClass);
/**
* Gets all registered bounds handlers
*
* @return the list of registered bounds handlers
*/
- List<DisplayBoundsHandler> getAllBoundsHandlers();
+ List<DisplayBoundsHandler<?>> getAllBoundsHandlers();
/**
* Gets all responsible bounds handlers
@@ -38,14 +38,14 @@ public interface DisplayHelper {
* @return the the list of responsible bounds handlers
* @see DisplayHelper#getSortedBoundsHandlers(Class) for the sorted version
*/
- DisplayBoundsHandler getResponsibleBoundsHandler(Class screenClass);
+ DisplayBoundsHandler<?> getResponsibleBoundsHandler(Class<?> screenClass);
/**
* Registers a bounds handler
*
* @param handler the handler to register
*/
- void registerBoundsHandler(DisplayBoundsHandler handler);
+ void registerBoundsHandler(DisplayBoundsHandler<?> handler);
/**
* Gets the base bounds handler api for exclusion zones
diff --git a/src/main/java/me/shedaniel/rei/api/DisplaySettings.java b/src/main/java/me/shedaniel/rei/api/DisplaySettings.java
deleted file mode 100644
index 36fa1634b..000000000
--- a/src/main/java/me/shedaniel/rei/api/DisplaySettings.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Roughly Enough Items by Danielshe.
- * Licensed under the MIT License.
- */
-
-package me.shedaniel.rei.api;
-
-public interface DisplaySettings<T extends RecipeDisplay> {
-
- /**
- * Gets the recipe display height
- *
- * @param category the category of the display
- * @return the height
- */
- int getDisplayHeight(RecipeCategory<?> category);
-
- /**
- * Gets the recipe display width
- *
- * @param category the category of the display
- * @param display the display of the recipe
- * @return the width
- */
- int getDisplayWidth(RecipeCategory<?> category, T display);
-
- /**
- * Gets the maximum amount of recipe displays of the category displayed at the same time.
- *
- * @param category the category of the displays
- * @return the maximum amount
- */
- int getMaximumRecipePerPage(RecipeCategory<?> category);
-
- /**
- * Gets the fixed amount of recipes per page.
- *
- * @return the amount of recipes, returns -1 if not fixed
- */
- default int getFixedRecipesPerPage() {
- return -1;
- }
-
-}
diff --git a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java
index f29ca9129..5e6cde696 100644
--- a/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java
+++ b/src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java
@@ -5,7 +5,7 @@
package me.shedaniel.rei.api;
-import me.shedaniel.rei.gui.config.DisplayVisibility;
+import net.minecraft.util.ActionResult;
public interface DisplayVisibilityHandler {
@@ -20,14 +20,14 @@ public interface DisplayVisibilityHandler {
/**
* Handles the visibility of the display.
- * {@link DisplayVisibility#PASS} to pass the handling to another handler
- * {@link DisplayVisibility#ALWAYS_VISIBLE} to always display it
- * {@link DisplayVisibility#NEVER_VISIBLE} to never display it
+ * {@link ActionResult#PASS} to pass the handling to another handler
+ * {@link ActionResult#SUCCESS} to always display it
+ * {@link ActionResult#FAIL} to never display it
*
* @param category the category of the display
* @param display the display of the recipe
* @return the visibility
*/
- DisplayVisibility handleDisplay(RecipeCategory<?> category, RecipeDisplay display);
+ ActionResult handleDisplay(RecipeCategory<?> category, RecipeDisplay display);
}
diff --git a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
index 64c53c300..73d1367c1 100644
--- a/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
+++ b/src/main/java/me/shedaniel/rei/api/RecipeCategory.java
@@ -12,7 +12,6 @@ import me.shedaniel.rei.gui.widget.CategoryBaseWidget;
import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
import me.shedaniel.rei.gui.widget.Widget;
import net.minecraft.client.gui.DrawableHelper;
-import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import java.awt.*;
@@ -31,25 +30,11 @@ public interface RecipeCategory<T extends RecipeDisplay> {
Identifier getIdentifier();
/**
- * Gets the stack to render for the icon
- *
- * @return the stack to render
- * @deprecated use {@link RecipeCategory#getIcon()} instead
- */
- @Deprecated
- default ItemStack getCategoryIcon() {
- return ItemStack.EMPTY;
- }
-
- /**
* Gets the renderer of the icon, allowing developers to render things other than items
*
* @return the renderer of the icon
*/
- @SuppressWarnings("deprecation")
- default Renderer getIcon() {
- return Renderable.fromItemStackSupplier(this::getCategoryIcon);
- }
+ Renderer getIcon();
/**
* Gets the category name
@@ -66,7 +51,7 @@ public interface RecipeCategory<T extends RecipeDisplay> {
*/
@SuppressWarnings("unchecked")
default RecipeRenderer getSimpleRenderer(T recipe) {
- return Renderable.fromRecipe(recipe::getInput, recipe::getOutput);
+ return Renderer.fromRecipe(recipe::getInput, recipe::getOutput);
}
/**
@@ -100,58 +85,40 @@ public interface RecipeCategory<T extends RecipeDisplay> {
}
/**
- * Gets the display settings for the category, used for getting the bounds for the display
- *
- * @return the display settings
- */
- default DisplaySettings<T> getDisplaySettings() {
- return new DisplaySettings<T>() {
- @Override
- public int getDisplayHeight(RecipeCategory<?> category) {
- return 66;
- }
-
- @Override
- public int getDisplayWidth(RecipeCategory<?> category, T display) {
- return 150;
- }
-
- @Override
- public int getMaximumRecipePerPage(RecipeCategory<?> category) {
- return 99;
- }
- };
- }
-
- /**
* Gets the recipe display height
- * Please do not override this, use {@link RecipeCategory#getDisplaySettings()} instead
*
* @return the recipe display height
*/
default int getDisplayHeight() {
- return RecipeHelper.getInstance().getCachedCategorySettings(getIdentifier()).map(settings -> settings.getDisplayHeight(this)).orElse(0);
+ return 66;
}
/**
* Gets the recipe display width
- * Please do not override this, use {@link RecipeCategory#getDisplaySettings()} instead
*
* @param display the recipe display
* @return the recipe display width
*/
default int getDisplayWidth(T display) {
- return RecipeHelper.getInstance().getCachedCategorySettings(getIdentifier()).map(settings -> settings.getDisplayWidth(this, display)).orElse(0);
+ return 150;
}
/**
* Gets the maximum recipe per page.
- * Please do not override this, use {@link RecipeCategory#getDisplaySettings()} instead
*
* @return the maximum amount of recipes for page
*/
default int getMaximumRecipePerPage() {
- return RecipeHelper.getInstance().getCachedCategorySettings(getIdentifier()).map(settings -> settings.getMaximumRecipePerPage(this)).orElse(0);
+ return 99;
+ }
+
+ /**
+ * Gets the fixed amount of recipes per page.
+ *
+ * @return the amount of recipes, returns -1 if not fixed
+ */
+ default int getFixedRecipesPerPage() {
+ return -1;
}
/**
diff --git a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java
index 80bb18238..70373ca51 100644
--- a/src/main/java/me/shedaniel/rei/api/RecipeHelper.java
+++ b/src/main/java/me/shedaniel/rei/api/RecipeHelper.java
@@ -197,14 +197,6 @@ public interface RecipeHelper {
<T extends Recipe<?>> void registerRecipes(Identifier category, Predicate<Recipe> recipeFilter, Function<T, RecipeDisplay> mappingFunction);
/**
- * Gets the cached category setting by the category identifier
- *
- * @param category the identifier of the category
- * @return the optional of the category settings
- */
- Optional<DisplaySettings> getCachedCategorySettings(Identifier category);
-
- /**
* Registers a live recipe generator.
*
* @param liveRecipeGenerator the generator to register
diff --git a/src/main/java/me/shedaniel/rei/api/Renderable.java b/src/main/java/me/shedaniel/rei/api/Renderable.java
deleted file mode 100644
index 2d4c258ca..000000000
--- a/src/main/java/me/shedaniel/rei/api/Renderable.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Roughly Enough Items by Danielshe.
- * Licensed under the MIT License.
- */
-
-package me.shedaniel.rei.api;
-
-import me.shedaniel.rei.gui.renderables.EmptyRenderer;
-import me.shedaniel.rei.gui.renderables.ItemStackRenderer;
-import me.shedaniel.rei.gui.renderables.SimpleRecipeRenderer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.math.MathHelper;
-
-import java.util.List;
-import java.util.function.Supplier;
-
-/**
- * The base class for renderables
- */
-public class Renderable {
-
- /**
- * Gets an item stack renderer by an item stack supplier
- *
- * @param supplier the supplier for getting the item stack
- * @return the item stack renderer
- */
- public static ItemStackRenderer fromItemStackSupplier(Supplier<ItemStack> supplier) {
- return new ItemStackRenderer() {
- @Override
- public ItemStack getItemStack() {
- return supplier.get();
- }
- };
- }
-
- /**
- * Gets an item stack renderer by an item stack
- *
- * @param stack the item stack to be displayed
- * @return the item stack renderer
- */
- public static ItemStackRenderer fromItemStack(ItemStack stack) {
- return fromItemStackSupplier(() -> stack);
- }
-
- /**
- * Gets an empty renderer
- *
- * @return an empty renderer
- */
- public static EmptyRenderer empty() {
- return EmptyRenderer.INSTANCE;
- }
-
- /**
- * Gets a simple recipe renderer from inputs and outputs
- *
- * @param input the list of input items
- * @param output the list of output items
- * @return the recipe renderer
- */
- public static SimpleRecipeRenderer fromRecipe(Supplier<List<List<ItemStack>>> input, Supplier<List<ItemStack>> output) {
- return new SimpleRecipeRenderer(input, output);
- }
-
- public static ItemStackRenderer fromItemStacks(List<ItemStack> stacks) {
- return new ItemStackRenderer() {
- @Override
- public ItemStack getItemStack() {
- if (stacks.isEmpty())
- return ItemStack.EMPTY;
- return stacks.get(MathHelper.floor((System.currentTimeMillis() / 500 % (double) stacks.size()) / 1f));
- }
- };
- }
-}
diff --git a/src/main/java/me/shedaniel/rei/api/Renderer.java b/src/main/java/me/shedaniel/rei/api/Renderer.java
index d3ddab934..43d4c55b3 100644
--- a/src/main/java/me/shedaniel/rei/api/Renderer.java
+++ b/src/main/java/me/shedaniel/rei/api/Renderer.java
@@ -5,10 +5,74 @@
package me.shedaniel.rei.api;
+import me.shedaniel.rei.gui.renderables.EmptyRenderer;
+import me.shedaniel.rei.gui.renderables.ItemStackRenderer;
+import me.shedaniel.rei.gui.renderables.SimpleRecipeRenderer;
import net.minecraft.client.gui.DrawableHelper;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.math.MathHelper;
+
+import java.util.List;
+import java.util.function.Supplier;
public abstract class Renderer extends DrawableHelper {
/**
+ * Gets an item stack renderer by an item stack supplier
+ *
+ * @param supplier the supplier for getting the item stack
+ * @return the item stack renderer
+ */
+ public static ItemStackRenderer fromItemStackSupplier(Supplier<ItemStack> supplier) {
+ return new ItemStackRenderer() {
+ @Override
+ public ItemStack getItemStack() {
+ return supplier.get();
+ }
+ };
+ }
+
+ /**
+ * Gets an item stack renderer by an item stack
+ *
+ * @param stack the item stack to be displayed
+ * @return the item stack renderer
+ */
+ public static ItemStackRenderer fromItemStack(ItemStack stack) {
+ return fromItemStackSupplier(() -> stack);
+ }
+
+ /**
+ * Gets an empty renderer
+ *
+ * @return an empty renderer
+ */
+ public static EmptyRenderer empty() {
+ return EmptyRenderer.INSTANCE;
+ }
+
+ /**
+ * Gets a simple recipe renderer from inputs and outputs
+ *
+ * @param input the list of input items
+ * @param output the list of output items
+ * @return the recipe renderer
+ */
+ public static SimpleRecipeRenderer fromRecipe(Supplier<List<List<ItemStack>>> input, Supplier<List<ItemStack>> output) {
+ return new SimpleRecipeRenderer(input, output);
+ }
+
+ public static ItemStackRenderer fromItemStacks(List<ItemStack> stacks) {
+ return new ItemStackRenderer() {
+ @Override
+ public ItemStack getItemStack() {
+ if (stacks.isEmpty())
+ return ItemStack.EMPTY;
+ return stacks.get(MathHelper.floor((System.currentTimeMillis() / 500 % (double) stacks.size()) / 1f));
+ }
+ };
+ }
+
+ /**
* Gets the current blit offset
*
* @return the blit offset
@@ -36,4 +100,5 @@ public abstract class Renderer extends DrawableHelper {
* @param delta the delta
*/
public abstract void render(int x, int y, double mouseX, double mouseY, float delta);
+
}
diff --git a/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java b/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java
index 426ccd926..1ae0bf958 100644
--- a/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java
+++ b/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java
@@ -24,15 +24,15 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler {
private static final Function<Rectangle, String> RECTANGLE_STRING_FUNCTION = rectangle -> rectangle.x + "," + rectangle.y + "," + rectangle.width + "," + rectangle.height;
private static final Comparator<Rectangle> RECTANGLE_COMPARATOR = BaseBoundsHandlerImpl::compare;
- private static final Comparator<Pair<Pair<Class<?>, Float>, ExclusionZoneSupplier>> LIST_PAIR_COMPARATOR;
+ private static final Comparator<Pair<Pair<Class<?>, Float>, Function<Boolean, List<Rectangle>>>> LIST_PAIR_COMPARATOR;
static {
- Comparator<Pair<Pair<Class<?>, Float>, ExclusionZoneSupplier>> comparator = Comparator.comparingDouble(value -> value.getLeft().getRight());
+ Comparator<Pair<Pair<Class<?>, Float>, Function<Boolean, List<Rectangle>>>> comparator = Comparator.comparingDouble(value -> value.getLeft().getRight());
LIST_PAIR_COMPARATOR = comparator.reversed();
}
private String lastArea = null;
- private List<Pair<Pair<Class<?>, Float>, ExclusionZoneSupplier>> list = Lists.newArrayList();
+ private List<Pair<Pair<Class<?>, Float>, Function<Boolean, List<Rectangle>>>> list = Lists.newArrayList();
private static int compare(Rectangle o1, Rectangle o2) {return RECTANGLE_STRING_FUNCTION.apply(o1).compareTo(RECTANGLE_STRING_FUNCTION.apply(o2));}
@@ -94,7 +94,7 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler {
}
public List<Rectangle> getCurrentExclusionZones(Class<?> currentScreenClass, boolean isOnRightSide) {
- List<Pair<Pair<Class<?>, Float>, ExclusionZoneSupplier>> only = list.stream().filter(pair -> pair.getLeft().getLeft().isAssignableFrom(currentScreenClass)).collect(Collectors.toList());
+ List<Pair<Pair<Class<?>, Float>, Function<Boolean, List<Rectangle>>>> only = list.stream().filter(pair -> pair.getLeft().getLeft().isAssignableFrom(currentScreenClass)).collect(Collectors.toList());
only.sort(LIST_PAIR_COMPARATOR);
List<Rectangle> rectangles = Lists.newArrayList();
only.forEach(pair -> rectangles.addAll(pair.getRight().apply(isOnRightSide)));
@@ -102,7 +102,7 @@ public class BaseBoundsHandlerImpl implements BaseBoundsHandler {
}
@Override
- public void registerExclusionZones(Class<?> screenClass, ExclusionZoneSupplier supplier) {
+ public void registerExclusionZones(Class<?> screenClass, Function<Boolean, List<Rectangle>> supplier) {
list.add(new Pair<>(new Pair<>(screenClass, 0f), supplier));
}
diff --git a/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java b/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java
index 4cac6a11f..ac6d581bf 100644
--- a/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java
+++ b/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java
@@ -19,8 +19,8 @@ import java.util.stream.Collectors;
public class DisplayHelperImpl implements DisplayHelper {
- private static final Comparator<DisplayBoundsHandler> BOUNDS_HANDLER_COMPARATOR;
- private static final DisplayBoundsHandler EMPTY = new DisplayBoundsHandler() {
+ private static final Comparator<DisplayBoundsHandler<?>> BOUNDS_HANDLER_COMPARATOR;
+ private static final DisplayBoundsHandler<Object> EMPTY = new DisplayBoundsHandler() {
@Override
public Class getBaseSupportedClass() {
return null;
@@ -43,27 +43,27 @@ public class DisplayHelperImpl implements DisplayHelper {
};
static {
- Comparator<DisplayBoundsHandler> comparator = Comparator.comparingDouble(DisplayBoundsHandler::getPriority);
+ Comparator<DisplayBoundsHandler<?>> comparator = Comparator.comparingDouble(DisplayBoundsHandler::getPriority);
BOUNDS_HANDLER_COMPARATOR = comparator.reversed();
}
- private List<DisplayBoundsHandler> screenDisplayBoundsHandlers = Lists.newArrayList();
- private Map<Class, DisplayBoundsHandler> handlerCache = Maps.newHashMap();
+ private List<DisplayBoundsHandler<?>> screenDisplayBoundsHandlers = Lists.newArrayList();
+ private Map<Class<?>, DisplayBoundsHandler<?>> handlerCache = Maps.newHashMap();
private BaseBoundsHandler baseBoundsHandler;
@Override
- public List<DisplayBoundsHandler> getSortedBoundsHandlers(Class screenClass) {
+ public List<DisplayBoundsHandler<?>> getSortedBoundsHandlers(Class<?> screenClass) {
return screenDisplayBoundsHandlers.stream().filter(handler -> handler.getBaseSupportedClass().isAssignableFrom(screenClass)).sorted(BOUNDS_HANDLER_COMPARATOR).collect(Collectors.toList());
}
@Override
- public List<DisplayBoundsHandler> getAllBoundsHandlers() {
+ public List<DisplayBoundsHandler<?>> getAllBoundsHandlers() {
return screenDisplayBoundsHandlers;
}
@Override
- public DisplayBoundsHandler getResponsibleBoundsHandler(Class screenClass) {
- Optional<DisplayBoundsHandler> any = handlerCache.entrySet().stream().filter(entry -> entry.getKey().equals(screenClass)).map(Map.Entry::getValue).findAny();
+ public DisplayBoundsHandler<?> getResponsibleBoundsHandler(Class<?> screenClass) {
+ Optional<? extends DisplayBoundsHandler<?>> any = handlerCache.entrySet().stream().filter(entry -> entry.getKey().equals(screenClass)).map(Map.Entry::getValue).findAny();
if (any.isPresent())
return any.get();
handlerCache.put(screenClass, screenDisplayBoundsHandlers.stream().filter(handler -> handler.getBaseSupportedClass().isAssignableFrom(screenClass)).sorted(BOUNDS_HANDLER_COMPARATOR).findAny().orElse(EMPTY));
@@ -71,7 +71,7 @@ public class DisplayHelperImpl implements DisplayHelper {
}
@Override
- public void registerBoundsHandler(DisplayBoundsHandler handler) {
+ public void registerBoundsHandler(DisplayBoundsHandler<?> handler) {
screenDisplayBoundsHandlers.add(handler);
}
diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
index 5db09d727..679d327e8 100644
--- a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
+++ b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java
@@ -9,10 +9,10 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.*;
-import me.shedaniel.rei.gui.config.DisplayVisibility;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeManager;
+import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import java.awt.*;
@@ -42,7 +42,6 @@ public class RecipeHelperImpl implements RecipeHelper {
private final List<RecipeFunction> recipeFunctions = Lists.newArrayList();
private final AtomicInteger recipeCount = new AtomicInteger();
private final Map<Identifier, List<RecipeDisplay>> recipeCategoryListMap = Maps.newHashMap();
- private final Map<Identifier, DisplaySettings> categoryDisplaySettingsMap = Maps.newHashMap();
private final List<RecipeCategory> categories = Lists.newArrayList();
private final Map<Identifier, ButtonAreaSupplier> speedCraftAreaSupplierMap = Maps.newHashMap();
private final Map<Identifier, List<List<ItemStack>>> categoryWorkingStations = Maps.newHashMap();
@@ -267,8 +266,8 @@ public class RecipeHelperImpl implements RecipeHelper {
if (getDisplayVisibilityHandlers().isEmpty())
registerRecipeVisibilityHandler(new DisplayVisibilityHandler() {
@Override
- public DisplayVisibility handleDisplay(RecipeCategory<?> category, RecipeDisplay display) {
- return DisplayVisibility.ALWAYS_VISIBLE;
+ public ActionResult handleDisplay(RecipeCategory<?> category, RecipeDisplay display) {
+ return ActionResult.SUCCESS;
}
@Override
@@ -278,8 +277,6 @@ public class RecipeHelperImpl implements RecipeHelper {
});
// Clear Cache
((DisplayHelperImpl) RoughlyEnoughItemsCore.getDisplayHelper()).resetCache();
- this.categoryDisplaySettingsMap.clear();
- getAllCategories().forEach(category -> categoryDisplaySettingsMap.put(category.getIdentifier(), category.getDisplaySettings()));
ScreenHelper.getOptionalOverlay().ifPresent(overlay -> overlay.shouldReInit = true);
long usedTime = System.currentTimeMillis() - startTime;
@@ -353,9 +350,9 @@ public class RecipeHelperImpl implements RecipeHelper {
List<DisplayVisibilityHandler> list = getDisplayVisibilityHandlers().stream().sorted(VISIBILITY_HANDLER_COMPARATOR).collect(Collectors.toList());
for(DisplayVisibilityHandler displayVisibilityHandler : list) {
try {
- DisplayVisibility visibility = displayVisibilityHandler.handleDisplay(category, display);