diff options
author | isXander <xander@isxander.dev> | 2024-02-29 22:22:46 +0000 |
---|---|---|
committer | isXander <xander@isxander.dev> | 2024-02-29 22:22:46 +0000 |
commit | 308d882fc015fd448deb059b2a814246f7a32f05 (patch) | |
tree | 257777901c4db53220d4ae4ea869426633a42b25 /common/src | |
parent | 0a10f11494db07f974b416c1f69184728b68374c (diff) | |
download | YetAnotherConfigLib-308d882fc015fd448deb059b2a814246f7a32f05.tar.gz YetAnotherConfigLib-308d882fc015fd448deb059b2a814246f7a32f05.tar.bz2 YetAnotherConfigLib-308d882fc015fd448deb059b2a814246f7a32f05.zip |
Start work on 1.20.5
Diffstat (limited to 'common/src')
9 files changed, 24 insertions, 39 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/config/GsonConfigInstance.java b/common/src/main/java/dev/isxander/yacl3/config/GsonConfigInstance.java index 4e7c931..91749ba 100644 --- a/common/src/main/java/dev/isxander/yacl3/config/GsonConfigInstance.java +++ b/common/src/main/java/dev/isxander/yacl3/config/GsonConfigInstance.java @@ -4,6 +4,7 @@ import com.google.gson.*; import dev.isxander.yacl3.config.v2.impl.serializer.GsonConfigSerializer; import dev.isxander.yacl3.gui.utils.ItemRegistryHelper; import dev.isxander.yacl3.impl.utils.YACLConstants; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; @@ -67,7 +68,7 @@ public class GsonConfigInstance<T> extends ConfigInstance<T> { this.path = path; this.gson = builder .setExclusionStrategies(new ConfigExclusionStrategy()) - .registerTypeHierarchyAdapter(Component.class, new Component.SerializerAdapter()) + .registerTypeHierarchyAdapter(Component.class, new Component.SerializerAdapter(RegistryAccess.EMPTY)) .registerTypeHierarchyAdapter(Style.class, new GsonConfigSerializer.StyleTypeAdapter()) .registerTypeHierarchyAdapter(Color.class, new ColorTypeAdapter()) .registerTypeHierarchyAdapter(Item.class, new ItemTypeAdapter()) @@ -162,7 +163,7 @@ public class GsonConfigInstance<T> extends ConfigInstance<T> { private UnaryOperator<GsonBuilder> gsonBuilder = builder -> builder .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .serializeNulls() - .registerTypeHierarchyAdapter(Component.class, new Component.SerializerAdapter()) + .registerTypeHierarchyAdapter(Component.class, new Component.SerializerAdapter(RegistryAccess.EMPTY)) .registerTypeHierarchyAdapter(Style.class, new GsonConfigSerializer.StyleTypeAdapter()) .registerTypeHierarchyAdapter(Color.class, new ColorTypeAdapter()) .registerTypeHierarchyAdapter(Item.class, new ItemTypeAdapter()); diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/impl/serializer/GsonConfigSerializer.java b/common/src/main/java/dev/isxander/yacl3/config/v2/impl/serializer/GsonConfigSerializer.java index d38fb73..8cd1ed4 100644 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/impl/serializer/GsonConfigSerializer.java +++ b/common/src/main/java/dev/isxander/yacl3/config/v2/impl/serializer/GsonConfigSerializer.java @@ -9,6 +9,7 @@ import dev.isxander.yacl3.gui.utils.ItemRegistryHelper; import dev.isxander.yacl3.impl.utils.YACLConstants; import dev.isxander.yacl3.platform.YACLPlatform; import net.minecraft.commands.ParserUtils; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; @@ -220,7 +221,7 @@ public class GsonConfigSerializer<T> extends ConfigSerializer<T> { private UnaryOperator<GsonBuilder> gsonBuilder = builder -> builder .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .serializeNulls() - .registerTypeHierarchyAdapter(Component.class, new Component.SerializerAdapter()) + .registerTypeHierarchyAdapter(Component.class, new Component.SerializerAdapter(RegistryAccess.EMPTY)) .registerTypeHierarchyAdapter(Style.class, new StyleTypeAdapter()) .registerTypeHierarchyAdapter(Color.class, new ColorTypeAdapter()) .registerTypeHierarchyAdapter(Item.class, new ItemTypeAdapter()) diff --git a/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java b/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java index 91cda1f..56dcfcc 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java @@ -21,7 +21,6 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten public ElementListWidgetExt(Minecraft client, int x, int y, int width, int height, boolean smoothScrolling) { super(client, x, y, width, height); this.doSmoothScrolling = smoothScrolling; - setRenderBackground(true); setRenderHeader(false, 0); } @@ -124,7 +123,7 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten } @Override - protected void renderList(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + protected void renderListItems(GuiGraphics graphics, int mouseX, int mouseY, float delta) { int left = this.getRowLeft(); int right = this.getRowWidth(); int count = this.getItemCount(); diff --git a/common/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java b/common/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java index e8b4eb6..20604ef 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java @@ -244,6 +244,10 @@ public class OptionListWidget extends ElementListWidgetExt<OptionListWidget.Entr } } + @Override + protected void renderListBackground(GuiGraphics guiGraphics) { + } + public abstract class Entry extends ElementListWidgetExt.Entry<Entry> { public boolean isViewable() { return true; diff --git a/common/src/main/java/dev/isxander/yacl3/gui/TooltipButtonWidget.java b/common/src/main/java/dev/isxander/yacl3/gui/TooltipButtonWidget.java index f439301..f88bdc3 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/TooltipButtonWidget.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/TooltipButtonWidget.java @@ -15,7 +15,8 @@ public class TooltipButtonWidget extends Button { public TooltipButtonWidget(Screen screen, int x, int y, int width, int height, Component message, Component tooltip, OnPress onPress) { super(x, y, width, height, message, onPress, DEFAULT_NARRATION); this.screen = screen; - if (tooltip != null) - setTooltip(new YACLTooltip(tooltip, this)); + // TODO + if (tooltip != null); + //setTooltip(new YACLTooltip(tooltip, this)); } } diff --git a/common/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java b/common/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java index fbb2fd0..a24b87a 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java @@ -84,12 +84,6 @@ public class YACLScreen extends Screen { config.initConsumer().accept(this); } - @Override - public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - renderDirtBackground(graphics); - super.render(graphics, mouseX, mouseY, delta); - } - protected void finishOrSave() { saveButtonMessage = null; @@ -179,6 +173,11 @@ public class YACLScreen extends Screen { } @Override + protected void renderMenuBackground(GuiGraphics guiGraphics) { + this.renderMenuBackground(guiGraphics, 0, this.tabArea.top() + 1, this.width, this.tabArea.height()); + } + + @Override public boolean shouldCloseOnEsc() { if (pendingChanges()) { setSaveButtonMessage(Component.translatable("yacl.gui.save_before_exit").withStyle(ChatFormatting.RED), Component.translatable("yacl.gui.save_before_exit.tooltip")); @@ -341,11 +340,11 @@ public class YACLScreen extends Screen { public void updateButtons() { boolean pendingChanges = pendingChanges(); - undoButton.active = pendingChanges; - saveFinishedButton.setMessage(pendingChanges ? Component.translatable("yacl.gui.save") : GuiUtils.translatableFallback("yacl.gui.done", CommonComponents.GUI_DONE)); - saveFinishedButton.setTooltip(new YACLTooltip(pendingChanges ? Component.translatable("yacl.gui.save.tooltip") : Component.translatable("yacl.gui.finished.tooltip"), saveFinishedButton)); + // TODO + undoButton.active = pendingChanges; saveFinishedButton.setMessage(pendingChanges ? Component.translatable("yacl.gui.save") : GuiUtils.translatableFallback("yacl.gui.done", CommonComponents.GUI_DONE)); + //saveFinishedButton.setTooltip(new YACLTooltip(pendingChanges ? Component.translatable("yacl.gui.save.tooltip") : Component.translatable("yacl.gui.finished.tooltip"), saveFinishedButton)); cancelResetButton.setMessage(pendingChanges ? GuiUtils.translatableFallback("yacl.gui.cancel", CommonComponents.GUI_CANCEL) : Component.translatable("controls.reset")); - cancelResetButton.setTooltip(new YACLTooltip(pendingChanges ? Component.translatable("yacl.gui.cancel.tooltip") : Component.translatable("yacl.gui.reset.tooltip"), cancelResetButton)); + //cancelResetButton.setTooltip(new YACLTooltip(pendingChanges ? Component.translatable("yacl.gui.cancel.tooltip") : Component.translatable("yacl.gui.reset.tooltip"), cancelResetButton)); } } diff --git a/common/src/main/java/dev/isxander/yacl3/gui/YACLTooltip.java b/common/src/main/java/dev/isxander/yacl3/gui/YACLTooltip.java deleted file mode 100644 index 966b8a8..0000000 --- a/common/src/main/java/dev/isxander/yacl3/gui/YACLTooltip.java +++ /dev/null @@ -1,20 +0,0 @@ -package dev.isxander.yacl3.gui; - -import net.minecraft.client.gui.components.Tooltip; -import net.minecraft.client.gui.navigation.ScreenRectangle; -import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner; -import net.minecraft.network.chat.Component; - -public class YACLTooltip extends Tooltip { - private final net.minecraft.client.gui.components.AbstractWidget widget; - - public YACLTooltip(Component tooltip, net.minecraft.client.gui.components.AbstractWidget widget) { - super(tooltip, tooltip); - this.widget = widget; - } - - @Override - protected ClientTooltipPositioner createTooltipPositioner(boolean bl, boolean bl2, ScreenRectangle screenRectangle) { - return new YACLTooltipPositioner(widget); - } -} diff --git a/common/src/main/java/dev/isxander/yacl3/gui/controllers/dropdown/AbstractDropdownControllerElement.java b/common/src/main/java/dev/isxander/yacl3/gui/controllers/dropdown/AbstractDropdownControllerElement.java index 0e62af4..31d4d51 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/controllers/dropdown/AbstractDropdownControllerElement.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/controllers/dropdown/AbstractDropdownControllerElement.java @@ -226,7 +226,7 @@ public abstract class AbstractDropdownControllerElement<T, U> extends StringCont public void renderDropdownBackground(GuiGraphics graphics, int numberOfItems) { graphics.setColor(0.25f, 0.25f, 0.25f, 1.0f); - graphics.blit(Screen.BACKGROUND_LOCATION, getDimension().x(), getDimension().yLimit() + 2, 0, 0.0f, 0.0f, getDimension().width(), getDimension().height() * numberOfItems + 2, 32, 32); + graphics.blit(Screen.MENU_BACKGROUND, getDimension().x(), getDimension().yLimit() + 2, 0, 0.0f, 0.0f, getDimension().width(), getDimension().height() * numberOfItems + 2, 32, 32); graphics.setColor(1.0f, 1.0f, 1.0f, 1.0f); graphics.renderOutline(getDimension().x(), getDimension().yLimit() + 2, getDimension().width(), getDimension().height() * numberOfItems, -1); } diff --git a/common/src/main/resources/yacl.accesswidener b/common/src/main/resources/yacl.accesswidener index 7c0e2ca..39e8981 100644 --- a/common/src/main/resources/yacl.accesswidener +++ b/common/src/main/resources/yacl.accesswidener @@ -4,7 +4,7 @@ extendable method net/minecraft/client/gui/components/AbstractSelectionList chil extendable method net/minecraft/client/gui/components/AbstractSelectionList getEntryAtPosition (DD)Lnet/minecraft/client/gui/components/AbstractSelectionList$Entry; accessible class net/minecraft/client/gui/components/AbstractSelectionList$Entry accessible method net/minecraft/client/gui/components/tabs/TabNavigationBar <init> (ILnet/minecraft/client/gui/components/tabs/TabManager;Ljava/lang/Iterable;)V -accessible field net/minecraft/client/gui/components/tabs/TabNavigationBar layout Lnet/minecraft/client/gui/layouts/GridLayout; +accessible field net/minecraft/client/gui/components/tabs/TabNavigationBar layout Lnet/minecraft/client/gui/layouts/LinearLayout; accessible field net/minecraft/client/gui/components/tabs/TabNavigationBar width I accessible field net/minecraft/client/gui/components/tabs/TabNavigationBar tabManager Lnet/minecraft/client/gui/components/tabs/TabManager; accessible field net/minecraft/client/gui/components/tabs/TabNavigationBar tabs Lcom/google/common/collect/ImmutableList; |