aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-01-19 21:15:26 +0000
committerisXander <xandersmith2008@gmail.com>2023-01-19 21:15:26 +0000
commitee53b51a1e8d88085c75f227f4710b68c03b19c8 (patch)
tree77a942242a982757da040a6120950bad30e49f77
parentffdd6e5ceacd71c76c55a8716702d4d6da17c7ab (diff)
downloadYetAnotherConfigLib-ee53b51a1e8d88085c75f227f4710b68c03b19c8.tar.gz
YetAnotherConfigLib-ee53b51a1e8d88085c75f227f4710b68c03b19c8.tar.bz2
YetAnotherConfigLib-ee53b51a1e8d88085c75f227f4710b68c03b19c8.zip
mojmap
-rw-r--r--build.gradle.kts8
-rw-r--r--gradle.properties2
-rw-r--r--src/client/java/dev/isxander/yacl/api/Binding.java14
-rw-r--r--src/client/java/dev/isxander/yacl/api/ButtonOption.java20
-rw-r--r--src/client/java/dev/isxander/yacl/api/ConfigCategory.java16
-rw-r--r--src/client/java/dev/isxander/yacl/api/Controller.java4
-rw-r--r--src/client/java/dev/isxander/yacl/api/LabelOption.java16
-rw-r--r--src/client/java/dev/isxander/yacl/api/ListOption.java11
-rw-r--r--src/client/java/dev/isxander/yacl/api/NameableEnum.java4
-rw-r--r--src/client/java/dev/isxander/yacl/api/Option.java16
-rw-r--r--src/client/java/dev/isxander/yacl/api/OptionFlag.java12
-rw-r--r--src/client/java/dev/isxander/yacl/api/OptionGroup.java20
-rw-r--r--src/client/java/dev/isxander/yacl/api/PlaceholderCategory.java22
-rw-r--r--src/client/java/dev/isxander/yacl/api/YetAnotherConfigLib.java12
-rw-r--r--src/client/java/dev/isxander/yacl/gui/AbstractWidget.java49
-rw-r--r--src/client/java/dev/isxander/yacl/gui/CategoryListWidget.java28
-rw-r--r--src/client/java/dev/isxander/yacl/gui/CategoryWidget.java4
-rw-r--r--src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java57
-rw-r--r--src/client/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java26
-rw-r--r--src/client/java/dev/isxander/yacl/gui/OptionListWidget.java124
-rw-r--r--src/client/java/dev/isxander/yacl/gui/RequireRestartScreen.java21
-rw-r--r--src/client/java/dev/isxander/yacl/gui/SearchFieldWidget.java36
-rw-r--r--src/client/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java44
-rw-r--r--src/client/java/dev/isxander/yacl/gui/TooltipButtonWidget.java29
-rw-r--r--src/client/java/dev/isxander/yacl/gui/YACLScreen.java120
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/ActionController.java14
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/BooleanController.java47
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/ColorController.java24
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java76
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/LabelController.java61
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java34
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/TickBoxController.java22
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/cycling/CyclingControllerElement.java10
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/cycling/CyclingListController.java10
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/cycling/EnumController.java22
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/slider/DoubleSliderController.java12
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/slider/FloatSliderController.java12
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/slider/IntegerSliderController.java12
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/slider/LongSliderController.java12
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java40
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/string/IStringController.java6
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java80
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/string/number/DoubleFieldController.java7
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/string/number/FloatFieldController.java7
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/string/number/IntegerFieldController.java6
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/string/number/LongFieldController.java6
-rw-r--r--src/client/java/dev/isxander/yacl/gui/controllers/string/number/NumberFieldController.java12
-rw-r--r--src/client/java/dev/isxander/yacl/gui/utils/GuiUtils.java28
-rw-r--r--src/client/java/dev/isxander/yacl/impl/ButtonOptionImpl.java28
-rw-r--r--src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java28
-rw-r--r--src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java44
-rw-r--r--src/client/java/dev/isxander/yacl/impl/ListOptionEntryImpl.java12
-rw-r--r--src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java26
-rw-r--r--src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java26
-rw-r--r--src/client/java/dev/isxander/yacl/impl/OptionImpl.java36
-rw-r--r--src/client/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java39
-rw-r--r--src/client/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java15
-rw-r--r--src/client/java/dev/isxander/yacl/mixin/client/OptionInstanceAccessor.java (renamed from src/client/java/dev/isxander/yacl/mixin/client/SimpleOptionAccessor.java)8
-rw-r--r--src/client/resources/yet-another-config-lib.client.mixins.json2
-rw-r--r--src/main/java/dev/isxander/yacl/config/GsonConfigInstance.java8
-rw-r--r--src/main/java/dev/isxander/yacl/config/NbtConfigInstance.java276
-rw-r--r--src/main/resources/assets/yet-another-config-lib/lang/ru_ru.json48
-rw-r--r--src/main/resources/assets/yet-another-config-lib/lang/zh_tw.json46
-rw-r--r--src/main/resources/yacl.accesswidener4
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java209
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java14
66 files changed, 921 insertions, 1223 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 3a52db9..4769d21 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -60,15 +60,19 @@ loom {
repositories {
mavenCentral()
maven("https://maven.terraformersmc.com")
+ maven("https://maven.quiltmc.org/repository/release")
}
val minecraftVersion: String by project
val fabricLoaderVersion: String by project
-val yarnBuild: String by project
+val qmBuild: String by project
dependencies {
minecraft("com.mojang:minecraft:$minecraftVersion")
- mappings("net.fabricmc:yarn:$minecraftVersion+build.$yarnBuild:v2")
+ mappings(loom.layered {
+ mappings("org.quiltmc:quilt-mappings:$minecraftVersion+build.$qmBuild:intermediary-v2")
+ officialMojangMappings()
+ })
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
"modClientImplementation"(fabricApi.module("fabric-resource-loader-v0", "0.69.1+1.19.3"))
diff --git a/gradle.properties b/gradle.properties
index 292f0c1..9b9df7b 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G
minecraftVersion=1.19.3
fabricLoaderVersion=0.14.11
-yarnBuild=1
+qmBuild=17
modId=yet-another-config-lib
modName=YetAnotherConfigLib
diff --git a/src/client/java/dev/isxander/yacl/api/Binding.java b/src/client/java/dev/isxander/yacl/api/Binding.java
index 91158d3..ba5a2c0 100644
--- a/src/client/java/dev/isxander/yacl/api/Binding.java
+++ b/src/client/java/dev/isxander/yacl/api/Binding.java
@@ -1,8 +1,8 @@
package dev.isxander.yacl.api;
import dev.isxander.yacl.impl.GenericBindingImpl;
-import dev.isxander.yacl.mixin.client.SimpleOptionAccessor;
-import net.minecraft.client.option.SimpleOption;
+import dev.isxander.yacl.mixin.client.OptionInstanceAccessor;
+import net.minecraft.client.OptionInstance;
import org.apache.commons.lang3.Validate;
import java.util.function.Consumer;
@@ -35,15 +35,15 @@ public interface Binding<T> {
}
/**
- * Creates a {@link Binding} for Minecraft's {@link SimpleOption}
+ * Creates a {@link Binding} for Minecraft's {@link OptionInstance}
*/
- static <T> Binding<T> minecraft(SimpleOption<T> minecraftOption) {
+ static <T> Binding<T> minecraft(OptionInstance<T> minecraftOption) {
Validate.notNull(minecraftOption, "`minecraftOption` must not be null");
return new GenericBindingImpl<>(
- ((SimpleOptionAccessor<T>) (Object) minecraftOption).getDefaultValue(),
- minecraftOption::getValue,
- minecraftOption::setValue
+ ((OptionInstanceAccessor<T>) (Object) minecraftOption).getInitialValue(),
+ minecraftOption::get,
+ minecraftOption::set
);
}
diff --git a/src/client/java/dev/isxander/yacl/api/ButtonOption.java b/src/client/java/dev/isxander/yacl/api/ButtonOption.java
index 2025840..88e1c4b 100644
--- a/src/client/java/dev/isxander/yacl/api/ButtonOption.java
+++ b/src/client/java/dev/isxander/yacl/api/ButtonOption.java
@@ -2,13 +2,9 @@ package dev.isxander.yacl.api;
import dev.isxander.yacl.gui.YACLScreen;
import dev.isxander.yacl.impl.ButtonOptionImpl;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import org.apache.commons.lang3.Validate;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
-import java.util.ArrayList;
-import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -19,7 +15,7 @@ public interface ButtonOption extends Option<BiConsumer<YACLScreen, ButtonOption
*/
BiConsumer<YACLScreen, ButtonOption> action();
- static Builder createBuilder() {
+ static dev.isxander.yacl.api.ButtonOption.Builder createBuilder() {
return new ButtonOptionImpl.BuilderImpl();
}
@@ -29,7 +25,7 @@ public interface ButtonOption extends Option<BiConsumer<YACLScreen, ButtonOption
*
* @see Option#name()
*/
- Builder name(@NotNull Text name);
+ dev.isxander.yacl.api.ButtonOption.Builder name(@NotNull Component name);
/**
* Sets the tooltip to be used by the option.
@@ -38,9 +34,9 @@ public interface ButtonOption extends Option<BiConsumer<YACLScreen, ButtonOption
*
* @param tooltips text lines - merged with a new-line on {@link Option.Builder#build()}.
*/
- Builder tooltip(@NotNull Text... tooltips);
+ dev.isxander.yacl.api.ButtonOption.Builder tooltip(@NotNull Component... tooltips);
- Builder action(@NotNull BiConsumer<YACLScreen, ButtonOption> action);
+ dev.isxander.yacl.api.ButtonOption.Builder action(@NotNull BiConsumer<YACLScreen, ButtonOption> action);
/**
* Action to be executed upon button press
@@ -48,14 +44,14 @@ public interface ButtonOption extends Option<BiConsumer<YACLScreen, ButtonOption
* @see ButtonOption#action()
*/
@Deprecated
- Builder action(@NotNull Consumer<YACLScreen> action);
+ dev.isxander.yacl.api.ButtonOption.Builder action(@NotNull Consumer<YACLScreen> action);
/**
* Sets if the option can be configured
*
* @see Option#available()
*/
- Builder available(boolean available);
+ dev.isxander.yacl.api.ButtonOption.Builder available(boolean available);
/**
* Sets the controller for the option.
@@ -63,7 +59,7 @@ public interface ButtonOption extends Option<BiConsumer<YACLScreen, ButtonOption
*
* @see dev.isxander.yacl.gui.controllers
*/
- Builder controller(@NotNull Function<ButtonOption, Controller<BiConsumer<YACLScreen, ButtonOption>>> control);
+ dev.isxander.yacl.api.ButtonOption.Builder controller(@NotNull Function<ButtonOption, Controller<BiConsumer<YACLScreen, ButtonOption>>> control);
ButtonOption build();
}
diff --git a/src/client/java/dev/isxander/yacl/api/ConfigCategory.java b/src/client/java/dev/isxander/yacl/api/ConfigCategory.java
index eecb9cb..0e8d1e5 100644
--- a/src/client/java/dev/isxander/yacl/api/ConfigCategory.java
+++ b/src/client/java/dev/isxander/yacl/api/ConfigCategory.java
@@ -2,16 +2,10 @@ package dev.isxander.yacl.api;
import com.google.common.collect.ImmutableList;
import dev.isxander.yacl.impl.ConfigCategoryImpl;
-import dev.isxander.yacl.impl.OptionGroupImpl;
-import dev.isxander.yacl.impl.utils.YACLConstants;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import org.apache.commons.lang3.Validate;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
/**
* Separates {@link Option}s or {@link OptionGroup}s into multiple distinct sections.
@@ -22,7 +16,7 @@ public interface ConfigCategory {
/**
* Name of category, displayed as a button on the left column.
*/
- @NotNull Text name();
+ @NotNull Component name();
/**
* Gets every {@link OptionGroup} in this category.
@@ -33,7 +27,7 @@ public interface ConfigCategory {
* Tooltip (or description) of the category.
* Rendered on hover.
*/
- @NotNull Text tooltip();
+ @NotNull Component tooltip();
/**
* Creates a builder to construct a {@link ConfigCategory}
@@ -48,7 +42,7 @@ public interface ConfigCategory {
*
* @see ConfigCategory#name()
*/
- Builder name(@NotNull Text name);
+ Builder name(@NotNull Component name);
/**
* Adds an option to the root group of the category.
@@ -91,7 +85,7 @@ public interface ConfigCategory {
*
* @param tooltips text lines - merged with a new-line on {@link Builder#build()}.
*/
- Builder tooltip(@NotNull Text... tooltips);
+ Builder tooltip(@NotNull Component... tooltips);
ConfigCategory build();
}
diff --git a/src/client/java/dev/isxander/yacl/api/Controller.java b/src/client/java/dev/isxander/yacl/api/Controller.java
index 7bf7e7f..0b8e2ed 100644
--- a/src/client/java/dev/isxander/yacl/api/Controller.java
+++ b/src/client/java/dev/isxander/yacl/api/Controller.java
@@ -3,7 +3,7 @@ package dev.isxander.yacl.api;
import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.AbstractWidget;
import dev.isxander.yacl.gui.YACLScreen;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
/**
* Provides a widget to control the option.
@@ -17,7 +17,7 @@ public interface Controller<T> {
/**
* Gets the formatted value based on {@link Option#pendingValue()}
*/
- Text formatValue();
+ Component formatValue();
/**
* Provides a widget to display
diff --git a/src/client/java/dev/isxander/yacl/api/LabelOption.java b/src/client/java/dev/isxander/yacl/api/LabelOption.java
index 0e8202b..05c7214 100644
--- a/src/client/java/dev/isxander/yacl/api/LabelOption.java
+++ b/src/client/java/dev/isxander/yacl/api/LabelOption.java
@@ -1,7 +1,7 @@
package dev.isxander.yacl.api;
import dev.isxander.yacl.impl.LabelOptionImpl;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -9,19 +9,19 @@ import java.util.Collection;
/**
* A label option is an easier way of creating a label with a {@link dev.isxander.yacl.gui.controllers.LabelController}.
* This option is immutable and cannot be disabled. Tooltips are supported through
- * {@link Text} styling.
+ * {@link Component} styling.
*/
-public interface LabelOption extends Option<Text> {
- @NotNull Text label();
+public interface LabelOption extends Option<Component> {
+ @NotNull Component label();
/**
* Creates a new label option with the given label, skipping a builder for ease.
*/
- static LabelOption create(@NotNull Text label) {
+ static LabelOption create(@NotNull Component label) {
return new LabelOptionImpl(label);
}
- static Builder createBuilder() {
+ static dev.isxander.yacl.api.LabelOption.Builder createBuilder() {
return new LabelOptionImpl.BuilderImpl();
}
@@ -29,12 +29,12 @@ public interface LabelOption extends Option<Text> {
/**
* Appends a line to the label
*/
- Builder line(@NotNull Text line);
+ dev.isxander.yacl.api.LabelOption.Builder line(@NotNull Component line);
/**
* Appends multiple lines to the label
*/
- Builder lines(@NotNull Collection<? extends Text> lines);
+ dev.isxander.yacl.api.LabelOption.Builder lines(@NotNull Collection<? extends Component> lines);
LabelOption build();
}
diff --git a/src/client/java/dev/isxander/yacl/api/ListOption.java b/src/client/java/dev/isxander/yacl/api/ListOption.java
index 54ed3a5..adbdc29 100644
--- a/src/client/java/dev/isxander/yacl/api/ListOption.java
+++ b/src/client/java/dev/isxander/yacl/api/ListOption.java
@@ -1,11 +1,8 @@
package dev.isxander.yacl.api;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import dev.isxander.yacl.impl.ListOptionImpl;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import org.apache.commons.lang3.Validate;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -61,7 +58,7 @@ public interface ListOption<T> extends OptionGroup, Option<List<T>> {
*
* @see ListOption#name()
*/
- Builder<T> name(@NotNull Text name);
+ Builder<T> name(@NotNull Component name);
/**
* Sets the tooltip to be used by the list. It is displayed like a normal
@@ -70,9 +67,9 @@ public interface ListOption<T> extends OptionGroup, Option<List<T>> {
* Can be invoked twice to append more lines.
* No need to wrap the text yourself, the gui does this itself.
*
- * @param tooltips text lines - merged with a new-line on {@link Builder#build()}.
+ * @param tooltips text lines - merged with a new-line on {@link dev.isxander.yacl.api.ListOption.Builder#build()}.
*/
- Builder<T> tooltip(@NotNull Text... tooltips);
+ Builder<T> tooltip(@NotNull Component... tooltips);
/**
* Sets the value that is used when creating new entries
diff --git a/src/client/java/dev/isxander/yacl/api/NameableEnum.java b/src/client/java/dev/isxander/yacl/api/NameableEnum.java
index 793b230..4b04057 100644
--- a/src/client/java/dev/isxander/yacl/api/NameableEnum.java
+++ b/src/client/java/dev/isxander/yacl/api/NameableEnum.java
@@ -1,10 +1,10 @@
package dev.isxander.yacl.api;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
/**
* Used for the default value formatter of {@link dev.isxander.yacl.gui.controllers.cycling.EnumController}
*/
public interface NameableEnum {
- Text getDisplayName();
+ Component getDisplayName();
}
diff --git a/src/client/java/dev/isxander/yacl/api/Option.java b/src/client/java/dev/isxander/yacl/api/Option.java
index 9b4ff7b..faa6f1c 100644
--- a/src/client/java/dev/isxander/yacl/api/Option.java
+++ b/src/client/java/dev/isxander/yacl/api/Option.java
@@ -2,10 +2,7 @@ package dev.isxander.yacl.api;
import com.google.common.collect.ImmutableSet;
import dev.isxander.yacl.impl.OptionImpl;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
-import org.apache.commons.lang3.Validate;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -13,19 +10,18 @@ import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
-import java.util.stream.Stream;
public interface Option<T> {
/**
* Name of the option
*/
- @NotNull Text name();
+ @NotNull Component name();
/**
* Tooltip (or description) of the option.
* Rendered on hover.
*/
- @NotNull Text tooltip();
+ @NotNull Component tooltip();
/**
* Widget provider for a type of option.<