aboutsummaryrefslogtreecommitdiff
path: root/RoughlyEnoughItems-runtime/src/main/java
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 /RoughlyEnoughItems-runtime/src/main/java
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>
Diffstat (limited to 'RoughlyEnoughItems-runtime/src/main/java')
-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
17 files changed, 399 insertions, 27 deletions
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().getHorizontalEntriesBoundaries()));
+ int heightReduction = (int) Math.round(bounds.width * (1 - ConfigObject.getInstance().getVerticalEntriesBoundaries()));
+ bounds.x += widthReduction;
+ bounds.width -= widthReduction;
+ bounds.y += heightReduction / 2;
+ bounds.height -= heightReduction;
int entrySize = entrySize();
if (ConfigObject.getInstance().isEntryListWidgetScrolled()) {
int width = Math.max(Mth.floor((bounds.width - 2 - 6) / (float) entrySize), 1);
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java
index 75ad6c718..6d30c4cef 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java
@@ -190,8 +190,14 @@ public class FavoritesListWidget extends WidgetWithBounds {
@Override
public boolean mouseDragged(double mouseX, double mouseY, int int_1, double double_3, double double_4) {
- if (lastTouchedEntry != null) {
- lastTouchedEntry.dragged = true;
+ if (lastTouchedEntry != null && !lastTouchedEntry.dragged) {
+ Point startPoint = lastTouchedEntry.startedDraggingPosition;
+ double xDistance = Math.abs(startPoint.x - mouseX);
+ double yDistance = Math.abs(startPoint.y - mouseY);
+ double requiredDistance = entrySize() * .4;
+ if (xDistance * xDistance + yDistance * yDistance > requiredDistance * requiredDistance) {
+ lastTouchedEntry.dragged = true;
+ }
}
if (scrolling.mouseDragged(mouseX, mouseY, int_1, double_3, double_4, ConfigObject.getInstance().doesSnapToRows(), entrySize()))
return true;
@@ -381,6 +387,7 @@ public class FavoritesListWidget extends WidgetWithBounds {
Entry entry = lastTouchedEntry;
double x = entry.x.doubleValue();
double y = entry.y.doubleValue();
+ entry.startedDraggingPosition = null;
boolean contains = currentBounds.contains(PointHelper.ofMouse());
if (contains || !entry.madeUp) {
@@ -441,6 +448,7 @@ public class FavoritesListWidget extends WidgetWithBounds {
for (Entry entry : entries.values()) {
if (entry.getWidget().containsMouse(mouseX, mouseY)) {
lastTouchedEntry = entry;
+ lastTouchedEntry.startedDraggingPosition = new Point(mouseX, mouseY);
break;
}
}
@@ -492,6 +500,7 @@ public class FavoritesListWidget extends WidgetWithBounds {
private FavoriteEntry entry;
private final EntryListEntry widget;
private boolean hidden;
+ private Point startedDraggingPosition;
private boolean dragged;
private boolean madeUp;
private Animator x = new Animator();
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java
index 0e3bb662e..a38da1d4a 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java
@@ -46,6 +46,7 @@ import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
import me.shedaniel.clothconfig2.api.Modifier;
import me.shedaniel.clothconfig2.api.ModifierKeyCode;
import me.shedaniel.clothconfig2.gui.entries.KeyCodeEntry;
+import me.shedaniel.clothconfig2.impl.EasingMethod;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.ConfigManager;
import me.shedaniel.rei.api.EntryRegistry;
@@ -53,6 +54,7 @@ import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.REIHelper;
import me.shedaniel.rei.api.favorites.FavoriteEntry;
import me.shedaniel.rei.gui.ContainerScreenOverlay;
+import me.shedaniel.rei.gui.TransformingScreen;
import me.shedaniel.rei.gui.WarningAndErrorScreen;
import me.shedaniel.rei.gui.config.RecipeScreenType;
import me.shedaniel.rei.gui.config.entry.FilteringEntry;
@@ -65,6 +67,7 @@ import me.shedaniel.rei.impl.filtering.rules.ManualFilteringRule;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
+import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.Button;
@@ -79,6 +82,7 @@ import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.Mth;
import net.minecraft.util.Tuple;
+import org.apache.commons.lang3.mutable.MutableLong;
import org.jetbrains.annotations.ApiStatus;
import java.lang.reflect.Method;
@@ -158,7 +162,7 @@ public class ConfigManagerImpl implements ConfigManager {
ConfigObjectImpl.UsePercentage bounds = field.getAnnotation(ConfigObjectImpl.UsePercentage.class);
return Collections.singletonList(ConfigEntryBuilder.create().startIntSlider(new TranslatableComponent(i13n), Mth.ceil(Utils.getUnsafely(field, config, 0.0) * 100), Mth.ceil(bounds.min() * 100), Mth.ceil(bounds.max() * 100)).setDefaultValue(() -> Mth.ceil((double) Utils.getUnsafely(field, defaults) * 100)).setSaveConsumer((newValue) -> {
Utils.setUnsafely(field, config, newValue / 100d);
- }).setTextGetter(integer -> new TextComponent(String.format("Size: %d%%", integer))).build());
+ }).setTextGetter(integer -> new TextComponent(bounds.prefix() + String.format("%d%%", integer))).build());
}, (field) -> field.getType() == Double.TYPE || field.getType() == Double.class, ConfigObjectImpl.UsePercentage.class);
guiRegistry.registerAnnotationProvider((i13n, field, config, defaults, guiProvider) ->
@@ -223,7 +227,7 @@ public class ConfigManagerImpl implements ConfigManager {
provider.setCategoryFunction((baseI13n, categoryName) -> String.format("%s.%s", baseI13n, categoryName));
provider.setBuildFunction(builder -> {
builder.setGlobalized(true);
- builder.setGlobalizedExpanded(true);
+ builder.setGlobalizedExpanded(false);
if (Minecraft.getInstance().getConnection() != null && Minecraft.getInstance().getConnection().getRecipeManager() != null) {
builder.getOrCreateCategory(new TranslatableComponent("config.roughlyenoughitems.advanced")).getEntries().add(0, new ReloadPluginsEntry(220));
}
@@ -238,7 +242,12 @@ public class ConfigManagerImpl implements ConfigManager {
ContainerScreenOverlay.getEntryListWidget().updateSearch(ScreenHelper.getSearchField().getText(), true);
}).build();
});
- return provider.get();
+ MutableLong current = new MutableLong();
+ return new TransformingScreen(provider.get(),
+ parent,
+ () -> current.setValue(Util.getMillis() + (getConfig().isReducedMotion() ? -3000 : 0)),
+ () -> 0, () -> (1 - EasingMethod.EasingMethodImpl.EXPO.apply(Mth.clamp((Util.getMillis() - current.getValue()) / 750.0, 0, 1)))
+ * Minecraft.getInstance().getWindow().getGuiScaledHeight() * 1.3);
} catch (Exception e) {
e.printStackTrace();
}
@@ -266,7 +275,7 @@ public class ConfigManagerImpl implements ConfigManager {
}
@Override
- protected void init() {
+ public void init() {
super.init();
this.addButton(new Button(this.width / 2 - 100, 140, 200, 20, CommonComponents.GUI_CANCEL, button -> this.minecraft.setScreen(parent)));
}
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
index cc59a0559..1bea42943 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java