Browse Source

Make config screen animations more bearable, fix work station recipes ignoring the visibility handlers.

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel 4 years ago
parent
commit
277b7f9768

+ 8 - 0
RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/TransformingScreen.java

@@ -46,6 +46,7 @@ public class TransformingScreen extends DelegateScreen implements ScissorsScreen
     private Runnable init;
     private boolean renderingLastScreen = false;
     private boolean translatingLast;
+    private boolean initAfter = false;
     
     public TransformingScreen(boolean translatingLast, Screen parent, Screen lastScreen, Runnable init, DoubleSupplier xTransformer, DoubleSupplier yTransformer, BooleanSupplier finished) {
         super(Minecraft.getInstance().level == null && parent == null ? new TitleScreen() : parent);
@@ -57,6 +58,10 @@ public class TransformingScreen extends DelegateScreen implements ScissorsScreen
         this.finished = finished;
     }
     
+    public void setInitAfter(boolean initAfter) {
+        this.initAfter = initAfter;
+    }
+    
     public void setParentScreen(Screen parent) {
         this.parent = parent;
     }
@@ -129,6 +134,9 @@ public class TransformingScreen extends DelegateScreen implements ScissorsScreen
             Minecraft.getInstance().screen = parent;
             if (parent != null) {
                 Minecraft.getInstance().noRender = false;
+                if (initAfter) {
+                    parent.init(Minecraft.getInstance(), Minecraft.getInstance().getWindow().getGuiScaledWidth(), Minecraft.getInstance().getWindow().getGuiScaledHeight());
+                }
             }
         } else {
             super.tick();

+ 2 - 2
RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java

@@ -368,10 +368,10 @@ public class EntryWidget extends Slot {
     public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
         if (ScreenHelper.isWithinRecipeViewingScreen && entryStacks.size() > 1 && containsMouse(mouseX, mouseY)) {
             if (amount < 0) {
-                EntryWidget.stackDisplayOffset += 500;
+                EntryWidget.stackDisplayOffset = ((System.currentTimeMillis() + stackDisplayOffset) / 1000 - 1) * 1000;
                 return true;
             } else if (amount > 0) {
-                EntryWidget.stackDisplayOffset -= 500;
+                EntryWidget.stackDisplayOffset = ((System.currentTimeMillis() + stackDisplayOffset) / 1000 + 1) * 1000;
                 return true;
             }
         }

+ 2 - 1
RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java

@@ -235,11 +235,12 @@ public class ConfigManagerImpl implements ConfigManager {
             TransformingScreen parentTranslated;
             {
                 MutableLong current = new MutableLong(0);
-                parentTranslated = new TransformingScreen(true, null,
+                parentTranslated = new TransformingScreen(true, parent,
                         null,
                         () -> current.setValue(current.getValue() == 0 ? Util.getMillis() + (getConfig().isReducedMotion() ? -3000 : 0) : current.getValue()),
                         () -> 0, () -> (EasingMethod.EasingMethodImpl.EXPO.apply(Mth.clamp((Util.getMillis() - current.getValue()) / 750.0, 0, 1)))
                                        * Minecraft.getInstance().getWindow().getGuiScaledHeight(), () -> Util.getMillis() - current.getValue() > 800);
+                parentTranslated.setInitAfter(true);
             }
             ConfigScreenProvider<ConfigObjectImpl> provider = (ConfigScreenProvider<ConfigObjectImpl>) AutoConfig.getConfigScreen(ConfigObjectImpl.class, parentTranslated);
             provider.setI13nFunction(manager -> "config.roughlyenoughitems");

+ 1 - 1
RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java

@@ -205,7 +205,7 @@ public class RecipeHelperImpl implements RecipeHelper {
             }
             for (EntryStack stack : usagesFor) {
                 if (isStackWorkStationOfCategory(categoryId, stack)) {
-                    set.addAll(allRecipesFromCategory);
+                    set.addAll(CollectionUtils.filter(allRecipesFromCategory, this::isDisplayVisible));
                     break;
                 }
             }

+ 1 - 1
gradle.properties

@@ -1,5 +1,5 @@
 org.gradle.jvmargs=-Xmx3G
-mod_version=5.8.8
+mod_version=5.8.9
 supported_version=1.16.2/3/4
 minecraft_version=1.16.4
 fabricloader_version=0.10.6+build.214