diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-02-23 14:46:06 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-02-23 14:46:06 +0800 |
| commit | ac2a724b0575438357810fdc71b4c2fa6590665c (patch) | |
| tree | eec15bf1eaad9918e2d3ae4d22918a5a7e50b455 /api/src/main/java/me/shedaniel | |
| parent | 792d6ee9325b0a14796de51e31c9f51876fcdf8f (diff) | |
| parent | a2309c47c447d217346147af5823e991feaf9dcd (diff) | |
| download | RoughlyEnoughItems-ac2a724b0575438357810fdc71b4c2fa6590665c.tar.gz RoughlyEnoughItems-ac2a724b0575438357810fdc71b4c2fa6590665c.tar.bz2 RoughlyEnoughItems-ac2a724b0575438357810fdc71b4c2fa6590665c.zip | |
Merge remote-tracking branch 'origin/7.x-1.18' into 7.x-1.18.2
# Conflicts:
# gradle.properties
# runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
Diffstat (limited to 'api/src/main/java/me/shedaniel')
20 files changed, 76 insertions, 2530 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..dfd8f08f6 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 @@ -50,6 +50,9 @@ public interface ConfigObject { void setCheating(boolean cheating); + @ApiStatus.Experimental + CheatingMode getCheatingMode(); + EntryPanelOrdering getItemListOrdering(); boolean isItemListAscending(); @@ -86,6 +89,8 @@ public interface ConfigObject { String getWeatherCommand(); + String getTimeCommand(); + int getMaxRecipePerPage(); int getMaxRecipesPageHeight(); @@ -113,10 +118,14 @@ public interface ConfigObject { boolean doesFastEntryRendering(); + boolean doesCacheEntryRendering(); + boolean doDebugRenderTimeRequired(); boolean doMergeDisplayUnderOne(); + FavoriteAddWidgetMode getFavoriteAddWidgetMode(); + ModifierKeyCode getFavoriteKeyCode(); ModifierKeyCode getRecipeKeybind(); @@ -188,6 +197,9 @@ public interface ConfigObject { @ApiStatus.Experimental SyntaxHighlightingMode getSyntaxHighlightingMode(); + @ApiStatus.Experimental + boolean isFocusModeZoomed(); + SearchMode getTooltipSearchMode(); SearchMode getTagSearchMode(); 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/SimpleDisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java index fe116e744..b0ce0e735 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java @@ -127,6 +127,7 @@ public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHold outputWidget.setZ(getZ() + 50); outputWidget.getBounds().setLocation(xx, yy); outputWidget.render(matrices, mouseX, mouseY, delta); + yy += 18; } } @@ -146,7 +147,7 @@ public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHold @Override public int getHeight() { - return 4 + getItemsHeight() * 18; + return Math.max(4 + getItemsHeight() * 18, 4 + outputWidgets.size() * 18); } public int getItemsHeight() { 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/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); - } - - public interface Arg<T> { - List<ValueAnimator<?>> dependencies(); - - void set(T value, long duration); - - T target(); - - T value(); - } - - public static <A1, T> RecordValueAnimator<T, RecordValueAnimatorArgs.Arg1<A1, T>> of(ValueAnimator<A1> a1, RecordValueAnimatorArgs.Arg1.Op<A1, T> op, RecordValueAnimatorArgs.Arg1.Up<A1, T> up) { - return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg1<>(a1, op, up)); - } - - public static <A1, A2, T> RecordValueAnimator<T, RecordValueAnimatorArgs.Arg2<A1, A2, T>> of(ValueAnimator<A1> a1, ValueAnimator<A2> a2, RecordValueAnimatorArgs.Arg2.Op<A1, A2, T> op, RecordValueAnimatorArgs.Arg2.Up<A1, A2, T> up) { - return new RecordValueAnimator<>(new RecordValueAnimatorArgs.Arg2<>(a1, a2, op, up)); - } |
