From 305718e163f91802a4bc1c1ed6540febb2ce204e Mon Sep 17 00:00:00 2001 From: isXander Date: Tue, 11 Jun 2024 23:13:49 +0100 Subject: codec config and rewritten kotlin dsl --- src/main/java/dev/isxander/yacl3/api/Binding.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/main/java/dev/isxander/yacl3/api/Binding.java') diff --git a/src/main/java/dev/isxander/yacl3/api/Binding.java b/src/main/java/dev/isxander/yacl3/api/Binding.java index f41b78b..61c59a2 100644 --- a/src/main/java/dev/isxander/yacl3/api/Binding.java +++ b/src/main/java/dev/isxander/yacl3/api/Binding.java @@ -6,6 +6,7 @@ import net.minecraft.client.OptionInstance; import org.apache.commons.lang3.Validate; import java.util.function.Consumer; +import java.util.function.Function; import java.util.function.Supplier; /** @@ -19,6 +20,10 @@ public interface Binding { T defaultValue(); + default Binding xmap(Function to, Function from) { + return Binding.generic(to.apply(this.defaultValue()), () -> to.apply(this.getValue()), v -> this.setValue(from.apply(v))); + } + /** * Creates a generic binding. * -- cgit