Danielshe 5 лет назад
Родитель
Сommit
89d68f8fb9

+ 1 - 1
gradle.properties

@@ -2,5 +2,5 @@ minecraft_version=19w44a
 yarn_version=19w44a+build.3
 fabric_loader_version=0.6.3+build.168
 fabric_version=0.4.9+build.258-1.15
-mod_version=2.3.2-unstable
+mod_version=2.3.3-unstable
 modmenu_version=1.7.14-unstable.19w42a+build.10

+ 7 - 7
src/main/java/me/shedaniel/clothconfig2/ClothConfigInitializer.java

@@ -31,7 +31,7 @@ public class ClothConfigInitializer implements ClientModInitializer {
     private static EasingMethod easingMethod = EasingMethodImpl.QUART;
     private static long scrollDuration = 1000;
     private static double scrollStep = 16;
-    private static double bounceBackMultiplier = .84;
+    private static double bounceBackMultiplier = .24;
     
     public static EasingMethod getEasingMethod() {
         return easingMethod;
@@ -56,7 +56,7 @@ public class ClothConfigInitializer implements ClientModInitializer {
             easingMethod = EasingMethodImpl.QUART;
             scrollDuration = 1000;
             scrollStep = 16;
-            bounceBackMultiplier = .84;
+            bounceBackMultiplier = .24;
             if (!file.exists()) {
                 saveConfig();
             }
@@ -71,13 +71,13 @@ public class ClothConfigInitializer implements ClientModInitializer {
             }
             scrollDuration = Long.parseLong(properties.getProperty("scrollDuration", "1000"));
             scrollStep = Double.parseDouble(properties.getProperty("scrollStep", "16"));
-            bounceBackMultiplier = Double.parseDouble(properties.getProperty("bounceBackMultiplier1", "0.84"));
+            bounceBackMultiplier = Double.parseDouble(properties.getProperty("bounceBackMultiplier2", "0.24"));
         } catch (Exception e) {
             e.printStackTrace();
             easingMethod = EasingMethodImpl.QUART;
             scrollDuration = 1000;
             scrollStep = 16;
-            bounceBackMultiplier = .84;
+            bounceBackMultiplier = .24;
             try {
                 if (file.exists())
                     file.delete();
@@ -95,7 +95,7 @@ public class ClothConfigInitializer implements ClientModInitializer {
             properties.setProperty("easingMethod", easingMethod.toString());
             properties.setProperty("scrollDuration", scrollDuration + "");
             properties.setProperty("scrollStep", scrollStep + "");
-            properties.setProperty("bounceBackMultiplier1", bounceBackMultiplier + "");
+            properties.setProperty("bounceBackMultiplier2", bounceBackMultiplier + "");
             properties.store(writer, null);
             writer.close();
         } catch (Exception e) {
@@ -103,7 +103,7 @@ public class ClothConfigInitializer implements ClientModInitializer {
             easingMethod = EasingMethodImpl.QUART;
             scrollDuration = 1000;
             scrollStep = 16;
-            bounceBackMultiplier = .84;
+            bounceBackMultiplier = .24;
         }
     }
     
@@ -130,7 +130,7 @@ public class ClothConfigInitializer implements ClientModInitializer {
                             return integer <= 0 ? "Value: Disabled" : (integer > 1500 ? String.format("Value: %.1fs", integer / 1000f) : "Value: " + integer + "ms");
                         }).setDefaultValue(1000).setSaveConsumer(i -> scrollDuration = i).build());
                         scrolling.addEntry(entryBuilder.startDoubleField("Scroll Step", scrollStep).setDefaultValue(16).setSaveConsumer(i -> scrollStep = i).build());
-                        scrolling.addEntry(entryBuilder.startDoubleField("Bounce Multiplier", bounceBackMultiplier).setDefaultValue(0.84).setSaveConsumer(i -> bounceBackMultiplier = i).build());
+                        scrolling.addEntry(entryBuilder.startDoubleField("Bounce Multiplier", bounceBackMultiplier).setDefaultValue(0.24).setSaveConsumer(i -> bounceBackMultiplier = i).build());
                         ConfigCategory testing = builder.getOrCreateCategory("Testing");
                         testing.addEntry(entryBuilder.startDropdownMenu("lol apple", DropdownMenuBuilder.TopCellElementBuilder.ofItemObject(Items.APPLE), DropdownMenuBuilder.CellCreatorBuilder.ofItemObject()).setDefaultValue(Items.APPLE).setSelections(Registry.ITEM.stream().sorted(Comparator.comparing(Item::toString)).collect(Collectors.toSet())).setSaveConsumer(item -> System.out.println("save this " + item)).build());
                         builder.setSavingRunnable(() -> {

+ 5 - 15
src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicNewSmoothScrollingEntryListWidget.java

@@ -19,24 +19,11 @@ public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends Dynamic
     protected boolean smoothScrolling = true;
     protected long start;
     protected long duration;
-    protected RunSixtyTimesEverySec clamper = () -> {
-        target = clamp(target);
-        if (target < 0) {
-            target = target * getBounceBackMultiplier();
-        } else if (target > getMaxScroll()) {
-            target = (target - getMaxScroll()) * getBounceBackMultiplier() + getMaxScroll();
-        } else
-            unregisterClamper();
-    };
     
     public DynamicNewSmoothScrollingEntryListWidget(MinecraftClient client, int width, int height, int top, int bottom, Identifier backgroundLocation) {
         super(client, width, height, top, bottom, backgroundLocation);
     }
     
-    protected void unregisterClamper() {
-        clamper.unregisterTick();
-    }
-    
     public final double clamp(double v) {
         return clamp(v, SmoothScrollingSettings.CLAMP_EXTENSION);
     }
@@ -128,8 +115,11 @@ public abstract class DynamicNewSmoothScrollingEntryListWidget<E extends Dynamic
     
     private void updatePosition(float delta) {
         target = clamp(target);
-        if ((target < 0 || target > getMaxScroll()) && !clamper.isRegistered())
-            clamper.registerTick();
+        if (target < 0) {
+            target -= target * (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3;
+        } else if (target > getMaxScroll()) {
+            target = (target - getMaxScroll()) * (1 - (1 - ClothConfigInitializer.getBounceBackMultiplier()) * delta / 3) + getMaxScroll();
+        }
         if (!Precision.almostEquals(scroll, target, Precision.FLOAT_EPSILON))
             scroll = (float) Interpolation.expoEase(scroll, target, Math.min((System.currentTimeMillis() - start) / ((double) duration), 1));
         else