diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-02-09 20:17:34 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-02-18 11:29:59 +0800 |
| commit | 07cf05103e82b6edd25b4c401808f3be2a0294fd (patch) | |
| tree | 494b3019349137a277d37905e7f1b7e69caa887c /api/src/main/java | |
| parent | 2a6c99e0e489cd7c63f4c3dabed83b8b3f910c89 (diff) | |
| download | RoughlyEnoughItems-07cf05103e82b6edd25b4c401808f3be2a0294fd.tar.gz RoughlyEnoughItems-07cf05103e82b6edd25b4c401808f3be2a0294fd.tar.bz2 RoughlyEnoughItems-07cf05103e82b6edd25b4c401808f3be2a0294fd.zip | |
Migrate to Cloth Config's ValueAnimator, and add option to cache entry renders
Diffstat (limited to 'api/src/main/java')
16 files changed, 7 insertions, 2580 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 bd6e5b547..6c54579f8 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 @@ -112,6 +112,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) { - setAsNumber(value); - return this; - } - - public NumberAnimator<T> setAs(float value) { - setAsNumber(value); - return this; - } - - public NumberAnimator<T> setAs(double value) { - setAsNumber(value); - return this; - } - - @Override - public NumberAnimator<T> setTo(T value, long duration) { - setToNumber(value, duration); - return this; - } - - public NumberAnimator<T> setTo(int value, long duration) { - setToNumber(value, duration); - return this; - } - - public NumberAnimator<T> setTo(long value, long duration) { - setToNumber(value, duration); - return this; - } - - public NumberAnimator<T> setTo(float value, long duration) { - setToNumber(value, duration); - return this; - } - - public NumberAnimator<T> setTo(double value, long duration) { - setToNumber(value, duration); - return this; - } - - public NumberAnimator<T> setAsNumber(Number value) { - return setToNumber(value, -1); - } - - public abstract NumberAnimator<T> setToNumber(Number value, long duration); - - @Override - public NumberAnimator<T> withConvention(Supplier<T> convention, long duration) { - ValueAnimator<T> parentConvention = ValueAnimator.super.withConvention(convention, duration); - return new ValueAnimatorAsNumberAnimator<T>(parentConvention) { - @Override - public NumberAnimator<T> setToNumber(Number value, long duration) { - return NumberAnimator.this.setToNumber(value, duration); - } - }; - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimatorWrapped.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimatorWrapped.java deleted file mode 100644 index 72219dfc7..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/NumberAnimatorWrapped.java +++ /dev/null @@ -1,80 +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 NumberAnimatorWrapped<T extends Number, R extends Number> extends NumberAnimator<T> { - private final NumberAnimator<R> parent; - private final Function<R, T> converter; - - NumberAnimatorWrapped(NumberAnimator<R> parent, Function<R, T> converter) { - this.parent = parent; - this.converter = converter; - } - - @Override - public NumberAnimator<T> setToNumber(Number value, long duration) { - this.parent.setToNumber(value, duration); - return this; - } - - @Override - public T target() { - return converter.apply(parent.target()); - } - - @Override - public T value() { - return converter.apply(parent.value()); - } - - @Override - public void update(double delta) { - parent.update(delta); - } - - @Override - public int intValue() { - return parent.intValue(); - } - - @Override - public long longValue() { - return parent.longValue(); - } - - @Override - public float floatValue() { - return parent.floatValue(); - } - - @Override - public double doubleValue() { - return parent.doubleValue(); - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ProgressValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ProgressValueAnimator.java deleted file mode 100644 index de5607223..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/ProgressValueAnimator.java +++ /dev/null @@ -1,46 +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.Experimental -public interface ProgressValueAnimator<T> extends ValueAnimator<T> { - double progress(); - - @Override - default ProgressValueAnimator<T> setAs(T value) { - ValueAnimator.super.setAs(value); - return this; - } - - @Override - ProgressValueAnimator<T> setTo(T value, long duration); - - static <R> ProgressValueAnimator<R> mapProgress(NumberAnimator<?> parent, Function<Double, R> converter, Function<R, Double> backwardsConverter) { - return new MappingProgressValueAnimator<>(parent.asDouble(), converter, backwardsConverter); - } -} diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimator.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimator.java deleted file mode 100644 index 353ba7257..000000000 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/animator/RecordValueAnimator.java +++ /dev/null @@ -1,155 +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.List; - -@ApiStatus.Internal -final class RecordValueAnimator<T, A extends RecordValueAnimator.Arg<T>> implements ValueAnimator<T> { - private final A arg; - - RecordValueAnimator(A arg) { - this.arg = arg; - } - - @Override - public ValueAnimator<T> setTo(T value, long duration) { - arg.set(value, duration); - return this; - } - - @Override - public T target() { - return arg.target(); - } - - @Override - public T value() { - return arg.value(); - } - - @Override - public void update(double delta) { - for (ValueAnimator<?> dependency : arg.dependencies()) { - dependency.update(delta); - } - } - - @FunctionalInterface - public interface Setter<T> { - void set(T value); |
