diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-05-01 13:22:23 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-05-01 13:22:23 +0800 |
| commit | c1de02e7d2d42123cb207f9fa8e869c8a25fcdf6 (patch) | |
| tree | 8dd9f6ea157ae0bf85561e7f85b085b9565141de /src/main/java/me/shedaniel/rei | |
| parent | 6345d24492242ba9ea26c6b83163aa81464c8cfd (diff) | |
| parent | c57ef35f9d99ec64ec1501932a70cab40fcc5107 (diff) | |
| download | RoughlyEnoughItems-c1de02e7d2d42123cb207f9fa8e869c8a25fcdf6.tar.gz RoughlyEnoughItems-c1de02e7d2d42123cb207f9fa8e869c8a25fcdf6.tar.bz2 RoughlyEnoughItems-c1de02e7d2d42123cb207f9fa8e869c8a25fcdf6.zip | |
Merge branch '1.14-dev' into 1.14
Diffstat (limited to 'src/main/java/me/shedaniel/rei')
10 files changed, 225 insertions, 61 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java new file mode 100644 index 000000000..83cf9163c --- /dev/null +++ b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java @@ -0,0 +1,16 @@ +package me.shedaniel.rei.api; + +import net.minecraft.client.gui.Screen; + +import java.awt.*; +import java.util.List; + +public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Screen> { + List<Rectangle> getCurrentExclusionZones(Class<? extends Screen> currentScreenClass, boolean isOnRightSide); + + void registerExclusionZones(Class<? extends Screen> screenClass, ExclusionZoneSupplier supplier); + + public static interface ExclusionZoneSupplier { + 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 edb319d76..5d4fda8a4 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -16,6 +16,8 @@ public interface DisplayHelper { void registerBoundsHandler(DisplayBoundsHandler handler); + BaseBoundsHandler getBaseBoundsHandler(); + public static interface DisplayBoundsHandler<T> { Class getBaseSupportedClass(); @@ -31,6 +33,10 @@ public interface DisplayHelper { return new Rectangle(rectangle.x + 2, rectangle.y + 24, rectangle.width - 4, rectangle.height - (RoughlyEnoughItemsCore.getConfigManager().getConfig().sideSearchField ? 27 + 22 : 27)); } + default boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) { + return false; + } + default float getPriority() { return 0f; } diff --git a/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java b/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java new file mode 100644 index 000000000..2548d23ab --- /dev/null +++ b/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java @@ -0,0 +1,93 @@ +package me.shedaniel.rei.client; + +import com.google.common.collect.Lists; +import me.shedaniel.rei.api.BaseBoundsHandler; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.Screen; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Pair; + +import java.awt.*; +import java.util.Comparator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +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<? extends Screen>, Float>, ExclusionZoneSupplier>> LIST_PAIR_COMPARATOR; + + static { + Comparator<Pair<Pair<Class<? extends Screen>, Float>, ExclusionZoneSupplier>> comparator = Comparator.comparingDouble(value -> value.getLeft().getRight()); + LIST_PAIR_COMPARATOR = comparator.reversed(); + } + + private String lastArea = null; + private List<Pair<Pair<Class<? extends Screen>, Float>, ExclusionZoneSupplier>> list = Lists.newArrayList(); + + private static int compare(Rectangle o1, Rectangle o2) {return RECTANGLE_STRING_FUNCTION.apply(o1).compareTo(RECTANGLE_STRING_FUNCTION.apply(o2));} + + @Override + public Class getBaseSupportedClass() { + return Screen.class; + } + + @Override + public Rectangle getLeftBounds(Screen screen) { + return new Rectangle(); + } + + @Override + public Rectangle getRightBounds(Screen screen) { + return new Rectangle(); + } + + @Override + public float getPriority() { + return -5f; + } + + @Override + public boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) { + if (lastArea == null) { + lastArea = getStringFromAreas(rectangle, getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide)); + return false; + } + String fromAreas = getStringFromAreas(rectangle, getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide)); + if (lastArea.contentEquals(fromAreas)) + return false; + lastArea = fromAreas; + return true; + } + + @Override + public ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, Screen screen, Rectangle fullBounds) { + List<Rectangle> currentExclusionZones = getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide); + for(Rectangle currentExclusionZone : currentExclusionZones) + if (left + 18 >= currentExclusionZone.x && top + 18 >= currentExclusionZone.y && left <= currentExclusionZone.x + currentExclusionZone.width && top <= currentExclusionZone.y + currentExclusionZone.height) + return ActionResult.FAIL; + return ActionResult.PASS; + } + + public List<Rectangle> getCurrentExclusionZones(Class<? extends Screen> currentScreenClass, boolean isOnRightSide) { + List<Pair<Pair<Class<? extends Screen>, Float>, ExclusionZoneSupplier>> 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))); + return rectangles; + } + + @Override + public void registerExclusionZones(Class<? extends Screen> screenClass, ExclusionZoneSupplier supplier) { + list.add(new Pair<>(new Pair<>(screenClass, 0f), supplier)); + } + + public String getStringFromAreas(Rectangle rectangle, List<Rectangle> exclusionZones) { + List<Rectangle> sorted = Lists.newArrayList(exclusionZones); + sorted.sort(RECTANGLE_COMPARATOR); + return RECTANGLE_STRING_FUNCTION.apply(rectangle) + ":" + sorted.stream().map(RECTANGLE_STRING_FUNCTION::apply).collect(Collectors.joining("|")); + } + +} diff --git a/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java b/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java index e1f6c8144..28c5f5e43 100644 --- a/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java @@ -2,6 +2,7 @@ package me.shedaniel.rei.client; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import me.shedaniel.rei.api.BaseBoundsHandler; import me.shedaniel.rei.api.DisplayHelper; import java.awt.*; @@ -33,9 +34,15 @@ public class DisplayHelperImpl implements DisplayHelper { public Rectangle getRightBounds(Object screen) { return new Rectangle(); } + + @Override + public float getPriority() { + return -10f; + } }; private List<DisplayBoundsHandler> screenDisplayBoundsHandlerMap = Lists.newArrayList(); private Map<Class, DisplayBoundsHandler> handlerCache = Maps.newHashMap(); + private BaseBoundsHandler baseBoundsHandler; @Override public List<DisplayBoundsHandler> getSortedBoundsHandlers(Class screenClass) { @@ -59,6 +66,15 @@ public class DisplayHelperImpl implements DisplayHelper { screenDisplayBoundsHandlerMap.add(handler); } + @Override + public BaseBoundsHandler getBaseBoundsHandler() { + return baseBoundsHandler; + } + + public void setBaseBoundsHandler(BaseBoundsHandler baseBoundsHandler) { + this.baseBoundsHandler = baseBoundsHandler; + } + public void resetCache() { handlerCache.clear(); } diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java index 22df089ea..ec5b211d0 100644 --- a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java @@ -185,6 +185,9 @@ public class RecipeHelperImpl implements RecipeHelper { this.categoryDisplaySettingsMap.clear(); this.displayVisibilityHandlers.clear(); ((DisplayHelperImpl) RoughlyEnoughItemsCore.getDisplayHelper()).resetCache(); + BaseBoundsHandler baseBoundsHandler = new BaseBoundsHandlerImpl(); + RoughlyEnoughItemsCore.getDisplayHelper().registerBoundsHandler(baseBoundsHandler); + ((DisplayHelperImpl) RoughlyEnoughItemsCore.getDisplayHelper()).setBaseBoundsHandler(baseBoundsHandler); long startTime = System.currentTimeMillis(); List<REIPluginEntry> plugins = new LinkedList<>(RoughlyEnoughItemsCore.getPlugins()); plugins.sort((first, second) -> { @@ -196,16 +199,20 @@ public class RecipeHelperImpl implements RecipeHelper { PluginDisabler pluginDisabler = RoughlyEnoughItemsCore.getPluginDisabler(); plugins.forEach(plugin -> { Identifier identifier = plugin.getPluginIdentifier(); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_ITEMS)) - plugin.registerItems(RoughlyEnoughItemsCore.getItemRegisterer()); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_CATEGORIES)) - plugin.registerPluginCategories(this); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_RECIPE_DISPLAYS)) - plugin.registerRecipeDisplays(this); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_BOUNDS)) - plugin.registerBounds(RoughlyEnoughItemsCore.getDisplayHelper()); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_OTHERS)) - plugin.registerOthers(this); + try { + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_ITEMS)) + plugin.registerItems(RoughlyEnoughItemsCore.getItemRegisterer()); + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_CATEGORIES)) + plugin.registerPluginCategories(this); + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_RECIPE_DISPLAYS)) + plugin.registerRecipeDisplays(this); + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_BOUNDS)) + plugin.registerBounds(RoughlyEnoughItemsCore.getDisplayHelper()); + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_OTHERS)) + plugin.registerOthers(this); + } catch (Exception e) { + RoughlyEnoughItemsCore.LOGGER.error("[REI] %s plugin failed to load: %s", identifier.toString(), e.getLocalizedMessage()); + } }); if (getDisplayVisibilityHandlers().size() == 0) registerRecipeVisibilityHandler(new DisplayVisibilityHandler() { diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 41bd9b9ec..8c60ac015 100644 --- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -327,7 +327,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra @Override public void render(int mouseX, int mouseY, float delta) { List<ItemStack> currentStacks = ClientHelper.getInventoryItemsTypes(); - if (getLeft() != lastLeft) + if (RoughlyEnoughItemsCore.getDisplayHelper().getBaseBoundsHandler() != null && RoughlyEnoughItemsCore.getDisplayHelper().getBaseBoundsHandler().shouldRecalculateArea(!RoughlyEnoughItemsCore.getConfigManager().getConfig().mirrorItemPanel, rectangle)) init(true); else if (RoughlyEnoughItemsCore.getConfigManager().isCraftableOnlyEnabled() && (!hasSameListContent(new LinkedList<>(ScreenHelper.inventoryStacks), currentStacks) || (currentStacks.size() != ScreenHelper.inventoryStacks.size()))) { ScreenHelper.inventoryStacks = ClientHelper.getInventoryItemsTypes(); diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java index 345342ef0..0c8a50f1b 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java @@ -27,7 +27,6 @@ import org.apache.commons.lang3.StringUtils; import java.awt.*; import java.util.Arrays; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; @@ -98,45 +97,49 @@ public class ItemListOverlay extends Widget { int startX = (int) rectangle.getCenterX() - width * 9; int startY = (int) rectangle.getCenterY() - height * 9; this.listArea = new Rectangle((int) startX, (int) startY, width * 18, height * 18); - int fitSlotsPerPage = getTotalFitSlotsPerPage(listArea.x, listArea.y, listArea); + int fitSlotsPerPage = getTotalFitSlotsPerPage(startX, startY, listArea); int j = page * fitSlotsPerPage; - for(int i = 0; i < getFullTotalSlotsPerPage(); i++) { - j++; + for(int yy = 0; yy < height; yy++) { + for(int xx = 0; xx < width; xx++) { + int x = startX + xx * 18, y = startY + yy * 18; + if (!canBeFit(x, y, listArea)) + continue; + j++; + if (j > currentDisplayed.size()) + break; + widgets.add(new ItemSlotWidget(x, y, Collections.singletonList(currentDisplayed.get(j - 1)), false, true, true) { + @Override + protected void queueTooltip(ItemStack itemStack, float delta) { + ClientPlayerEntity player = minecraft.player; + if (!ClientHelper.isCheating() || player.inventory.getCursorStack().isEmpty()) + super.queueTooltip(itemStack, delta); + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (isHighlighted(mouseX, mouseY)) { + if (ClientHelper.isCheating()) { + if (getCurrentStack() != null && !getCurrentStack().isEmpty()) { + ItemStack cheatedStack = getCurrentStack().copy(); + if (RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode == ItemCheatingMode.REI_LIKE) + cheatedStack.setAmount(button != 1 ? 1 : cheatedStack.getMaxAmount()); + else if (RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode == ItemCheatingMode.JEI_LIKE) + cheatedStack.setAmount(button != 0 ? 1 : cheatedStack.getMaxAmount()); + else + cheatedStack.setAmount(1); + return ClientHelper.tryCheatingStack(cheatedStack); + } + } else if (button == 0) + return ClientHelper.executeRecipeKeyBind(getCurrentStack().copy()); + else if (button == 1) + return ClientHelper.executeUsageKeyBind(getCurrentStack().copy()); + } + return false; + } + }); + } if (j > currentDisplayed.size()) break; - int x = startX + (i % width) * 18, y = startY + MathHelper.floor(i / width) * 18; - if (!canBeFit(x, y, listArea)) - continue; - widgets.add(new ItemSlotWidget(x, y, Collections.singletonList(currentDisplayed.get(j - 1)), false, true, true) { - @Override - protected void queueTooltip(ItemStack itemStack, float delta) { - ClientPlayerEntity player = minecraft.player; - if (!ClientHelper.isCheating() || player.inventory.getCursorStack().isEmpty()) - super.queueTooltip(itemStack, delta); - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (isHighlighted(mouseX, mouseY)) { - if (ClientHelper.isCheating()) { - if (getCurrentStack() != null && !getCurrentStack().isEmpty()) { - ItemStack cheatedStack = getCurrentStack().copy(); - if (RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode == ItemCheatingMode.REI_LIKE) - cheatedStack.setAmount(button != 1 ? 1 : cheatedStack.getMaxAmount()); - else if (RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode == ItemCheatingMode.JEI_LIKE) - cheatedStack.setAmount(button != 0 ? 1 : cheatedStack.getMaxAmount()); - else - cheatedStack.setAmount(1); - return ClientHelper.tryCheatingStack(cheatedStack); - } - } else if (button == 0) - return ClientHelper.executeRecipeKeyBind(getCurrentStack().copy()); - else if (button == 1) - return ClientHelper.executeUsageKeyBind(getCurrentStack().copy()); - } - return false; - } - }); } } @@ -149,9 +152,10 @@ public class ItemListOverlay extends Widget { public int getTotalFitSlotsPerPage(int startX, int startY, Rectangle listArea) { int slots = 0; - for(int i = 0; i < getFullTotalSlotsPerPage(); i++) - if (canBeFit(startX + (i % width) * 18, startY + MathHelper.floor(i / width) * 18, listArea)) - slots++; + for(int x = 0; x < width; x++) + for(int y = 0; y < height; y++) + if (canBeFit(startX + x * 18, startY + y * 18, listArea)) + slots++; return slots; } diff --git a/src/main/java/me/shedaniel/rei/listeners/RecipeBookGuiHooks.java b/src/main/java/me/shedaniel/rei/listeners/RecipeBookGuiHooks.java index 4737b2c9d..c76eb2b6e 100644 --- a/src/main/java/me/shedaniel/rei/listeners/RecipeBookGuiHooks.java +++ b/src/main/java/me/shedaniel/rei/listeners/RecipeBookGuiHooks.java @@ -1,12 +1,17 @@ package me.shedaniel.rei.listeners; +import net.minecraft.client.gui.recipebook.GroupButtonWidget; import net.minecraft.client.gui.widget.RecipeBookGhostSlots; import net.minecraft.client.gui.widget.TextFieldWidget; +import java.util.List; + public interface RecipeBookGuiHooks { RecipeBookGhostSlots rei_getGhostSlots(); TextFieldWidget rei_getSearchField(); + List<GroupButtonWidget> rei_getTabButtons(); + } diff --git a/src/main/java/me/shedaniel/rei/mixin/MixinRecipeBookGui.java b/src/main/java/me/shedaniel/rei/mixin/MixinRecipeBookGui.java index 1cc1baf8a..7d17d3c8e 100644 --- a/src/main/java/me/shedaniel/rei/mixin/MixinRecipeBookGui.java +++ b/src/main/java/me/shedaniel/rei/mixin/MixinRecipeBookGui.java @@ -1,6 +1,7 @@ package me.shedaniel.rei.mixin; import me.shedaniel.rei.listeners.RecipeBookGuiHooks; +import net.minecraft.client.gui.recipebook.GroupButtonWidget; import net.minecraft.client.gui.recipebook.RecipeBookGui; import net.minecraft.client.gui.widget.RecipeBookGhostSlots; import net.minecraft.client.gui.widget.TextFieldWidget; @@ -8,6 +9,8 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import java.util.List; + @Mixin(RecipeBookGui.class) public class MixinRecipeBookGui implements RecipeBookGuiHooks { @@ -18,6 +21,10 @@ public class MixinRecipeBookGui implements RecipeBookGuiHooks { @Shadow private TextFieldWidget searchField; + @Shadow + @Final + private List<GroupButtonWidget> tabButtons; + public RecipeBookGhostSlots rei_getGhostSlots() { return ghostSlots; } @@ -27,4 +34,10 @@ public class MixinRecipeBookGui implements RecipeBookGuiHooks { return searchField; } + @Override + public List<GroupButtonWidget> rei_getTabButtons() { + return tabButtons; + } + + } diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java index 87c1c51f1..a6b7e19a7 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java @@ -5,6 +5,7 @@ import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.*; import me.shedaniel.rei.client.ScreenHelper; import me.shedaniel.rei.gui.RecipeViewingScreen; +import me.shedaniel.rei.listeners.ContainerScreenHooks; import me.shedaniel.rei.listeners.RecipeBookGuiHooks; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.ContainerScreen; @@ -15,6 +16,8 @@ import net.minecraft.client.gui.container.FurnaceScreen; import net.minecraft.client.gui.container.SmokerScreen; import net.minecraft.client.gui.ingame.CreativePlayerInventoryScreen; import net.minecraft.client.gui.ingame.PlayerInventoryScreen; +import net.minecraft.client.gui.ingame.RecipeBookProvider; +import net.minecraft.client.gui.recipebook.RecipeBookGui; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.item.ItemStack; @@ -28,7 +31,6 @@ import net.minecraft.recipe.cooking.SmeltingRecipe; import net.minecraft.recipe.cooking.SmokingRecipe; import net.minecraft.recipe.crafting.ShapedRecipe; import net.minecraft.recipe.crafting.ShapelessRecipe; -import net.minecraft.util.ActionResult; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -142,6 +144,17 @@ public class DefaultPlugin implements REIPluginEntry { @Override public void registerBounds(DisplayHelper displayHelper) { + displayHelper.getBaseBoundsHandler().registerExclusionZones(ContainerScreen.class, isOnRightSide -> { + if (isOnRightSide || !MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen() || !(MinecraftClient.getInstance().currentScreen instanceof RecipeBookProvider)) + return Collections.emptyList(); + ContainerScreenHooks screenHooks = ScreenHelper.getLastContainerScreenHooks(); + List l = Lists.newArrayList(new Rectangle(screenHooks.rei_getContainerLeft() - 4 - 145, screenHooks.rei_getContainerTop(), 4 + 145 + 30, screenHooks.rei_getContainerHeight())); + RecipeBookGui recipeBookGui = ((RecipeBookProvider) MinecraftClient.getInstance().currentScreen).getRecipeBookGui(); + int size = ((RecipeBookGuiHooks) recipeBookGui).rei_getTabButtons().size(); + if (size > 0) + l.add(new Rectangle(screenHooks.rei_getContainerLeft() - 4 - 145 - 30, screenHooks.rei_getContainerTop(), 30, (size - 1) * 27)); + return l; + }); displayHelper.registerBoundsHandler(new DisplayHelper.DisplayBoundsHandler<ContainerScreen>() { @Override public Class getBaseSupportedClass() { @@ -160,15 +173,6 @@ public class DefaultPlugin implements REIPluginEntry { } @Override - public ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, ContainerScreen screen, Rectangle fullBounds) { - if (!isOnRightSide) - if (MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen() && left + 18 > ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() - 4 - 145 - 30) - if (top + 18 >= ScreenHelper.getLastContainerScreenHooks().rei_getContainerTop() && top <= ScreenHelper.getLastContainerScreenHooks().rei_getContainerTop() + ScreenHelper.getLastContainerScreenHooks().rei_getContainerHeight()) - return ActionResult.FAIL; - return ActionResult.PASS; - } - - @Override public float getPriority() { return -1.0f; } |
