aboutsummaryrefslogtreecommitdiff
path: root/src/client/java/dev/isxander/yacl/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/java/dev/isxander/yacl/api')
-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
12 files changed, 69 insertions, 98 deletions
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.
@@ -128,7 +124,7 @@ public interface Option<T> {
*
* @see Option#name()
*/
- Builder<T> name(@NotNull Text name);
+ Builder<T> name(@NotNull Component name);
/**
* Sets the tooltip to be used by the option.
@@ -137,7 +133,7 @@ public interface Option<T> {
* @param tooltipGetter function to get tooltip depending on value {@link Builder#build()}.
*/
@SuppressWarnings("unchecked")
- Builder<T> tooltip(@NotNull Function<T, Text>... tooltipGetter);
+ Builder<T> tooltip(@NotNull Function<T, Component>... tooltipGetter);
/**
* Sets the tooltip to be used by the option.
@@ -146,7 +142,7 @@ public interface Option<T> {
*
* @param tooltips text lines - merged with a new-line on {@link Builder#build()}.
*/
- Builder<T> tooltip(@NotNull Text... tooltips);
+ Builder<T> tooltip(@NotNull Component... tooltips);
/**
* Sets the controller for the option.
diff --git a/src/client/java/dev/isxander/yacl/api/OptionFlag.java b/src/client/java/dev/isxander/yacl/api/OptionFlag.java
index 7a5c23f..51d57e4 100644
--- a/src/client/java/dev/isxander/yacl/api/OptionFlag.java
+++ b/src/client/java/dev/isxander/yacl/api/OptionFlag.java
@@ -1,7 +1,7 @@
package dev.isxander.yacl.api;
import dev.isxander.yacl.gui.RequireRestartScreen;
-import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.Minecraft;
import java.util.function.Consumer;
@@ -10,14 +10,14 @@ import java.util.function.Consumer;
* Each flag is executed only once per save, no matter the amount of options with the flag.
*/
@FunctionalInterface
-public interface OptionFlag extends Consumer<MinecraftClient> {
+public interface OptionFlag extends Consumer<Minecraft> {
/** Warns the user that a game restart is required for the changes to take effect */
- OptionFlag GAME_RESTART = client -> client.setScreen(new RequireRestartScreen(client.currentScreen));
+ OptionFlag GAME_RESTART = client -> client.setScreen(new RequireRestartScreen(client.screen));
/** Reloads chunks upon applying (F3+A) */
- OptionFlag RELOAD_CHUNKS = client -> client.worldRenderer.reload();
+ OptionFlag RELOAD_CHUNKS = client -> client.levelRenderer.allChanged();
- OptionFlag WORLD_RENDER_UPDATE = client -> client.worldRenderer.scheduleTerrainUpdate();
+ OptionFlag WORLD_RENDER_UPDATE = client -> client.levelRenderer.needsUpdate();
- OptionFlag ASSET_RELOAD = MinecraftClient::reloadResourcesConcurrently;
+ OptionFlag ASSET_RELOAD = Minecraft::delayTextureReload;
}
diff --git a/src/client/java/dev/isxander/yacl/api/OptionGroup.java b/src/client/java/dev/isxander/yacl/api/OptionGroup.java
index 8dd9c14..9f78071 100644
--- a/src/client/java/dev/isxander/yacl/api/OptionGroup.java
+++ b/src/client/java/dev/isxander/yacl/api/OptionGroup.java
@@ -2,14 +2,10 @@ package dev.isxander.yacl.api;
import com.google.common.collect.ImmutableList;
import dev.isxander.yacl.impl.OptionGroupImpl;
-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;
/**
* Serves as a separator between multiple chunks of options
@@ -21,12 +17,12 @@ public interface OptionGroup {
* Name of the option group, displayed as a separator in the option lists.
* Can be empty.
*/
- Text name();
+ Component name();
/**
* Tooltip displayed on hover.
*/
- Text tooltip();
+ Component tooltip();
/**
* List of all options in the group
@@ -53,20 +49,20 @@ public interface OptionGroup {
interface Builder {
/**
- * Sets name of the group, can be {@link Text#empty()} to just separate options, like sodium.
+ * Sets name of the group, can be {@link Component#empty()} to just separate options, like sodium.
*
* @see OptionGroup#name()
*/
- Builder name(@NotNull Text name);
+ Builder name(@NotNull Component name);
/**
* Sets the tooltip to be used by the option group.
* Can be invoked twice to append more lines.
- * No need to wrap the text yourself, the gui does this itself.
+ * No need to wrap the Component yourself, the gui does this itself.
*
- * @param tooltips text lines - merged with a new-line on {@link Builder#build()}.
+ * @param tooltips Component lines - merged with a new-line on {@link Builder#build()}.
*/
- Builder tooltip(@NotNull Text... tooltips);
+ Builder tooltip(@NotNull Component... tooltips);
/**
* Adds an option to group.
diff --git a/src/client/java/dev/isxander/yacl/api/PlaceholderCategory.java b/src/client/java/dev/isxander/yacl/api/PlaceholderCategory.java
index 7bcc821..3641fad 100644
--- a/src/client/java/dev/isxander/yacl/api/PlaceholderCategory.java
+++ b/src/client/java/dev/isxander/yacl/api/PlaceholderCategory.java
@@ -2,15 +2,11 @@ package dev.isxander.yacl.api;
import dev.isxander.yacl.gui.YACLScreen;
import dev.isxander.yacl.impl.PlaceholderCategoryImpl;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import org.apache.commons.lang3.Validate;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
-import java.util.ArrayList;
-import java.util.List;
import java.util.function.BiFunction;
/**
@@ -21,7 +17,7 @@ public interface PlaceholderCategory extends ConfigCategory {
/**
* Function to create a screen to open upon changing to this category
*/
- BiFunction<MinecraftClient, YACLScreen, Screen> screen();
+ BiFunction<Minecraft, YACLScreen, Screen> screen();
static Builder createBuilder() {
return new PlaceholderCategoryImpl.BuilderImpl();
@@ -33,23 +29,23 @@ public interface PlaceholderCategory extends ConfigCategory {
*
* @see ConfigCategory#name()
*/
- Builder name(@NotNull Text name);
+ Builder name(@NotNull Component name);
/**
* Sets the tooltip to be used by the category.
* Can be invoked twice to append more lines.
- * No need to wrap the text yourself, the gui does this itself.
+ * No need to wrap the Component yourself, the gui does this itself.
*
- * @param tooltips text lines - merged with a new-line on {@link Builder#build()}.
+ * @param tooltips Component lines - merged with a new-line on {@link dev.isxander.yacl.api.PlaceholderCategory.Builder#build()}.
*/
- Builder tooltip(@NotNull Text... tooltips);
+ Builder tooltip(@NotNull Component... tooltips);
/**
* Screen to open upon selecting this category
*
* @see PlaceholderCategory#screen()
*/
- Builder screen(@NotNull BiFunction<MinecraftClient, YACLScreen, Screen> screenFunction);
+ Builder screen(@NotNull BiFunction<Minecraft, YACLScreen, Screen> screenFunction);
PlaceholderCategory build();
}
diff --git a/src/client/java/dev/isxander/yacl/api/YetAnotherConfigLib.java b/src/client/java/dev/isxander/yacl/api/YetAnotherConfigLib.java
index f9a71d3..c6da1d1 100644
--- a/src/client/java/dev/isxander/yacl/api/YetAnotherConfigLib.java
+++ b/src/client/java/dev/isxander/yacl/api/YetAnotherConfigLib.java
@@ -4,16 +4,12 @@ import com.google.common.collect.ImmutableList;
import dev.isxander.yacl.config.ConfigInstance;
import dev.isxander.yacl.gui.YACLScreen;
import dev.isxander.yacl.impl.YetAnotherConfigLibImpl;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.text.Text;
-import org.apache.commons.lang3.Validate;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
-import java.util.function.BiFunction;
import java.util.function.Consumer;
/**
@@ -24,7 +20,7 @@ public interface YetAnotherConfigLib {
/**
* Title of the GUI. Only used for Minecraft narration.
*/
- Text title();
+ Component title();
/**
* Gets all config categories.
@@ -69,7 +65,7 @@ public interface YetAnotherConfigLib {
*
* @see YetAnotherConfigLib#title()
*/
- Builder title(@NotNull Text title);
+ Builder title(@NotNull Component title);
/**
* Adds a new category.