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
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<p align="center">
<img src="https://github.com/ImCodist/quick-menu/assets/50346006/e6ce7cf2-43f5-442e-bf90-8d912eb0fa58" alt="In-Game Preview"/>
</p>
<img src="https://github.com/ImCodist/quick-menu/assets/50346006/e6ce7cf2-43f5-442e-bf90-8d912eb0fa58" alt="In-Game Preview"/>

- Easy to access menu with a **keybind** *(Default: G)*
- A simple action button **editor**.
Expand Down
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.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
owo_version=0.12.24+1.21.9
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 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 All @@ -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;
Expand Down
66 changes: 63 additions & 3 deletions src/main/java/xyz/imcodist/quickmenu/data/ActionButtonData.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -34,6 +37,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 +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) {
Expand Down Expand Up @@ -95,14 +104,19 @@ 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;
}

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() {
Expand All @@ -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<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;
}
}
Loading