Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'fabric-loom' version '1.11-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -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' }
}
Expand Down
14 changes: 8 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.8
yarn_mappings=1.21.8+build.1
loader_version=0.17.2

# Fabric API
fabric_version=0.115.1+1.21.4
fabric_version=0.128.2+1.21.7

# Mod Properties
mod_version=1.2.6
mod_version=1.2.8
maven_group=xyz.imcodist.quickmenu
archives_base_name=quick-menu

# owo-lib
owo_version=0.12.20+1.21.4
owo_version=0.12.22+1.21.8
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
27 changes: 17 additions & 10 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -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/.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -130,26 +134,29 @@ 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.
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
case $MAX_FD in #(
'' | 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
Expand Down Expand Up @@ -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" \
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##########################################################################
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/xyz/imcodist/quickmenu/QuickMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
63 changes: 61 additions & 2 deletions src/main/java/xyz/imcodist/quickmenu/data/ActionButtonData.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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;
Expand All @@ -34,6 +36,10 @@ public ActionButtonDataJSON toJSON() {
jsonData.keybind = keybind;

actions.forEach((action) -> {
if(action == null)
{
return;
}
ArrayList<String> actionArray = new ArrayList<>();
actionArray.add(action.getJsonType());
actionArray.add(action.getJsonValue());
Expand Down Expand Up @@ -67,7 +73,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) {
Expand Down Expand Up @@ -95,6 +103,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;
Expand All @@ -119,9 +132,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<BaseActionData> actions;
private long delay;

public ActionButtonDataContext(
List<BaseActionData> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ public String getString() {
return "uh oh why are you seeing this";
}

public void run() {}
public long run() {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -44,5 +44,6 @@ public void run() {
player.networkHandler.sendChatMessage(commandToRun);
}
}
return 0;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public String getString() {
}

@Override
public void run() {
public long run() {
KeybindHandler.pressKey(keybindTranslationKey);
return 0;
}
}
Loading