diff --git a/README.md b/README.md
index 79e52c3..8e06db3 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,7 @@ You can download the **latest version** in the [Releases](https://github.com/ImC
The mod is also avaliable to download on [Modrinth](https://modrinth.com/mod/quick-menu).
## Features
-
-
-
+
- Easy to access menu with a **keybind** *(Default: G)*
- A simple action button **editor**.
diff --git a/build.gradle b/build.gradle
index abea5ad..41a2983 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id 'fabric-loom' version '1.9-SNAPSHOT'
+ id 'fabric-loom' version '1.11-SNAPSHOT'
id 'maven-publish'
}
@@ -17,6 +17,7 @@ repositories {
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
+ mavenLocal()
// owo-lib
maven { url 'https://maven.wispforest.io' }
}
diff --git a/gradle.properties b/gradle.properties
index 66cdf8f..b4e2485 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -4,17 +4,19 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
-minecraft_version=1.21.4
-yarn_mappings=1.21.4+build.8
-loader_version=0.16.10
+
+
+minecraft_version=1.21.10
+yarn_mappings=1.21.10+build.2
+loader_version=0.17.3
# Fabric API
-fabric_version=0.115.1+1.21.4
+fabric_version=0.135.0+1.21.10
# Mod Properties
-mod_version=1.2.6
+mod_version=1.2.10
maven_group=xyz.imcodist.quickmenu
archives_base_name=quick-menu
# owo-lib
-owo_version=0.12.20+1.21.4
\ No newline at end of file
+owo_version=0.12.24+1.21.9
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index c1962a7..a4b76b9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 21d5e09..ca025c8 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index aeb74cb..f5feea6 100644
--- a/gradlew
+++ b/gradlew
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,7 +85,9 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +134,13 @@ location of your Java installation."
fi
else
JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
@@ -141,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -149,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,11 +205,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
diff --git a/gradlew.bat b/gradlew.bat
index 93e3f59..9d21a21 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
diff --git a/src/main/java/xyz/imcodist/quickmenu/QuickMenu.java b/src/main/java/xyz/imcodist/quickmenu/QuickMenu.java
index 64ab010..f136740 100644
--- a/src/main/java/xyz/imcodist/quickmenu/QuickMenu.java
+++ b/src/main/java/xyz/imcodist/quickmenu/QuickMenu.java
@@ -3,10 +3,8 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.util.InputUtil;
-import xyz.imcodist.quickmenu.other.ActionButtonDataHandler;
-import xyz.imcodist.quickmenu.other.KeybindHandler;
+import xyz.imcodist.quickmenu.other.*;
import xyz.imcodist.quickmenu.other.ModConfig;
-import xyz.imcodist.quickmenu.other.ModKeybindings;
import xyz.imcodist.quickmenu.ui.MainUI;
public class QuickMenu implements ModInitializer {
@@ -20,8 +18,10 @@ public void onInitialize() {
ModKeybindings.initialize();
ActionButtonDataHandler.initialize();
+// ClientTickEvents.START_CLIENT_TICK.register(ActionButtonDelayHandler.INSTANCE);
// On the end of each tick check to see if a keybind has been pressed.
ClientTickEvents.END_CLIENT_TICK.register((client) -> {
+ ActionButtonDelayHandler.INSTANCE.doDelayChecks();
// Check for menu open keybind.
if (ModKeybindings.menuOpenKeybinding.isPressed()) {
if (!menuKeyPressed) {
@@ -44,7 +44,7 @@ public void onInitialize() {
InputUtil.Key key = actionButtonData.getKey();
if (key == null) return;
- long handle = client.getWindow().getHandle();
+ var handle = client.getWindow();
if (InputUtil.isKeyPressed(handle, key.getCode())) {
if (!actionButtonData.keyPressed) run = true;
actionButtonData.keyPressed = true;
diff --git a/src/main/java/xyz/imcodist/quickmenu/data/ActionButtonData.java b/src/main/java/xyz/imcodist/quickmenu/data/ActionButtonData.java
index e717e1b..1064ee5 100644
--- a/src/main/java/xyz/imcodist/quickmenu/data/ActionButtonData.java
+++ b/src/main/java/xyz/imcodist/quickmenu/data/ActionButtonData.java
@@ -1,6 +1,7 @@
package xyz.imcodist.quickmenu.data;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.input.KeyInput;
import net.minecraft.client.util.InputUtil;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.CustomModelDataComponent;
@@ -11,7 +12,9 @@
import xyz.imcodist.quickmenu.QuickMenu;
import xyz.imcodist.quickmenu.data.command_actions.BaseActionData;
import xyz.imcodist.quickmenu.data.command_actions.CommandActionData;
+import xyz.imcodist.quickmenu.data.command_actions.DelayActionData;
import xyz.imcodist.quickmenu.data.command_actions.KeybindActionData;
+import xyz.imcodist.quickmenu.other.ActionButtonDelayHandler;
import xyz.imcodist.quickmenu.other.ModConfigModel;
import java.util.ArrayList;
@@ -34,6 +37,10 @@ public ActionButtonDataJSON toJSON() {
jsonData.keybind = keybind;
actions.forEach((action) -> {
+ if(action == null)
+ {
+ return;
+ }
ArrayList actionArray = new ArrayList<>();
actionArray.add(action.getJsonType());
actionArray.add(action.getJsonValue());
@@ -67,7 +74,9 @@ public static ActionButtonData fromJSON(ActionButtonDataJSON json) {
json.actions.forEach((actionArray) -> {
BaseActionData actionData = getActionDataType(actionArray.get(0), actionArray.get(1));
- data.actions.add(actionData);
+ if(actionData != null) {
+ data.actions.add(actionData);
+ }
});
if (json.icon != null) {
@@ -95,6 +104,11 @@ private static BaseActionData getActionDataType(String type, String value) {
keybindActionData.keybindTranslationKey = value;
return keybindActionData;
}
+ case "delay" -> {
+ var delayAction = new DelayActionData();
+ delayAction.ticks = Math.max(0, Long.parseLong(value));
+ return delayAction;
+ }
}
return null;
@@ -102,7 +116,7 @@ private static BaseActionData getActionDataType(String type, String value) {
public InputUtil.Key getKey() {
if (keybind.size() < 4) return null;
- return InputUtil.fromKeyCode(keybind.get(0), keybind.get(1));
+ return InputUtil.fromKeyCode(new KeyInput(keybind.get(0), keybind.get(1), 0));
}
public void run() {
@@ -119,9 +133,55 @@ public void run(boolean isKeybind) {
client.player.sendMessage(Text.of("Ran action \"" + name + "\""), true);
}
}
+// MinecraftClient.getInstance()
// Run the buttons action.
- actions.forEach(BaseActionData::run);
+// actions.forEach(BaseActionData::run);
+ new ActionButtonDataContext(new ArrayList<>(actions), 0).run();
+ }
+
+ public static class ActionButtonDataContext {
+
+ private final List actions;
+ private long delay;
+
+ public ActionButtonDataContext(
+ List actions,
+ long delay
+ ) {
+ this.actions = actions;
+ this.delay = delay;
+ }
+
+ public void run() {
+ for (var idx = 0; idx < actions.size(); idx++) {
+ var action = actions.get(idx);
+ var nextDelay = action.run();
+ if (nextDelay > 0) {
+ // TODO : Envelope the remaining actions in a timer.
+ var nextSet = new ActionButtonDataContext(actions.subList(idx + 1, actions.size()), nextDelay);
+ // TODO - Create a timer construct that listens
+ ActionButtonDelayHandler.INSTANCE.add(nextSet);
+ return;
+ }
+ }
+ }
+
+ public long getDelay() {
+ return delay;
+ }
+
+ public void decrementDelay()
+ {
+ delay = Math.max(0, delay - 1);
+ }
+
+ public boolean isReady()
+ {
+ return delay == 0;
+ }
+
+
}
public static class CustomModelDataValues {
diff --git a/src/main/java/xyz/imcodist/quickmenu/data/command_actions/BaseActionData.java b/src/main/java/xyz/imcodist/quickmenu/data/command_actions/BaseActionData.java
index c9b6e35..950d640 100644
--- a/src/main/java/xyz/imcodist/quickmenu/data/command_actions/BaseActionData.java
+++ b/src/main/java/xyz/imcodist/quickmenu/data/command_actions/BaseActionData.java
@@ -13,5 +13,7 @@ public String getString() {
return "uh oh why are you seeing this";
}
- public void run() {}
+ public long run() {
+ return 0;
+ }
}
diff --git a/src/main/java/xyz/imcodist/quickmenu/data/command_actions/CommandActionData.java b/src/main/java/xyz/imcodist/quickmenu/data/command_actions/CommandActionData.java
index 4239ee7..9333980 100644
--- a/src/main/java/xyz/imcodist/quickmenu/data/command_actions/CommandActionData.java
+++ b/src/main/java/xyz/imcodist/quickmenu/data/command_actions/CommandActionData.java
@@ -23,12 +23,12 @@ public String getString() {
}
@Override
- public void run() {
+ public long run() {
MinecraftClient client = MinecraftClient.getInstance();
- if (client == null) return;
+ if (client == null) return 0;
ClientPlayerEntity player = client.player;
- if (player == null) return;
+ if (player == null) return 0;
// Run the command.
String commandToRun = command;
@@ -44,5 +44,6 @@ public void run() {
player.networkHandler.sendChatMessage(commandToRun);
}
}
+ return 0;
}
}
diff --git a/src/main/java/xyz/imcodist/quickmenu/data/command_actions/DelayActionData.java b/src/main/java/xyz/imcodist/quickmenu/data/command_actions/DelayActionData.java
new file mode 100644
index 0000000..c47b1e4
--- /dev/null
+++ b/src/main/java/xyz/imcodist/quickmenu/data/command_actions/DelayActionData.java
@@ -0,0 +1,31 @@
+package xyz.imcodist.quickmenu.data.command_actions;
+
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.network.ClientPlayerEntity;
+
+public class DelayActionData extends BaseActionData {
+
+ public long ticks = 20;
+
+ @Override
+ public String getJsonType() {
+ return "delay";
+ }
+ @Override
+ public String getJsonValue() {
+ return String.format("%s", ticks);
+ }
+
+ @Override
+ public String getTypeString() { return "DLY"; }
+ @Override
+ public String getString() {
+ return String.format("%s", ticks);
+ }
+
+ @Override
+ public long run() {
+ // TODO - rework this function to allow delays
+ return ticks;
+ }
+}
diff --git a/src/main/java/xyz/imcodist/quickmenu/data/command_actions/KeybindActionData.java b/src/main/java/xyz/imcodist/quickmenu/data/command_actions/KeybindActionData.java
index 488dd95..08e0ee8 100644
--- a/src/main/java/xyz/imcodist/quickmenu/data/command_actions/KeybindActionData.java
+++ b/src/main/java/xyz/imcodist/quickmenu/data/command_actions/KeybindActionData.java
@@ -23,7 +23,8 @@ public String getString() {
}
@Override
- public void run() {
+ public long run() {
KeybindHandler.pressKey(keybindTranslationKey);
+ return 0;
}
}
diff --git a/src/main/java/xyz/imcodist/quickmenu/other/ActionButtonDelayHandler.java b/src/main/java/xyz/imcodist/quickmenu/other/ActionButtonDelayHandler.java
new file mode 100644
index 0000000..00d199f
--- /dev/null
+++ b/src/main/java/xyz/imcodist/quickmenu/other/ActionButtonDelayHandler.java
@@ -0,0 +1,36 @@
+package xyz.imcodist.quickmenu.other;
+
+import net.minecraft.client.MinecraftClient;
+import xyz.imcodist.quickmenu.data.ActionButtonData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ActionButtonDelayHandler {
+
+ public static final ActionButtonDelayHandler INSTANCE = new ActionButtonDelayHandler();
+
+ private final List delayedActions = new ArrayList<>();
+
+ private final List actionsInbox = new ArrayList<>();
+
+ public void add(ActionButtonData.ActionButtonDataContext context){
+ actionsInbox.add(context);
+ }
+
+
+ public void doDelayChecks() {
+ for(var it = delayedActions.iterator(); it.hasNext();){
+ var action = it.next();
+ action.decrementDelay();
+ if(action.isReady()){
+ action.run();
+ it.remove();
+ }
+ }
+ if(!actionsInbox.isEmpty()) {
+ delayedActions.addAll(actionsInbox);
+ actionsInbox.clear();
+ }
+ }
+}
diff --git a/src/main/java/xyz/imcodist/quickmenu/other/KeybindHandler.java b/src/main/java/xyz/imcodist/quickmenu/other/KeybindHandler.java
index c8412c2..39e94fe 100644
--- a/src/main/java/xyz/imcodist/quickmenu/other/KeybindHandler.java
+++ b/src/main/java/xyz/imcodist/quickmenu/other/KeybindHandler.java
@@ -46,7 +46,7 @@ public static KeyBinding getFromTranslationKey(String translationKey) {
MinecraftClient client = MinecraftClient.getInstance();
if (client != null) {
for (KeyBinding keyBinding : client.options.allKeys) {
- if (keyBinding.getTranslationKey().equals(translationKey)) return keyBinding;
+ if (keyBinding.getId().equals(translationKey)) return keyBinding;
}
}
diff --git a/src/main/java/xyz/imcodist/quickmenu/other/ModKeybindings.java b/src/main/java/xyz/imcodist/quickmenu/other/ModKeybindings.java
index 96c5619..d698d02 100644
--- a/src/main/java/xyz/imcodist/quickmenu/other/ModKeybindings.java
+++ b/src/main/java/xyz/imcodist/quickmenu/other/ModKeybindings.java
@@ -3,19 +3,20 @@
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
+import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;
public class ModKeybindings {
public static KeyBinding menuOpenKeybinding;
public static void initialize() {
- String mainCategory = "key.category.quickmenu";
+// String mainCategory = "key.category.quickmenu";
menuOpenKeybinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.quickmenu.open",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_G,
- mainCategory
+ KeyBinding.Category.create(Identifier.of("quickmenu:all"))
));
}
}
diff --git a/src/main/java/xyz/imcodist/quickmenu/ui/ActionEditorUI.java b/src/main/java/xyz/imcodist/quickmenu/ui/ActionEditorUI.java
index b485c27..4868ce6 100644
--- a/src/main/java/xyz/imcodist/quickmenu/ui/ActionEditorUI.java
+++ b/src/main/java/xyz/imcodist/quickmenu/ui/ActionEditorUI.java
@@ -11,6 +11,8 @@
import io.wispforest.owo.ui.container.ScrollContainer;
import io.wispforest.owo.ui.core.*;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.Click;
+import net.minecraft.client.input.KeyInput;
import net.minecraft.client.util.InputUtil;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.CustomModelDataComponent;
@@ -23,6 +25,7 @@
import xyz.imcodist.quickmenu.data.ActionButtonData;
import xyz.imcodist.quickmenu.data.command_actions.BaseActionData;
import xyz.imcodist.quickmenu.data.command_actions.CommandActionData;
+import xyz.imcodist.quickmenu.data.command_actions.DelayActionData;
import xyz.imcodist.quickmenu.data.command_actions.KeybindActionData;
import xyz.imcodist.quickmenu.other.ActionButtonDataHandler;
import xyz.imcodist.quickmenu.ui.components.QuickMenuButton;
@@ -81,7 +84,6 @@ protected void build(FlowLayout rootComponent) {
int mainLayoutHeight = 206;
FlowLayout mainLayout = Containers.verticalFlow(Sizing.fixed(210), Sizing.fixed(mainLayoutHeight));
mainLayout.surface(new SwitcherSurface());
- mainLayout.zIndex(-200);
rootComponent.child(mainLayout);
// Set up the header.
@@ -300,7 +302,7 @@ public void createActions(FlowLayout layout) {
ButtonComponent keybindActionButton = Components.button(Text.translatable("menu.editor.not_bound"), (buttonComponent) -> {
KeybindPickerUI keybindPicker = new KeybindPickerUI();
keybindPicker.onSelectedKeybind = (item) -> {
- keybindAction.keybindTranslationKey = item.getTranslationKey();
+ keybindAction.keybindTranslationKey = item.getId();
updateActionKeybindMessage(buttonComponent, keybindAction);
};
@@ -315,6 +317,16 @@ public void createActions(FlowLayout layout) {
property.child(keybindActionButton);
}
+ if (action instanceof DelayActionData delayAction) {
+ TextBoxComponent textBoxComponent = Components.textBox(Sizing.fill(57));
+
+ textBoxComponent.setMaxLength(10);
+ textBoxComponent.text( String.format("%s", delayAction.ticks) );
+
+ property.child(textBoxComponent);
+ source = textBoxComponent;
+ }
+
// Add the remove button.
ButtonComponent removeActionButton = Components.button(Text.literal(" - "), (buttonComponent -> {
int currentIndex = actionArray.indexOf(action);
@@ -379,6 +391,11 @@ public void updateActionData() {
commandAction.command = textBoxSource.getText();
}
+ if (action instanceof DelayActionData delayAction) {
+ TextBoxComponent textBoxSource = (TextBoxComponent) source;
+ delayAction.ticks = Math.max(0, Long.parseLong(textBoxSource.getText()));
+ }
+
i.addAndGet(1);
});
}
@@ -391,7 +408,7 @@ public void updateKeybindButton() {
boolean isMouse = keybind.get(3) == 1;
if (!isMouse) {
- message = InputUtil.fromKeyCode(keybind.get(0), keybind.get(1)).getLocalizedText().getString();
+ message = InputUtil.fromKeyCode(new KeyInput(keybind.get(0), keybind.get(1),0)).getLocalizedText().getString();
} else {
message = switch (keybind.getFirst()) {
case 0 -> "Left Button";
@@ -422,7 +439,10 @@ private void updateActionKeybindMessage(ButtonComponent button, KeybindActionDat
}
@Override
- public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
+ public boolean keyPressed(KeyInput input) {
+ int keyCode = input.key();
+ int scanCode = input.scancode();
+ int modifiers = input.modifiers();
boolean wasEscape = false;
if (settingKeybind) {
@@ -446,12 +466,15 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
updateKeybindButton();
}
- if (!wasEscape) return super.keyPressed(keyCode, scanCode, modifiers);
+ if (!wasEscape) return super.keyPressed(input);
else return false;
}
@Override
- public boolean mouseClicked(double mouseX, double mouseY, int button) {
+ public boolean mouseClicked(Click click, boolean doubled) {
+ double mouseX = click.x();
+ double mouseY = click.y();
+ int button = click.button();
boolean keybindSet = false;
if (settingKeybind) {
@@ -475,7 +498,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
updateKeybindButton();
}
- if (!keybindSet) return super.mouseClicked(mouseX, mouseY, button);
+ if (!keybindSet) return super.mouseClicked(click, doubled);
else return false;
}
diff --git a/src/main/java/xyz/imcodist/quickmenu/ui/MainUI.java b/src/main/java/xyz/imcodist/quickmenu/ui/MainUI.java
index ae6dcee..ad54e4f 100644
--- a/src/main/java/xyz/imcodist/quickmenu/ui/MainUI.java
+++ b/src/main/java/xyz/imcodist/quickmenu/ui/MainUI.java
@@ -10,6 +10,9 @@
import io.wispforest.owo.ui.container.ScrollContainer;
import io.wispforest.owo.ui.core.*;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.Click;
+import net.minecraft.client.input.KeyInput;
+import net.minecraft.client.input.MouseInput;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@@ -256,8 +259,8 @@ private void closeOnKeybindRelease(boolean mouse, int button, int button2) {
// Make sure the keybind is correct.
if (
- (mouse && ModKeybindings.menuOpenKeybinding.matchesMouse(button))
- || (!mouse && ModKeybindings.menuOpenKeybinding.matchesKey(button, button2))
+ (mouse && ModKeybindings.menuOpenKeybinding.matchesMouse(new Click(0,0, new MouseInput(button, 0))))
+ || (!mouse && ModKeybindings.menuOpenKeybinding.matchesKey(new KeyInput(button, button2, 0)))
) {
if (hoveredData != null) {
// Press the current button.
@@ -269,25 +272,25 @@ private void closeOnKeybindRelease(boolean mouse, int button, int button2) {
}
@Override
- public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
- if (keyCode == GLFW.GLFW_KEY_E) {
+ public boolean keyPressed(KeyInput keyInput) {
+ if (keyInput.getKeycode() == GLFW.GLFW_KEY_E) {
editMode = !editMode;
updateEditorLayout();
}
- return super.keyPressed(keyCode, scanCode, modifiers);
+ return super.keyPressed(keyInput);
}
@Override
- public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
- closeOnKeybindRelease(keyCode, scanCode);
- return super.keyReleased(keyCode, scanCode, modifiers);
+ public boolean keyReleased(KeyInput keyInput) {
+ closeOnKeybindRelease(keyInput.getKeycode(), keyInput.scancode());
+ return super.keyReleased(keyInput);
}
@Override
- public boolean mouseReleased(double mouseX, double mouseY, int button) {
- closeOnKeybindRelease(button);
- return super.mouseReleased(mouseX, mouseY, button);
+ public boolean mouseReleased(Click click) {
+ closeOnKeybindRelease(click.button());
+ return super.mouseReleased(click);
}
@Override
diff --git a/src/main/java/xyz/imcodist/quickmenu/ui/components/QuickMenuButton.java b/src/main/java/xyz/imcodist/quickmenu/ui/components/QuickMenuButton.java
index 07374e5..e52c6f3 100644
--- a/src/main/java/xyz/imcodist/quickmenu/ui/components/QuickMenuButton.java
+++ b/src/main/java/xyz/imcodist/quickmenu/ui/components/QuickMenuButton.java
@@ -3,6 +3,7 @@
import io.wispforest.owo.ui.component.ButtonComponent;
import io.wispforest.owo.ui.core.OwoUIDrawContext;
import io.wispforest.owo.ui.core.Sizing;
+import net.minecraft.client.gui.Click;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
@@ -41,8 +42,8 @@ public void draw(OwoUIDrawContext context, int mouseX, int mouseY, float partial
}
@Override
- public boolean onMouseDown(double mouseX, double mouseY, int button) {
- if (button == GLFW.GLFW_MOUSE_BUTTON_2) rightClick.accept(this);
- return super.onMouseDown(mouseX, mouseY, button);
+ public boolean onMouseDown(Click click, boolean doubled) {
+ if (click.button() == GLFW.GLFW_MOUSE_BUTTON_2) rightClick.accept(this);
+ return super.onMouseDown(click, doubled);
}
}
diff --git a/src/main/java/xyz/imcodist/quickmenu/ui/popups/ActionPickerUI.java b/src/main/java/xyz/imcodist/quickmenu/ui/popups/ActionPickerUI.java
index f5c6fa3..ef1bf11 100644
--- a/src/main/java/xyz/imcodist/quickmenu/ui/popups/ActionPickerUI.java
+++ b/src/main/java/xyz/imcodist/quickmenu/ui/popups/ActionPickerUI.java
@@ -10,6 +10,7 @@
import net.minecraft.util.Formatting;
import xyz.imcodist.quickmenu.data.command_actions.BaseActionData;
import xyz.imcodist.quickmenu.data.command_actions.CommandActionData;
+import xyz.imcodist.quickmenu.data.command_actions.DelayActionData;
import xyz.imcodist.quickmenu.data.command_actions.KeybindActionData;
import xyz.imcodist.quickmenu.ui.surfaces.SwitcherSurface;
@@ -47,6 +48,7 @@ public ActionPickerUI() {
// Create action buttons.
addListData("command", "Command", "Runs a chat command.");
addListData("keybind", "Keybind", "Activates a keybind.");
+ addListData("delay", "Delay", "Adds a delay.");
for (ArrayList data : listData) {
actionsLayout.child(createActionLayout(data));
@@ -91,6 +93,7 @@ private BaseActionData getActionFromType(String type) {
switch (type) {
case "command" -> {return new CommandActionData();}
case "keybind" -> {return new KeybindActionData();}
+ case "delay" -> { return new DelayActionData(); }
}
return null;
diff --git a/src/main/java/xyz/imcodist/quickmenu/ui/popups/KeybindPickerUI.java b/src/main/java/xyz/imcodist/quickmenu/ui/popups/KeybindPickerUI.java
index 8022768..67a2542 100644
--- a/src/main/java/xyz/imcodist/quickmenu/ui/popups/KeybindPickerUI.java
+++ b/src/main/java/xyz/imcodist/quickmenu/ui/popups/KeybindPickerUI.java
@@ -49,7 +49,7 @@ public KeybindPickerUI() {
if (keyBindings != null) {
Map> sortedKeybindings = new HashMap<>();
for (KeyBinding keyBinding : keyBindings) {
- String category = keyBinding.getCategory();
+ String category = keyBinding.getCategory().id().toTranslationKey("key.category"); // TODO - Handle this better
if (!sortedKeybindings.containsKey(category)) {
sortedKeybindings.put(category, new ArrayList<>());
@@ -72,7 +72,7 @@ public KeybindPickerUI() {
layout.padding(Insets.of(1, 1, 0, 0));
layout.horizontalAlignment(HorizontalAlignment.RIGHT);
- LabelComponent keyLabel = Components.label(Text.translatable(keyBinding.getTranslationKey()));
+ LabelComponent keyLabel = Components.label(Text.translatable(keyBinding.getId()));
keyLabel.horizontalTextAlignment(HorizontalAlignment.LEFT);
keyLabel.positioning(Positioning.relative(0, 50));
layout.child(keyLabel);
diff --git a/src/main/java/xyz/imcodist/quickmenu/ui/surfaces/SwitcherSurface.java b/src/main/java/xyz/imcodist/quickmenu/ui/surfaces/SwitcherSurface.java
index 8b2a2db..917ed28 100644
--- a/src/main/java/xyz/imcodist/quickmenu/ui/surfaces/SwitcherSurface.java
+++ b/src/main/java/xyz/imcodist/quickmenu/ui/surfaces/SwitcherSurface.java
@@ -4,6 +4,7 @@
import io.wispforest.owo.ui.core.OwoUIDrawContext;
import io.wispforest.owo.ui.core.ParentComponent;
import io.wispforest.owo.ui.core.Surface;
+import net.minecraft.client.gl.RenderPipelines;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.util.Identifier;
@@ -25,15 +26,15 @@ public void draw(OwoUIDrawContext context, ParentComponent component) {
int sourceX = (isHeader) ? 0 : 24;
// Make sure the background renders as transparent.
- if (!isHeader) RenderSystem.enableBlend();
- RenderSystem.setShaderColor(1, 1, 1, 1);
+// if (!isHeader) RenderSystem.enableBlend(); // TODO - Figure out if a fix is needed
+// RenderSystem.setShaderColor(1, 1, 1, 1);
// Draws the texture as a 9 slice.
drawNineSlicedTexture(context, x, y, width, height, sourceX, 0, 6, 6, 12, 12, 52, 50);
// Undo previous render system changes.
- if (!isHeader) RenderSystem.disableBlend();
- RenderSystem.setShaderColor(1, 1, 1, 1);
+// if (!isHeader) RenderSystem.disableBlend(); // TODO - Figure out if a fix is needed
+// RenderSystem.setShaderColor(1, 1, 1, 1);
}
public void drawNineSlicedTexture(OwoUIDrawContext context, int x, int y, int width, int height, int sourceX, int sourceY, int sideWidth, int sideHeight, int centerWidth, int centerHeight, int textureWidth, int textureHeight) {
@@ -59,7 +60,7 @@ public void drawNineSlicedTexture(OwoUIDrawContext context, int x, int y, int wi
}
public void drawTexture(OwoUIDrawContext context, int x, int y, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int textureWidth, int textureHeight) {
- context.drawTexture(RenderLayer::getGuiTexturedOverlay, Identifier.of("quickmenu", "textures/switcher_textures.png"), x, y, sourceX, sourceY, sourceWidth, sourceHeight, textureWidth, textureHeight);
+ context.drawTexture(RenderPipelines.GUI_TEXTURED, Identifier.of("quickmenu", "textures/switcher_textures.png"), x, y, sourceX, sourceY, sourceWidth, sourceHeight, textureWidth, textureHeight);
}
public void drawRepeatingTexture(OwoUIDrawContext context, int x, int y, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int textureWidth, int textureHeight, int width, int height) {
diff --git a/src/main/resources/assets/quickmenu/lang/en_us.json b/src/main/resources/assets/quickmenu/lang/en_us.json
index 6028a85..fe0fa58 100644
--- a/src/main/resources/assets/quickmenu/lang/en_us.json
+++ b/src/main/resources/assets/quickmenu/lang/en_us.json
@@ -1,5 +1,5 @@
{
- "key.category.quickmenu": "Quick Menu",
+ "key.category.quickmenu.all": "Quick Menu",
"key.quickmenu.open": "Open Menu",
diff --git a/src/main/resources/assets/quickmenu/lang/zh_cn.json b/src/main/resources/assets/quickmenu/lang/zh_cn.json
index 9469edf..4084384 100644
--- a/src/main/resources/assets/quickmenu/lang/zh_cn.json
+++ b/src/main/resources/assets/quickmenu/lang/zh_cn.json
@@ -1,5 +1,5 @@
{
- "key.category.quickmenu": "快捷菜单",
+ "key.category.quickmenu.all": "快捷菜单",
"key.quickmenu.open": "打开菜单",
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 8c4e37b..6b3aa97 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -29,10 +29,11 @@
"quickmenu.mixins.json"
],
"depends": {
- "fabricloader": ">=0.16.10",
- "minecraft": "=1.21.4",
+ "fabricloader": ">=0.17.2",
+ "minecraft": ["1.21.9","1.21.10"],
"java": ">=21",
"fabric-api": "*",
+ "owo-lib": ">=0.12.22+1.21.9",
"fabric-key-binding-api-v1": "*"
}