aboutsummaryrefslogtreecommitdiff
path: root/src/client/java/dev
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/java/dev')
-rw-r--r--src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java11
-rw-r--r--src/client/java/dev/isxander/yacl/gui/YACLScreen.java4
-rw-r--r--src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java4
-rw-r--r--src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java4
-rw-r--r--src/client/java/dev/isxander/yacl/impl/OptionImpl.java14
5 files changed, 21 insertions, 16 deletions
diff --git a/src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java b/src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java
index ec8e304..46503a6 100644
--- a/src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java
+++ b/src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java
@@ -96,17 +96,6 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten
return null;
}
- @Override
- public boolean mouseReleased(double mouseX, double mouseY, int button) {
- // on mouseClicked, the clicked element becomes focused so you can drag. on release, we should clear the focus
- boolean clicked = super.mouseReleased(mouseX, mouseY, button);
-// if (getFocused() != null) {
-// this.getFocused().setFocused(null);
-//// this.setFocused(null);
-// }
- return clicked;
- }
-
/*
below code is licensed from cloth-config under LGPL3
modified to inherit vanilla's EntryListWidget and use yarn mappings
diff --git a/src/client/java/dev/isxander/yacl/gui/YACLScreen.java b/src/client/java/dev/isxander/yacl/gui/YACLScreen.java
index 3b14544..d653d8c 100644
--- a/src/client/java/dev/isxander/yacl/gui/YACLScreen.java
+++ b/src/client/java/dev/isxander/yacl/gui/YACLScreen.java
@@ -276,8 +276,8 @@ public class YACLScreen extends Screen {
int aboveY = yAbove - height + 12;
int maxBelow = screenHeight - (belowY + height);
int minAbove = aboveY - height;
- int y = belowY;
- if (maxBelow < -8)
+ int y = aboveY;
+ if (minAbove < 8)
y = maxBelow > minAbove ? belowY : aboveY;
int x = Math.max(centerX - text.getWidth() / 2 - 12, -6);
diff --git a/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java b/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java
index b3d28b3..2d39eb9 100644
--- a/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java
@@ -7,6 +7,7 @@ import dev.isxander.yacl.api.Option;
import dev.isxander.yacl.api.OptionGroup;
import dev.isxander.yacl.impl.utils.YACLConstants;
import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.ComponentContents;
import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
@@ -121,6 +122,9 @@ public final class ConfigCategoryImpl implements ConfigCategory {
MutableComponent concatenatedTooltip = Component.empty();
boolean first = true;
for (Component line : tooltipLines) {
+ if (line.getContents() == ComponentContents.EMPTY)
+ continue;
+
if (!first) concatenatedTooltip.append("\n");
first = false;
diff --git a/src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java b/src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java
index 0f883d9..68f53a0 100644
--- a/src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java
@@ -5,6 +5,7 @@ import dev.isxander.yacl.api.ListOption;
import dev.isxander.yacl.api.Option;
import dev.isxander.yacl.api.OptionGroup;
import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.ComponentContents;
import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
@@ -113,6 +114,9 @@ public final class OptionGroupImpl implements OptionGroup {
MutableComponent concatenatedTooltip = Component.empty();
boolean first = true;
for (Component line : tooltipLines) {
+ if (line.getContents() == ComponentContents.EMPTY)
+ continue;
+
if (!first) concatenatedTooltip.append("\n");
first = false;
diff --git a/src/client/java/dev/isxander/yacl/impl/OptionImpl.java b/src/client/java/dev/isxander/yacl/impl/OptionImpl.java
index 35ad620..644abc9 100644
--- a/src/client/java/dev/isxander/yacl/impl/OptionImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/OptionImpl.java
@@ -7,6 +7,7 @@ import dev.isxander.yacl.api.Option;
import dev.isxander.yacl.api.OptionFlag;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.ComponentContents;
import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
@@ -195,9 +196,11 @@ public final class OptionImpl<T> implements Option<T> {
@Override
public Option.Builder<T> tooltip(@NotNull Component... tooltips) {
- Validate.notNull(tooltips, "`tooltips` cannot be empty");
+ var tooltipFunctions = Arrays.stream(tooltips)
+ .map(t -> (Function<T, Component>) opt -> t)
+ .toList();
- this.tooltipGetters.addAll(Stream.of(tooltips).map(Component -> (Function<T, Component>) t -> Component).toList());
+ this.tooltipGetters.addAll(tooltipFunctions);
return this;
}
@@ -277,10 +280,15 @@ public final class OptionImpl<T> implements Option<T> {
MutableComponent concatenatedTooltip = Component.empty();
boolean first = true;
for (Function<T, Component> line : tooltipGetters) {
+ Component lineComponent = line.apply(value);
+
+ if (lineComponent.getContents() == ComponentContents.EMPTY)
+ continue;
+
if (!first) concatenatedTooltip.append("\n");
first = false;
- concatenatedTooltip.append(line.apply(value));
+ concatenatedTooltip.append(lineComponent);
}
return concatenatedTooltip;