From 79cd8ef540b33b7abfb748fe88368e388565790c Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Tue, 14 Mar 2023 14:14:18 -0700 Subject: [PATCH] Support for 1.19.4 --- gradle.properties | 14 ++++++------- .../OrganizablePlayScreens.java | 2 +- .../gui/screen/EditFolderScreen.java | 4 ++-- .../OrganizablePlayScreensOptionsScreen.java | 8 ++++---- .../mixin/MultiplayerScreenMixin.java | 4 ++-- .../MultiplayerServerListWidgetMixin.java | 2 +- .../mixin/SelectWorldScreenMixin.java | 8 ++++---- .../mixin/WorldListWidgetMixin.java | 20 ++++++------------- .../BothSuppliableIntSliderCallbacks.java | 15 +++----------- 9 files changed, 30 insertions(+), 47 deletions(-) diff --git a/gradle.properties b/gradle.properties index c97387f..12d03ae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version = 1.19.3 - yarn_mappings = 1.19.3+build.1 - loader_version = 0.14.11 + minecraft_version = 1.19.4 + yarn_mappings = 1.19.4+build.1 + loader_version = 0.14.17 # Mod Properties - mod_version = 1.1.2 + mod_version = 1.1.3 maven_group = com.kevinthegreat archives_base_name = organizable-play-screens # Dependencies - fabric_version = 0.69.1+1.19.3 - modmenu_version = 5.0.2 - essential_version = 11767+gf9bcb54c0 + fabric_version = 0.75.3+1.19.4 + modmenu_version = 6.1.0-rc.1 + essential_version = 12086+g2a8bd058e diff --git a/src/main/java/com/kevinthegreat/organizableplayscreens/OrganizablePlayScreens.java b/src/main/java/com/kevinthegreat/organizableplayscreens/OrganizablePlayScreens.java index 6856f35..2ef1aaa 100644 --- a/src/main/java/com/kevinthegreat/organizableplayscreens/OrganizablePlayScreens.java +++ b/src/main/java/com/kevinthegreat/organizableplayscreens/OrganizablePlayScreens.java @@ -93,7 +93,7 @@ public static void renderFolderEntry(MatrixStack matrices, int index, int y, int } } OrganizablePlayScreensOptions options = OrganizablePlayScreens.getInstance().options; - buttonMoveInto.setPos(options.getValue(options.moveEntryIntoButtonX), y + options.moveEntryIntoButtonY.getValue()); + buttonMoveInto.setPosition(options.getValue(options.moveEntryIntoButtonX), y + options.moveEntryIntoButtonY.getValue()); buttonMoveInto.render(matrices, mouseX, mouseY, tickDelta); } } diff --git a/src/main/java/com/kevinthegreat/organizableplayscreens/gui/screen/EditFolderScreen.java b/src/main/java/com/kevinthegreat/organizableplayscreens/gui/screen/EditFolderScreen.java index 49228c1..c158afa 100644 --- a/src/main/java/com/kevinthegreat/organizableplayscreens/gui/screen/EditFolderScreen.java +++ b/src/main/java/com/kevinthegreat/organizableplayscreens/gui/screen/EditFolderScreen.java @@ -42,7 +42,7 @@ public EditFolderScreen(BooleanConsumer callback, Mutable folderName, bo protected void init() { nameField = new TextFieldWidget(textRenderer, width / 2 - 100, 90, 200, 20, ENTER_FOLDER_NAME_TEXT); nameField.setMaxLength(128); - nameField.setTextFieldFocused(true); + nameField.setFocused(true); nameField.setText(folderName.getValue()); nameField.setChangedListener(this::updateDoneButton); addSelectableChild(nameField); @@ -103,7 +103,7 @@ private void updateDoneButton(String text) { @Override public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { renderBackground(matrices); - drawCenteredText(matrices, textRenderer, title, width / 2, 20, 0xffffff); + drawCenteredTextWithShadow(matrices, textRenderer, title, width / 2, 20, 0xffffff); drawTextWithShadow(matrices, textRenderer, ENTER_FOLDER_NAME_TEXT, width / 2 - 100, 80, 0xa0a0a0); nameField.render(matrices, mouseX, mouseY, delta); super.render(matrices, mouseX, mouseY, delta); diff --git a/src/main/java/com/kevinthegreat/organizableplayscreens/gui/screen/OrganizablePlayScreensOptionsScreen.java b/src/main/java/com/kevinthegreat/organizableplayscreens/gui/screen/OrganizablePlayScreensOptionsScreen.java index 2b5952d..b9be9eb 100644 --- a/src/main/java/com/kevinthegreat/organizableplayscreens/gui/screen/OrganizablePlayScreensOptionsScreen.java +++ b/src/main/java/com/kevinthegreat/organizableplayscreens/gui/screen/OrganizablePlayScreensOptionsScreen.java @@ -70,7 +70,7 @@ protected void init() { int y = height / 6 - 1 + i * 36; for (Pair> namedOption : optionRow) { int x = width / 2 - 155 + j * 135; - addDrawableChild(namedOption.getRight().createButton(gameOptions, x, y, 125)); + addDrawableChild(namedOption.getRight().createWidget(gameOptions, x, y, 125)); j++; } ButtonWidget resetButton = ButtonWidget.builder(Text.translatable("controls.reset"), (buttonWidget) -> { @@ -84,7 +84,7 @@ protected void init() { } } resetButtons = resetButtonsBuilder.build(); - addDrawableChild(options.buttonType.createButton(gameOptions, width / 2 - 155, height - 28, 150)); + addDrawableChild(options.buttonType.createWidget(gameOptions, width / 2 - 155, height - 28, 150)); addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (buttonWidget) -> { options.save(); client.setScreen(parent); @@ -115,10 +115,10 @@ public void clearAndInit() { @Override public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { renderBackground(matrices); - drawCenteredText(matrices, textRenderer, title, width / 2, 12, 0xFFFFFF); + drawCenteredTextWithShadow(matrices, textRenderer, title, width / 2, 12, 0xFFFFFF); int i = 0; for (String key : OrganizablePlayScreensOptions.KEYS) { - drawCenteredText(matrices, textRenderer, Text.translatable(key), width / 2, height / 6 - 12 + i, 0xFFFFFF); + drawCenteredTextWithShadow(matrices, textRenderer, Text.translatable(key), width / 2, height / 6 - 12 + i, 0xFFFFFF); i += 36; } if (options.buttonType.getValue()) { diff --git a/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/MultiplayerScreenMixin.java b/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/MultiplayerScreenMixin.java index 2b20282..ff17da7 100644 --- a/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/MultiplayerScreenMixin.java +++ b/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/MultiplayerScreenMixin.java @@ -244,9 +244,9 @@ private void organizableplayscreens_keyPressed(int keyCode, int scanCode, int mo * * @see MultiplayerServerListWidgetMixin#organizableplayscreens_currentPath currentPath */ - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;drawCenteredText(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", shift = At.Shift.AFTER)) + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;drawCenteredTextWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", shift = At.Shift.AFTER)) private void organizableplayscreens_renderPath(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { - drawCenteredText(matrices, textRenderer, serverListWidgetAccessor.organizableplayscreens_getCurrentPath(), width / 2, 6, 0xa0a0a0); + drawCenteredTextWithShadow(matrices, textRenderer, serverListWidgetAccessor.organizableplayscreens_getCurrentPath(), width / 2, 6, 0xa0a0a0); } /** diff --git a/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/MultiplayerServerListWidgetMixin.java b/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/MultiplayerServerListWidgetMixin.java index d632178..8198904 100644 --- a/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/MultiplayerServerListWidgetMixin.java +++ b/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/MultiplayerServerListWidgetMixin.java @@ -232,7 +232,7 @@ public void organizableplayscreens_swapEntries(int i, int j) { Collections.swap(organizableplayscreens_currentFolder.getEntries(), i, j); organizableplayscreens_updateAndSave(); setSelected(children().get(j)); - ensureSelectedEntryVisible(); + ensureVisible(getSelectedOrNull()); } /** diff --git a/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/SelectWorldScreenMixin.java b/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/SelectWorldScreenMixin.java index ef1c250..b89743d 100644 --- a/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/SelectWorldScreenMixin.java +++ b/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/SelectWorldScreenMixin.java @@ -88,7 +88,7 @@ private void organizableplayscreens_setWorldListWidgetAccessor(CallbackInfo ci) * The 'move entry back' button moves the selected entry to the parent folder. * The 'new folder' button opens a screen to create a new folder and stores it in {@link #organizableplayscreens_newFolder newFolder}. */ - @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/SelectWorldScreen;worldSelected(Z)V")) + @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/SelectWorldScreen;worldSelected(ZZ)V")) private void organizableplayscreens_addButtons(CallbackInfo ci) { OrganizablePlayScreensOptions options = OrganizablePlayScreens.getInstance().options; organizableplayscreens_buttonBack = addDrawableChild(ButtonWidget.builder(Text.of("←"), buttonWidget -> { @@ -244,16 +244,16 @@ private int organizableplayscreens_modifyTitleY(int original) { * * @see WorldListWidgetMixin#organizableplayscreens_currentPath currentPath */ - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/SelectWorldScreen;drawCenteredText(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", shift = At.Shift.AFTER)) + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/SelectWorldScreen;drawCenteredTextWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", shift = At.Shift.AFTER)) private void organizableplayscreens_renderPath(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { - drawCenteredText(matrices, textRenderer, worldListWidgetAccessor.organizableplayscreens_getCurrentPath(), width / 2, 2, 0xa0a0a0); + drawCenteredTextWithShadow(matrices, textRenderer, worldListWidgetAccessor.organizableplayscreens_getCurrentPath(), width / 2, 2, 0xa0a0a0); } /** * Updates the activation states of buttons. Called at the end of {@link #init()} and every time an entry is selected. */ @Inject(method = "worldSelected", at = @At("RETURN")) - private void organizableplayscreens_updateButtonStates(boolean active, CallbackInfo ci) { + private void organizableplayscreens_updateButtonStates(boolean buttonsActive, boolean deleteButtonActive, CallbackInfo ci) { WorldListWidget.Entry entry = levelList.getSelectedOrNull(); if (entry instanceof WorldListWidget.WorldEntry) { selectButton.setMessage(Text.translatable("selectWorld.select")); diff --git a/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/WorldListWidgetMixin.java b/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/WorldListWidgetMixin.java index 86a8b7f..77483bd 100644 --- a/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/WorldListWidgetMixin.java +++ b/src/main/java/com/kevinthegreat/organizableplayscreens/mixin/WorldListWidgetMixin.java @@ -22,13 +22,11 @@ import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.io.File; import java.util.*; import java.util.concurrent.CompletableFuture; -import java.util.function.Predicate; @Mixin(WorldListWidget.class) public abstract class WorldListWidgetMixin extends AlwaysSelectedEntryListWidget implements WorldListWidgetAccessor { @@ -318,14 +316,6 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { return entry != null && entry.keyPressed(keyCode, scanCode, modifiers) || super.keyPressed(keyCode, scanCode, modifiers); } - /** - * Allows moving selection to unavailable worlds to move them across folders. - */ - @ModifyArg(method = "moveSelection", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/WorldListWidget;moveSelectionIf(Lnet/minecraft/client/gui/widget/EntryListWidget$MoveDirection;Ljava/util/function/Predicate;)Z")) - protected Predicate organizableplayscreens_allowMoveSelectionToWorldEntry(Predicate predicate) { - return predicate.or(WorldListWidget.WorldEntry.class::isInstance); - } - /** * Updates the displayed entries with specified search string. */ @@ -343,7 +333,7 @@ public void organizableplayscreens_swapEntries(int i, int j) { Collections.swap(organizableplayscreens_currentFolder.getFolderEntries(), i, j); organizableplayscreens_updateAndSave(); setSelected(children().get(j)); - ensureSelectedEntryVisible(); + ensureVisible(getSelectedOrNull()); } /** @@ -363,7 +353,7 @@ private void organizableplayscreens_updateEntries(String search) { SingleplayerFolderEntry folderEntry = organizableplayscreens_worlds.get(worldEntry); if (folderEntry != null) { organizableplayscreens_currentFolder = folderEntry; - parent.worldSelected(true); + parent.worldSelected(true, true); } } children().addAll(organizableplayscreens_currentFolder.getFolderEntries()); @@ -376,10 +366,12 @@ private void organizableplayscreens_updateEntries(String search) { } } } - if (getSelectedOrNull() == null) { + WorldListWidget.Entry selected = getSelectedOrNull(); + if (selected == null) { setScrollAmount(0); + } else { + ensureVisible(selected); } - ensureSelectedEntryVisible(); narrateScreenIfNarrationEnabled(); } diff --git a/src/main/java/com/kevinthegreat/organizableplayscreens/option/BothSuppliableIntSliderCallbacks.java b/src/main/java/com/kevinthegreat/organizableplayscreens/option/BothSuppliableIntSliderCallbacks.java index 37a7f75..86b373a 100644 --- a/src/main/java/com/kevinthegreat/organizableplayscreens/option/BothSuppliableIntSliderCallbacks.java +++ b/src/main/java/com/kevinthegreat/organizableplayscreens/option/BothSuppliableIntSliderCallbacks.java @@ -1,7 +1,6 @@ package com.kevinthegreat.organizableplayscreens.option; import com.mojang.serialization.Codec; -import com.mojang.serialization.DataResult; import net.minecraft.client.gui.widget.ClickableWidget; import net.minecraft.client.option.GameOptions; import net.minecraft.client.option.SimpleOption; @@ -50,11 +49,11 @@ public int maxInclusive() { } @Override - public Function, ClickableWidget> getButtonCreator(SimpleOption.TooltipFactory tooltipFactory, GameOptions gameOptions, int x, int y, int width, Consumer changeCallback) { + public Function, ClickableWidget> getWidgetCreator(SimpleOption.TooltipFactory tooltipFactory, GameOptions gameOptions, int x, int y, int width, Consumer changeCallback) { if (buttonType.getValue()) { return option -> new OptionIntTextFieldWidgetImpl(x + 20, y, width - 20, 20, option, this, tooltipFactory); } else { - return SimpleOption.IntSliderCallbacks.super.getButtonCreator(tooltipFactory, gameOptions, x, y, width, changeCallback); + return SimpleOption.IntSliderCallbacks.super.getWidgetCreator(tooltipFactory, gameOptions, x, y, width, changeCallback); } } @@ -65,14 +64,6 @@ public Optional validate(Integer integer) { @Override public Codec codec() { - Function> function = value -> { - int minInclusive = minSupplier.getAsInt(); - int maxInclusive = maxSupplier.getAsInt() + 1; - if (value.compareTo(minInclusive) >= 0 && value.compareTo(maxInclusive) <= 0) { - return DataResult.success(value); - } - return DataResult.error("Value " + value + " outside of range [" + minInclusive + ":" + maxInclusive + "]", value); - }; - return Codec.INT.flatXmap(function, function); + return Codec.intRange(Integer.MIN_VALUE, Integer.MAX_VALUE); } }