aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-11-05 17:27:31 +0800
committershedaniel <daniel@shedaniel.me>2020-11-05 17:27:31 +0800
commitecf3079ca2622e538cc325fa6063401139881e12 (patch)
tree00a90fcf5af63b36f4951a598270d6d81ad6b2ed
parent19d5cc098a812d08b235dbb128746380919a4de6 (diff)
downloadRoughlyEnoughItems-ecf3079ca2622e538cc325fa6063401139881e12.tar.gz
RoughlyEnoughItems-ecf3079ca2622e538cc325fa6063401139881e12.tar.bz2
RoughlyEnoughItems-ecf3079ca2622e538cc325fa6063401139881e12.zip
v5.8.0 Update
- Config screen animations - Require dragging the favorites further before initializing the dragging phase - Require specific fabric modules to run instead of the whole API - Mark getPreviousContainerScreen as nullable - New config settings for setting entry list boundaries - Update fabric loader, auto config and cloth config versions Signed-off-by: shedaniel <daniel@shedaniel.me>
-rw-r--r--RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java13
-rw-r--r--RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/ConfigObject.java6
-rw-r--r--RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/REIHelper.java2
-rw-r--r--RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java2
-rw-r--r--RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java1
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java7
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java6
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java19
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java4
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/DelegateScreen.java243
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java73
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringAddRuleScreen.java2
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRuleOptionsScreen.java2
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRulesScreen.java2
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java2
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java7
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java13
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java17
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java18
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java2
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java7
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultCategoryHandler.java2
-rw-r--r--RoughlyEnoughItems-runtime/src/main/resources/roughlyenoughitems-runtime.accessWidener7
-rwxr-xr-xbuild.gradle9
-rw-r--r--gradle.properties12
-rwxr-xr-xsrc/main/resources/assets/roughlyenoughitems/lang/en_us.json2
26 files changed, 439 insertions, 41 deletions
diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java
index 34d6cc66d..f6b9232e7 100644
--- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java
+++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/AutoTransferHandler.java
@@ -32,6 +32,7 @@ import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.world.inventory.AbstractContainerMenu;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.function.Supplier;
@@ -182,8 +183,10 @@ public interface AutoTransferHandler {
boolean isActuallyCrafting();
+ @Nullable
AbstractContainerScreen<?> getContainerScreen();
-
+
+ @Nullable
@Deprecated
@ApiStatus.ScheduledForRemoval
default AbstractContainerScreen<?> getHandledScreen() {
@@ -191,15 +194,17 @@ public interface AutoTransferHandler {
}
RecipeDisplay getRecipe();
-
+
+ @Nullable
@Deprecated
@ApiStatus.ScheduledForRemoval
default AbstractContainerMenu getScreenHandler() {
return getContainer();
}
-
+
+ @Nullable
default AbstractContainerMenu getContainer() {
- return getHandledScreen().getMenu();
+ return getContainerScreen() == null ? null : getContainerScreen().getMenu();
}
}
diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/ConfigObject.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/ConfigObject.java
index 62482d09b..da43f244f 100644
--- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/ConfigObject.java
+++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/ConfigObject.java
@@ -182,4 +182,10 @@ public interface ConfigObject {
boolean isInventoryHighlightingAllowed();
boolean shouldResizeDynamically();
+
+ @ApiStatus.Experimental
+ double getHorizontalEntriesBoundaries();
+
+ @ApiStatus.Experimental
+ double getVerticalEntriesBoundaries();
}
diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/REIHelper.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/REIHelper.java
index 6a42c90dd..787c83e19 100644
--- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/REIHelper.java
+++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/api/REIHelper.java
@@ -51,8 +51,10 @@ public interface REIHelper {
@ApiStatus.Experimental
Optional<REIOverlay> getOverlay();
+ @Nullable
AbstractContainerScreen<?> getPreviousContainerScreen();
+ @Nullable
@Deprecated
default AbstractContainerScreen<?> getPreviousHandledScreen() {
return getPreviousContainerScreen();
diff --git a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java
index 8da1c2072..80ee0196a 100644
--- a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java
+++ b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/autocrafting/DefaultRecipeBookHandler.java
@@ -51,6 +51,8 @@ public class DefaultRecipeBookHandler implements AutoTransferHandler {
if (!(context.getContainer() instanceof RecipeBookMenu))
return Result.createNotApplicable();
RecipeBookMenu<?> container = (RecipeBookMenu<?>) context.getContainer();
+ if (container == null)
+ return Result.createNotApplicable();
if (display instanceof DefaultCraftingDisplay) {
DefaultCraftingDisplay craftingDisplay = (DefaultCraftingDisplay) display;
if (craftingDisplay.getOptionalRecipe().isPresent()) {
diff --git a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java
index 7fdd83869..466c02b54 100644
--- a/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java
+++ b/RoughlyEnoughItems-default-plugin/src/main/java/me/shedaniel/rei/plugin/crafting/DefaultCraftingCategory.java
@@ -96,6 +96,7 @@ public class DefaultCraftingCategory implements TransferRecipeCategory<DefaultCr
@Override
public void renderRedSlots(PoseStack matrices, List<Widget> widgets, Rectangle bounds, DefaultCraftingDisplay display, IntList redSlots) {
+ if (REIHelper.getInstance().getPreviousContainerScreen() == null) return;
ContainerInfo<AbstractContainerMenu> info = (ContainerInfo<AbstractContainerMenu>) ContainerInfoHandler.getContainerInfo(getIdentifier(), REIHelper.getInstance().getPreviousContainerScreen().getMenu().getClass());
if (info == null)
return;
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
index 9ea31b888..9d1d572b6 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
@@ -383,11 +383,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
RoughlyEnoughItemsCore.LOGGER.error("REI plugin from " + modContainer.getMetadata().getId() + " is not loaded because it is too old!");
}
- boolean networkingLoaded = FabricLoader.getInstance().isModLoaded("fabric-networking-v0");
- if (!networkingLoaded) {
- RoughlyEnoughItemsState.error("Fabric API is not installed!", "https://www.curseforge.com/minecraft/mc-mods/fabric-api/files/all");
- return;
- }
+ RoughlyEnoughItemsState.checkRequiredFabricModules();
Executor.run(() -> () -> {
ClientSidePacketRegistry.INSTANCE.register(RoughlyEnoughItemsNetwork.CREATE_ITEMS_MESSAGE_PACKET, (packetContext, packetByteBuf) -> {
ItemStack stack = packetByteBuf.readItem();
@@ -495,6 +491,7 @@ public class RoughlyEnoughItemsCore implements ClientModInitializer {
private boolean shouldReturn(Screen screen) {
if (screen == null) return true;
+ if (screen != Minecraft.getInstance().screen) return true;
return shouldReturn(screen.getClass());
}
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java
index 9704c1516..373ba7919 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java
@@ -57,11 +57,7 @@ public class RoughlyEnoughItemsNetwork implements ModInitializer {
@Override
public void onInitialize() {
- boolean loaded = FabricLoader.getInstance().isModLoaded("fabric-networking-v0");
- if (!loaded) {
- RoughlyEnoughItemsState.error("Fabric API is not installed!", "https://www.curseforge.com/minecraft/mc-mods/fabric-api/files/all");
- return;
- }
+ RoughlyEnoughItemsState.checkRequiredFabricModules();
Executor.run(() -> () -> {
FabricLoader.getInstance().getEntrypoints("rei_containers", Runnable.class).forEach(Runnable::run);
ServerSidePacketRegistry.INSTANCE.register(DELETE_ITEMS_PACKET, (packetContext, packetByteBuf) -> {
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java
index f290132d9..398ea52ca 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java
@@ -23,6 +23,7 @@
package me.shedaniel.rei;
+import com.google.common.collect.ImmutableSet;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Tuple;
@@ -56,6 +57,24 @@ public class RoughlyEnoughItemsState {
}
}
+ public static void checkRequiredFabricModules() {
+ ImmutableSet<String> requiredModules = ImmutableSet.<String>builder()
+ .add("fabric-api-base")
+ .add("fabric-resource-loader-v0")
+ .add("fabric-networking-v0")
+ .add("fabric-lifecycle-events-v1")
+ .add("fabric-lifecycle-events-v1")
+ .add("fabric-rendering-fluids-v1")
+ .build();
+ for (String module : requiredModules) {
+ boolean moduleLoaded = FabricLoader.getInstance().isModLoaded(module);
+ if (!moduleLoaded) {
+ RoughlyEnoughItemsState.error("Fabric API is not installed!", "https://www.curseforge.com/minecraft/mc-mods/fabric-api/files/all");
+ return;
+ }
+ }
+ }
+
public static void error(String reason, String link) {
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER || FabricLoader.getInstance().isDevelopmentEnvironment())
throw new RuntimeException(reason + " " + link);
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
index 08132ae85..03ef2daa6 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
@@ -401,7 +401,9 @@ public class ContainerScreenOverlay extends WidgetWithBounds implements REIOverl
VillagerRecipeViewingScreen widget = (VillagerRecipeViewingScreen) Minecraft.getInstance().screen;
return new Rectangle(widget.bounds.x, 3, widget.bounds.width, 18);
}
- return new Rectangle(REIHelper.getInstance().getPreviousContainerScreen().leftPos, 3, REIHelper.getInstance().getPreviousContainerScreen().imageWidth, 18);
+ AbstractContainerScreen<?> containerScreen = REIHelper.getInstance().getPreviousContainerScreen();
+ if (containerScreen != null)
+ return new Rectangle(containerScreen.leftPos, 3, containerScreen.imageWidth, 18);
}
return null;
}
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/DelegateScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/DelegateScreen.java
new file mode 100644
index 000000000..92afc1581
--- /dev/null
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/DelegateScreen.java
@@ -0,0 +1,243 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.gui;
+
+import com.mojang.blaze3d.vertex.PoseStack;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.Style;
+import net.minecraft.world.item.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.Nullable;
+
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Optional;
+
+@ApiStatus.Internal
+@ApiStatus.Experimental
+public class DelegateScreen extends Screen {
+ protected Screen parent;
+
+ public DelegateScreen(Screen parent) {
+ super(parent.getTitle());
+ this.parent = parent;
+ }
+
+ @Override
+ public Component getTitle() {
+ return parent.getTitle();
+ }
+
+ @Override
+ public String getNarrationMessage() {
+ return parent.getNarrationMessage();
+ }
+
+ @Override
+ public boolean keyPressed(int i, int j, int k) {
+ return parent.keyPressed(i, j, k);
+ }
+
+ @Override
+ public boolean shouldCloseOnEsc() {
+ return parent.shouldCloseOnEsc();
+ }
+
+ @Override
+ public void onClose() {
+ parent.onClose();
+ }
+
+ @Override
+ public <T extends AbstractWidget> T addButton(T abstractWidget) {
+ return parent.addButton(abstractWidget);
+ }
+
+ @Override
+ public <T extends GuiEventListener> T addWidget(T guiEventListener) {
+ return parent.addWidget(guiEventListener);
+ }
+
+ @Override
+ public List<Component> getTooltipFromItem(ItemStack itemStack) {
+ return parent.getTooltipFromItem(itemStack);
+ }
+
+ @Override
+ public void insertText(String string, boolean bl) {
+ parent.insertText(string, bl);
+ }
+
+ @Override
+ public boolean handleComponentClicked(@Nullable Style style) {
+ return parent.handleComponentClicked(style);
+ }
+
+ @Override
+ public void sendMessage(String string) {
+ parent.sendMessage(string);
+ }
+
+ @Override
+ public void sendMessage(String string, boolean bl) {
+ parent.sendMessage(string, bl);
+ }
+
+ @Override
+ public List<? extends GuiEventListener> children() {
+ return parent.children();
+ }
+
+ @Override
+ public void tick() {
+ parent.tick();
+ }
+
+ @Override
+ public void removed() {
+ parent.removed();
+ }
+
+ @Override
+ public boolean isPauseScreen() {
+ return parent.isPauseScreen();
+ }
+
+ @Override
+ public boolean isValidCharacterForName(String string, char c, int i) {
+ return parent.isValidCharacterForName(string, c, i);
+ }
+
+ @Override
+ public boolean isMouseOver(double d, double e) {
+ return parent.isMouseOver(d, e);
+ }
+
+ @Override
+ public void onFilesDrop(List<Path> list) {
+ parent.onFilesDrop(list);
+ }
+
+ @Nullable
+ @Override
+ public GuiEventListener getFocused() {
+ return parent.getFocused();
+ }
+
+ @Override
+ public void setFocused(@Nullable GuiEventListener guiEventListener) {
+ parent.setFocused(guiEventListener);
+ }
+
+ @Override
+ public int getBlitOffset() {
+ return parent.getBlitOffset();
+ }
+
+ @Override
+ public void setBlitOffset(int i) {
+ parent.setBlitOffset(i);
+ }
+
+ @Override
+ public boolean mouseClicked(double d, double e, int i) {
+ return parent.mouseClicked(d, e, i);
+ }
+
+ @Override
+ public boolean mouseReleased(double d, double e, int i) {
+ return parent.mouseReleased(d, e, i);
+ }
+
+ @Override
+ public boolean mouseDragged(double d, double e, int i, double f, double g) {
+ return parent.mouseDragged(d, e, i, f, g);
+ }
+
+ @Override
+ public boolean mouseScrolled(double d, double e, double f) {
+ return parent.mouseScrolled(d, e, f);
+ }
+
+ @Override
+ public boolean keyReleased(int i, int j, int k) {
+ return parent.keyReleased(i, j, k);
+ }
+
+ @Override
+ public boolean charTyped(char c, int i) {
+ return parent.charTyped(c, i);
+ }
+
+ @Override
+ public void setInitialFocus(@Nullable GuiEventListener guiEventListener) {
+ parent.setInitialFocus(guiEventListener);
+ }
+
+ @Override
+ public void magicalSpecialHackyFocus(@Nullable GuiEventListener guiEventListener) {
+ parent.magicalSpecialHackyFocus(guiEventListener);
+ }
+
+ @Override
+ public boolean changeFocus(boolean bl) {
+ return parent.changeFocus(bl);
+ }
+
+ @Override
+ public void mouseMoved(double d, double e) {
+ parent.mouseMoved(d, e);
+ }
+
+ @Override
+ public void resize(Minecraft minecraft, int i, int j) {
+ parent.resize(minecraft, i, j);
+ }
+
+ @Override
+ public void init(Minecraft minecraft, int i, int j) {
+ parent.init(minecraft, i, j);
+ }
+
+ @Override
+ public void init() {
+ parent.init();
+ }
+
+ @Override
+ public Optional<GuiEventListener> getChildAt(double d, double e) {
+ return parent.getChildAt(d, e);
+ }
+
+ @Override
+ public void render(PoseStack poseStack, int i, int j, float f) {
+ parent.render(poseStack, i, j, f);
+ }
+
+
+}
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java
new file mode 100644
index 000000000..5610656de
--- /dev/null
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java
@@ -0,0 +1,73 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.gui;
+
+import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.clothconfig2.api.ScissorsScreen;
+import me.shedaniel.math.Rectangle;
+import net.minecraft.client.gui.screens.Screen;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.function.DoubleSupplier;
+
+public class TransformingScreen extends DelegateScreen implements ScissorsScreen {
+ private final DoubleSupplier xTransformer;
+ private final DoubleSupplier yTransformer;
+ private final Screen lastScreen;
+
+ public TransformingScreen(Screen parent, Screen lastScreen, Runnable init, DoubleSupplier xTransformer, DoubleSupplier yTransformer) {
+ super(parent);
+ this.lastScreen = lastScreen;
+ this.xTransformer = xTransformer;
+ this.yTransformer = yTransformer;
+ init.run();
+ }
+
+ @Override
+ public void init() {
+ super.init();
+ }
+
+ @Override
+ public void render(PoseStack poseStack, int i, int j, float f) {
+ if (lastScreen != null) {
+ RenderSystem.pushMatrix();
+ RenderSystem.translated(0, 0, -400);
+ lastScreen.render(poseStack, -1, -1, 0);
+ RenderSystem.popMatrix();
+ }
+ RenderSystem.pushMatrix();
+ RenderSystem.translated(xTransformer.getAsDouble(), yTransformer.getAsDouble(), 0);
+ super.render(poseStack, i, j, f);
+ RenderSystem.popMatrix();
+ }
+
+ @Override
+ public @Nullable Rectangle handleScissor(@Nullable Rectangle rectangle) {
+ if (rectangle != null)
+ rectangle.translate((int) xTransformer.getAsDouble(), (int) yTransformer.getAsDouble());
+ return rectangle;
+ }
+}
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringAddRuleScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringAddRuleScreen.java
index 951b96003..44781b6ea 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringAddRuleScreen.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringAddRuleScreen.java
@@ -54,7 +54,7 @@ public class FilteringAddRuleScreen extends Screen {
}
@Override
- protected void init() {
+ public void init() {
super.init();
{
Component backText = new TextComponent("↩ ").append(new TranslatableComponent("gui.back"));
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRuleOptionsScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRuleOptionsScreen.java
index 443618d05..a30664901 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRuleOptionsScreen.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRuleOptionsScreen.java
@@ -56,7 +56,7 @@ public abstract class FilteringRuleOptionsScreen<T extends FilteringRule<?>> ext
}
@Override
- protected void init() {
+ public void init() {
super.init();
if (rulesList != null) save();
{
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRulesScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRulesScreen.java
index c2d64e7cc..f8a071c5a 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRulesScreen.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringRulesScreen.java
@@ -58,7 +58,7 @@ public class FilteringRulesScreen extends Screen {
}
@Override
- protected void init() {
+ public void init() {
super.init();
{
Component backText = new TextComponent("↩ ").append(new TranslatableComponent("gui.back"));
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java
index f0ba31ad2..49ac034e6 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/config/entry/FilteringScreen.java
@@ -172,7 +172,7 @@ public class FilteringScreen extends Screen {
}
@Override
- protected void init() {
+ public void init() {
super.init();
Rectangle bounds = getBounds();
updateSearch(this.searchField.getText());
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java
index 862439d65..70afd0c17 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java
@@ -141,6 +141,13 @@ public class EntryListWidget extends WidgetWithBounds {
}
private static Rectangle updateInnerBounds(Rectangle bounds) {
+ bounds = bounds.clone();
+ int widthReduction = (int) Math.round(bounds.width * (1 - ConfigObject.getInstance().ge