aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-02-09 20:17:34 +0800
committershedaniel <daniel@shedaniel.me>2022-02-09 20:17:34 +0800
commitcaa850ff55576c8aef92c28ab5dcf87a319f6e3a (patch)
tree4fbb17d0d7ee6c3d523ff5839288315e483accea
parent48ef9ff7f4b1be74006837b51a683d5e8b9bdc52 (diff)
downloadRoughlyEnoughItems-caa850ff55576c8aef92c28ab5dcf87a319f6e3a.tar.gz
RoughlyEnoughItems-caa850ff55576c8aef92c28ab5dcf87a319f6e3a.tar.bz2
RoughlyEnoughItems-caa850ff55576c8aef92c28ab5dcf87a319f6e3a.zip
Migrate to Cloth Config's ValueAnimator, and add option to cache entry renders
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java4
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConstantValueProvider.java53
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConventionValueAnimator.java67
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/DoubleValueAnimatorImpl.java109
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingProgressValueAnimator.java68
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingValueAnimator.java62
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimator.java116
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimatorWrapped.java80
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ProgressValueAnimator.java46
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimator.java155
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimatorArgs.java1487
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ValueAnimator.java192
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ValueAnimatorAsNumberAnimator.java70
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ValueProvider.java73
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java3
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java4
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconBaseCategory.java4
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/beacon/DefaultBeaconPaymentCategory.java4
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java12
-rw-r--r--fabric/src/main/resources/fabric.mod.json3
-rw-r--r--gradle.properties2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/REIRuntimeImpl.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java11
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/FilteringScreen.java28
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/dragging/CurrentDraggingStack.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/Menu.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EntryStackSubsetsMenuEntry.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java5
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/BatchedEntryRendererManager.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java176
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java65
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryStacksRegionWidget.java26
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java18
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabWidget.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ArrowWidget.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/BurningFireWidget.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/ButtonWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/LabelWidget.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/PanelWidget.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/region/RealRegionEntry.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java11
-rwxr-xr-xruntime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json3
48 files changed, 334 insertions, 2686 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java
index aa90567ae..b9bafaa0c 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java
@@ -113,6 +113,8 @@ public interface ConfigObject {
boolean doesFastEntryRendering();
+ boolean doesCacheEntryRendering();
+
boolean doDebugRenderTimeRequired();
boolean doMergeDisplayUnderOne();
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java
index 62c89edd2..858d43aa5 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/CompoundFavoriteRenderer.java
@@ -26,11 +26,11 @@ package me.shedaniel.rei.api.client.favorites;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector4f;
import me.shedaniel.clothconfig2.api.ScissorsHandler;
+import me.shedaniel.clothconfig2.api.animator.NumberAnimator;
+import me.shedaniel.clothconfig2.api.animator.ValueAnimator;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.AbstractRenderer;
import me.shedaniel.rei.api.client.gui.Renderer;
-import me.shedaniel.rei.api.client.gui.animator.NumberAnimator;
-import me.shedaniel.rei.api.client.gui.animator.ValueAnimator;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.Util;
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConstantValueProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConstantValueProvider.java
deleted file mode 100644
index e0f19d469..000000000
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConstantValueProvider.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.api.client.gui.animator;
-
-import org.jetbrains.annotations.ApiStatus;
-
-@ApiStatus.Internal
-final class ConstantValueProvider<T> implements ValueProvider<T> {
- private final T value;
-
- public ConstantValueProvider(T value) {
- this.value = value;
- }
-
- @Override
- public T value() {
- return value;
- }
-
- @Override
- public T target() {
- return value;
- }
-
- @Override
- public void completeImmediately() {
- }
-
- @Override
- public void update(double delta) {
- }
-}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConventionValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConventionValueAnimator.java
deleted file mode 100644
index 771fe6489..000000000
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ConventionValueAnimator.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.api.client.gui.animator;
-
-import org.jetbrains.annotations.ApiStatus;
-
-import java.util.Objects;
-import java.util.function.Supplier;
-
-@ApiStatus.Internal
-final class ConventionValueAnimator<T> implements ValueAnimator<T> {
- private final ValueAnimator<T> parent;
- private final Supplier<T> convention;
- private final long duration;
-
- ConventionValueAnimator(ValueAnimator<T> parent, Supplier<T> convention, long duration) {
- this.parent = parent;
- this.convention = convention;
- this.duration = duration;
- setAs(convention.get());
- }
-
- @Override
- public ValueAnimator<T> setTo(T value, long duration) {
- return parent.setTo(value, duration);
- }
-
- @Override
- public T target() {
- return convention.get();
- }
-
- @Override
- public T value() {
- return parent.value();
- }
-
- @Override
- public void update(double delta) {
- parent.update(delta);
- T target = target();
- if (!Objects.equals(parent.target(), target)) {
- setTo(target, duration);
- }
- }
-}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/DoubleValueAnimatorImpl.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/DoubleValueAnimatorImpl.java
deleted file mode 100644
index 23784720a..000000000
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/DoubleValueAnimatorImpl.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.api.client.gui.animator;
-
-import me.shedaniel.clothconfig2.impl.EasingMethod;
-import net.minecraft.Util;
-import org.jetbrains.annotations.ApiStatus;
-
-@ApiStatus.Internal
-final class DoubleValueAnimatorImpl extends NumberAnimator<Double> {
- private double amount;
- private double target;
- private long start;
- private long duration;
-
- DoubleValueAnimatorImpl() {
- }
-
- DoubleValueAnimatorImpl(double amount) {
- setAs(amount);
- }
-
- @Override
- public NumberAnimator<Double> setToNumber(Number value, long duration) {
- double doubleValue = value.doubleValue();
- if (target != doubleValue) {
- this.set(doubleValue, duration);
- }
-
- return this;
- }
-
- private void set(double value, long duration) {
- this.target = value;
- this.start = Util.getMillis();
-
- if (duration > 0) {
- this.duration = duration;
- } else {
- this.duration = 0;
- this.amount = this.target;
- }
- }
-
- @Override
- public void update(double delta) {
- if (duration != 0) {
- if (amount < target) {
- this.amount = Math.min(ease(amount, target + (target - amount), Math.min(((double) Util.getMillis() - start) / duration * delta * 3.0D, 1.0D), EasingMethod.EasingMethodImpl.LINEAR), target);
- } else if (amount > target) {
- this.amount = Math.max(ease(amount, target - (amount - target), Math.min(((double) Util.getMillis() - start) / duration * delta * 3.0D, 1.0D), EasingMethod.EasingMethodImpl.LINEAR), target);
- }
- }
- }
-
- private static double ease(double start, double end, double amount, EasingMethod easingMethod) {
- return start + (end - start) * easingMethod.apply(amount);
- }
-
- @Override
- public int intValue() {
- return (int) amount;
- }
-
- @Override
- public long longValue() {
- return (long) amount;
- }
-
- @Override
- public float floatValue() {
- return (float) amount;
- }
-
- @Override
- public double doubleValue() {
- return amount;
- }
-
- public Double target() {
- return target;
- }
-
- @Override
- public Double value() {
- return amount;
- }
-}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingProgressValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingProgressValueAnimator.java
deleted file mode 100644
index 513e77270..000000000
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingProgressValueAnimator.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.api.client.gui.animator;
-
-import org.jetbrains.annotations.ApiStatus;
-
-import java.util.function.Function;
-
-@ApiStatus.Internal
-final class MappingProgressValueAnimator<R> implements ProgressValueAnimator<R> {
- private final ValueAnimator<Double> parent;
- private final Function<Double, R> converter;
- private final Function<R, Double> backwardsConverter;
-
- MappingProgressValueAnimator(ValueAnimator<Double> parent, Function<Double, R> converter, Function<R, Double> backwardsConverter) {
- this.parent = parent;
- this.converter = converter;
- this.backwardsConverter = backwardsConverter;
- }
-
- @Override
- public ProgressValueAnimator<R> setTo(R value, long duration) {
- parent.setTo(backwardsConverter.apply(value), duration);
- return this;
- }
-
- @Override
- public R target() {
- return converter.apply(parent.target());
- }
-
- @Override
- public R value() {
- return converter.apply(parent.value());
- }
-
- @Override
- public void update(double delta) {
- parent.update(delta);
- }
-
-
- @Override
- public double progress() {
- return parent.value() / 100;
- }
-}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingValueAnimator.java
deleted file mode 100644
index aea3cc751..000000000
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/MappingValueAnimator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.api.client.gui.animator;
-
-import org.jetbrains.annotations.ApiStatus;
-
-import java.util.function.Function;
-
-@ApiStatus.Internal
-final class MappingValueAnimator<T, R> implements ValueAnimator<R> {
- private final ValueAnimator<T> parent;
- private final Function<T, R> converter;
- private final Function<R, T> backwardsConverter;
-
- MappingValueAnimator(ValueAnimator<T> parent, Function<T, R> converter, Function<R, T> backwardsConverter) {
- this.parent = parent;
- this.converter = converter;
- this.backwardsConverter = backwardsConverter;
- }
-
- @Override
- public ValueAnimator<R> setTo(R value, long duration) {
- parent.setTo(backwardsConverter.apply(value), duration);
- return this;
- }
-
- @Override
- public R target() {
- return converter.apply(parent.target());
- }
-
- @Override
- public R value() {
- return converter.apply(parent.value());
- }
-
- @Override
- public void update(double delta) {
- parent.update(delta);
- }
-}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimator.java
deleted file mode 100644
index 1c06e34a2..000000000
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimator.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.api.client.gui.animator;
-
-import org.jetbrains.annotations.ApiStatus;
-
-import java.util.function.Supplier;
-
-@ApiStatus.Experimental
-public abstract class NumberAnimator<T extends Number> extends Number implements ValueAnimator<T> {
- public NumberAnimator<Double> asDouble() {
- return new NumberAnimatorWrapped<>(this, Number::doubleValue);
- }
-
- public NumberAnimator<Float> asFloat() {
- return new NumberAnimatorWrapped<>(this, Number::floatValue);
- }
-
- public NumberAnimator<Integer> asInt() {
- return new NumberAnimatorWrapped<>(this, d -> (int) Math.round(d.doubleValue()));
- }
-
- public NumberAnimator<Long> asLong() {
- return new NumberAnimatorWrapped<>(this, d -> Math.round(d.doubleValue()));
- }
-
- @Override
- public NumberAnimator<T> setAs(T value) {
- ValueAnimator.super.setAs(value);
- return this;
- }
-
- public NumberAnimator<T> setAs(int value) {
- setAsNumber(value);
- return this;
- }
-
- public NumberAnimator<T> setAs(long value) {
-