diff --git a/common/src/main/java/dev/boxadactle/macrocraft/MacroCraft.java b/common/src/main/java/dev/boxadactle/macrocraft/MacroCraft.java index ee136ad..0b9a16b 100644 --- a/common/src/main/java/dev/boxadactle/macrocraft/MacroCraft.java +++ b/common/src/main/java/dev/boxadactle/macrocraft/MacroCraft.java @@ -1,8 +1,10 @@ package dev.boxadactle.macrocraft; +import dev.boxadactle.boxlib.command.BCommandManager; import dev.boxadactle.boxlib.config.BConfigClass; import dev.boxadactle.boxlib.config.BConfigHandler; import dev.boxadactle.boxlib.util.ModLogger; +import dev.boxadactle.macrocraft.command.MacroCommand; import dev.boxadactle.macrocraft.config.MacroCraftConfig; import dev.boxadactle.macrocraft.fs.MacroFile; import dev.boxadactle.macrocraft.macro.MacroState; @@ -17,7 +19,7 @@ public class MacroCraft { public static final String MOD_NAME = "MacroCraft"; public static final String MOD_ID = "macrocraft"; - public static final String VERSION = "3.0.0"; + public static final String VERSION = "4.1.0"; public static final String VERSION_STRING = MOD_NAME + " v" + VERSION; public static final ModLogger LOGGER = new ModLogger(MOD_NAME); @@ -32,6 +34,9 @@ public static void init() { LOGGER.info("Loading configuration..."); CONFIG = BConfigHandler.registerConfig(MacroCraftConfig.class); + + LOGGER.info("Registering client commands..."); + BCommandManager.register(MacroCommand.create()); } public static String formatDate(long timestamp) { diff --git a/common/src/main/java/dev/boxadactle/macrocraft/command/MacroCommand.java b/common/src/main/java/dev/boxadactle/macrocraft/command/MacroCommand.java new file mode 100644 index 0000000..568cfbf --- /dev/null +++ b/common/src/main/java/dev/boxadactle/macrocraft/command/MacroCommand.java @@ -0,0 +1,35 @@ +package dev.boxadactle.macrocraft.command; + +import com.mojang.brigadier.context.CommandContext; +import dev.boxadactle.boxlib.command.BCommandSourceStack; +import dev.boxadactle.boxlib.command.api.BClientCommand; +import dev.boxadactle.boxlib.scheduling.Scheduling; +import dev.boxadactle.boxlib.util.ClientUtils; +import dev.boxadactle.macrocraft.config.MacroCraftConfigScreen; +import dev.boxadactle.macrocraft.gui.MacroListScreen; + +public class MacroCommand { + + public static BClientCommand create() { + return BClientCommand.create("macro", MacroCommand::openList) + .registerSubcommand("config", MacroCommand::openConfig) + .registerSubcommand(new PlaySubcommand()) + .registerSubcommand(new RecordSubcommand()) + .registerSubcommand(new SaveSubcommand()); + } + + public static int openList(CommandContext ignored) { + // we have to delay because when the command is run it sets the screen to null + Scheduling.schedule(1, () -> ClientUtils.setScreen(new MacroListScreen(null))); + + return 0; + + } + + public static int openConfig(CommandContext ignored) { + Scheduling.schedule(1, () -> ClientUtils.setScreen(new MacroCraftConfigScreen(null))); + + return 0; + } + +} diff --git a/common/src/main/java/dev/boxadactle/macrocraft/command/PlaySubcommand.java b/common/src/main/java/dev/boxadactle/macrocraft/command/PlaySubcommand.java new file mode 100644 index 0000000..35fe6a4 --- /dev/null +++ b/common/src/main/java/dev/boxadactle/macrocraft/command/PlaySubcommand.java @@ -0,0 +1,43 @@ +package dev.boxadactle.macrocraft.command; + +import com.mojang.brigadier.builder.ArgumentBuilder; +import com.mojang.brigadier.context.CommandContext; +import dev.boxadactle.boxlib.command.BCommandManager; +import dev.boxadactle.boxlib.command.BCommandSourceStack; +import dev.boxadactle.boxlib.command.api.BClientSubcommand; +import dev.boxadactle.boxlib.scheduling.Scheduling; +import dev.boxadactle.boxlib.util.ClientUtils; +import dev.boxadactle.macrocraft.MacroCraft; +import dev.boxadactle.macrocraft.gui.MacroPlayScreen; +import dev.boxadactle.macrocraft.macro.MacroState; +import net.minecraft.network.chat.Component; + +public class PlaySubcommand implements BClientSubcommand { + + @Override + public ArgumentBuilder getSubcommand() { + return BCommandManager.literal("play").executes(this::onPlayCommand); + } + + @Override + public void build(ArgumentBuilder builder) { + builder.then(BCommandManager.literal("gui").executes(this::openPlayGui)); + } + + private int onPlayCommand(CommandContext ignored) { + if (!MacroState.hasLoadedMacro()) { + MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.notLoaded")); + return 0; + } + + MacroState.LOADED_MACRO.playMacro(); + + return 0; + } + + private int openPlayGui(CommandContext ignored) { + Scheduling.schedule(1, () -> ClientUtils.setScreen(new MacroPlayScreen(null))); + + return 0; + } +} diff --git a/common/src/main/java/dev/boxadactle/macrocraft/command/RecordSubcommand.java b/common/src/main/java/dev/boxadactle/macrocraft/command/RecordSubcommand.java new file mode 100644 index 0000000..5993629 --- /dev/null +++ b/common/src/main/java/dev/boxadactle/macrocraft/command/RecordSubcommand.java @@ -0,0 +1,79 @@ +package dev.boxadactle.macrocraft.command; + +import com.mojang.brigadier.builder.ArgumentBuilder; +import com.mojang.brigadier.context.CommandContext; +import dev.boxadactle.boxlib.command.BCommandManager; +import dev.boxadactle.boxlib.command.BCommandSourceStack; +import dev.boxadactle.boxlib.command.api.BClientSubcommand; +import dev.boxadactle.boxlib.scheduling.Scheduling; +import dev.boxadactle.boxlib.util.ClientUtils; +import dev.boxadactle.macrocraft.MacroCraft; +import dev.boxadactle.macrocraft.gui.MacroRecordScreen; +import dev.boxadactle.macrocraft.macro.MacroState; +import net.minecraft.network.chat.Component; + +public class RecordSubcommand implements BClientSubcommand { + @Override + public ArgumentBuilder getSubcommand() { + return BCommandManager.literal("record").executes(this::onRecordCommand); + } + + @Override + public void build(ArgumentBuilder builder) { + builder.then(BCommandManager.literal("start").executes(this::onStartRecord)); + + builder.then(BCommandManager.literal("stop").executes(this::onStopRecord)); + + builder.then(BCommandManager.literal("pause").executes(this::onPauseRecord)); + } + + private int onRecordCommand(CommandContext ignored) { + Scheduling.schedule(1, () -> ClientUtils.setScreen(new MacroRecordScreen(null))); + + return 0; + } + + private int onStartRecord(CommandContext ignored) { + if (MacroState.IS_RECORDING) { + MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.recording.already")); + + return 1; + } + + if (MacroState.IS_PAUSED) { + MacroState.resumeRecording(); + + return 0; + } + + MacroState.startRecording(); + + MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.recording.started")); + + return 0; + } + + private int onStopRecord(CommandContext ignored) { + if (!MacroState.IS_RECORDING) { + MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.recording.not")); + + return 1; + } + + MacroState.stopRecording(); + + return 0; + } + + private int onPauseRecord(CommandContext ignored) { + if (!MacroState.IS_RECORDING) { + MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.recording.not")); + + return 1; + } + + MacroState.pauseRecording(); + + return 0; + } +} diff --git a/common/src/main/java/dev/boxadactle/macrocraft/command/SaveSubcommand.java b/common/src/main/java/dev/boxadactle/macrocraft/command/SaveSubcommand.java new file mode 100644 index 0000000..a6c810a --- /dev/null +++ b/common/src/main/java/dev/boxadactle/macrocraft/command/SaveSubcommand.java @@ -0,0 +1,67 @@ +package dev.boxadactle.macrocraft.command; + +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.builder.ArgumentBuilder; +import com.mojang.brigadier.context.CommandContext; +import dev.boxadactle.boxlib.command.BCommandManager; +import dev.boxadactle.boxlib.command.BCommandSourceStack; +import dev.boxadactle.boxlib.command.api.BClientSubcommand; +import dev.boxadactle.boxlib.scheduling.Scheduling; +import dev.boxadactle.boxlib.util.ClientUtils; +import dev.boxadactle.macrocraft.MacroCraft; +import dev.boxadactle.macrocraft.fs.MacroFile; +import dev.boxadactle.macrocraft.gui.MacroSaveScreen; +import dev.boxadactle.macrocraft.macro.MacroState; +import net.minecraft.network.chat.Component; + +public class SaveSubcommand implements BClientSubcommand { + @Override + public ArgumentBuilder getSubcommand() { + return BCommandManager.literal("save").executes(this::save); + } + + @Override + public void build(ArgumentBuilder builder) { + builder.then( + BCommandManager.argument("filename", StringArgumentType.string()) + .executes(this::saveFile) + ); + } + + private int save(CommandContext ignored) { + if (MacroState.LOADED_MACRO == null) { + MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.notLoaded")); + + return 1; + } + + Scheduling.schedule(1, () -> ClientUtils.setScreen(new MacroSaveScreen(null))); + + return 0; + } + + private int saveFile(CommandContext context) { + if (!MacroState.hasLoadedMacro()) { + MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.notLoaded")); + return 1; + } + + String filename = StringArgumentType.getString(context, "filename"); + + if (filename.isBlank()) { + return save(context); + } + + if (!filename.endsWith(MacroFile.MACRO_EXTENSION)) { + filename += MacroFile.MACRO_EXTENSION; + } + + MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.saving")); + + MacroFile.saveMacro(filename, MacroState.LOADED_MACRO); + + MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.saved", filename)); + + return 0; + } +} diff --git a/common/src/main/resources/assets/macrocraft/lang/en_us.json b/common/src/main/resources/assets/macrocraft/lang/en_us.json index f774109..c39e57e 100644 --- a/common/src/main/resources/assets/macrocraft/lang/en_us.json +++ b/common/src/main/resources/assets/macrocraft/lang/en_us.json @@ -104,5 +104,7 @@ "command.macrocraft.recording.already": "You are already recording a macro", "command.macrocraft.recording.not": "You are not recording a macro", "command.macrocraft.recording.started": "Recording macro...", - "command.macrocraft.notLoaded": "No macro is loaded!" + "command.macrocraft.notLoaded": "No macro is loaded!", + "command.macrocraft.saving": "Saving macro...", + "command.macrocraft.saved": "Macro saved as \"%s\"" } \ No newline at end of file diff --git a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/MacroCraftFabric.java b/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/MacroCraftFabric.java index 03fcea9..16c2bce 100644 --- a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/MacroCraftFabric.java +++ b/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/MacroCraftFabric.java @@ -1,12 +1,7 @@ package dev.boxadactle.macrocraft.fabric; -import dev.boxadactle.boxlib.fabric.command.BCommandManager; import dev.boxadactle.macrocraft.MacroCraft; import dev.boxadactle.macrocraft.MacroCraftKeybinds; -import dev.boxadactle.macrocraft.fabric.command.ConfigCommand; -import dev.boxadactle.macrocraft.fabric.command.PlayCommand; -import dev.boxadactle.macrocraft.fabric.command.RecordCommand; -import dev.boxadactle.macrocraft.fabric.command.SaveCommand; import dev.boxadactle.macrocraft.gui.MacroListScreen; import dev.boxadactle.macrocraft.hud.MacroPlayHud; import dev.boxadactle.macrocraft.hud.MacroRecordHud; @@ -28,7 +23,6 @@ public void onInitialize() { HudRenderCallback.EVENT.register(this::renderMacroHud); initKeybinds(); - initCommands(); } private void initKeybinds() { @@ -39,15 +33,6 @@ private void initKeybinds() { KeyBindingHelper.registerKeyBinding(MacroCraftKeybinds.openMacroList); } - private void initCommands() { - BCommandManager.registerCommand("macro", (list) -> { - list.add(ConfigCommand::new); - list.add(PlayCommand::new); - list.add(RecordCommand::new); - list.add(SaveCommand::new); - }); - } - private void tick(Minecraft client) { MacroState.tick(); diff --git a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/MacrocraftCommand.java b/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/MacrocraftCommand.java deleted file mode 100644 index f363b05..0000000 --- a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/MacrocraftCommand.java +++ /dev/null @@ -1,20 +0,0 @@ -package dev.boxadactle.macrocraft.fabric; - -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.fabric.command.BClientCommand; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.gui.MacroListScreen; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; - -public abstract class MacrocraftCommand extends BClientCommand { - @Override - public String getCommandName() { - return "macro"; - } - - @Override - protected int onRootCommand(CommandContext context) { - ClientUtils.setScreen(new MacroListScreen(null)); - return 0; - } -} diff --git a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/ConfigCommand.java b/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/ConfigCommand.java deleted file mode 100644 index 52478f6..0000000 --- a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/ConfigCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package dev.boxadactle.macrocraft.fabric.command; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.config.MacroCraftConfigScreen; -import dev.boxadactle.macrocraft.fabric.MacrocraftCommand; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; - -public class ConfigCommand extends MacrocraftCommand { - @Override - public String getName() { - return "config"; - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.executes(this::openConfig); - } - - private int openConfig(CommandContext source) { - ClientUtils.setScreen(new MacroCraftConfigScreen(null)); - - return 0; - } -} diff --git a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/PlayCommand.java b/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/PlayCommand.java deleted file mode 100644 index 4a69ca0..0000000 --- a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/PlayCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package dev.boxadactle.macrocraft.fabric.command; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.fabric.MacrocraftCommand; -import dev.boxadactle.macrocraft.gui.MacroPlayScreen; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; - -public class PlayCommand extends MacrocraftCommand { - @Override - public String getName() { - return "play"; - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.executes(this::onPlayCommand); - } - - private int onPlayCommand(CommandContext context) { - ClientUtils.setScreen(new MacroPlayScreen(null)); - - return 0; - } -} diff --git a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/RecordCommand.java b/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/RecordCommand.java deleted file mode 100644 index 13ef222..0000000 --- a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/RecordCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -package dev.boxadactle.macrocraft.fabric.command; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.fabric.MacrocraftCommand; -import dev.boxadactle.macrocraft.gui.MacroRecordScreen; -import dev.boxadactle.macrocraft.macro.MacroState; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.network.chat.Component; - -public class RecordCommand extends MacrocraftCommand { - @Override - public String getName() { - return "record"; - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.executes(this::onRecordCommand); - - builder.then(ClientCommandManager.literal("start").executes(this::onStartRecord)); - - builder.then(ClientCommandManager.literal("stop").executes(this::onStopRecord)); - - builder.then(ClientCommandManager.literal("pause").executes(this::onPauseRecord)); - } - - private int onRecordCommand(CommandContext context) { - ClientUtils.setScreen(new MacroRecordScreen(null)); - - return 0; - } - - private int onStartRecord(CommandContext context) { - if (MacroState.IS_RECORDING) { - sendFeedback(Component.translatable("command.macrocraft.recording.already")); - - return 1; - } - - if (MacroState.IS_PAUSED) { - MacroState.resumeRecording(); - - return 0; - } - - MacroState.startRecording(); - - sendFeedback(Component.translatable("command.macrocraft.recording.started")); - - return 0; - } - - private int onStopRecord(CommandContext context) { - if (!MacroState.IS_RECORDING) { - sendFeedback(Component.translatable("command.macrocraft.recording.not")); - - return 1; - } - - MacroState.stopRecording(); - - return 0; - } - - private int onPauseRecord(CommandContext context) { - if (!MacroState.IS_RECORDING) { - sendFeedback(Component.translatable("command.macrocraft.recording.not")); - - return 1; - } - - MacroState.pauseRecording(); - - return 0; - } -} diff --git a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/SaveCommand.java b/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/SaveCommand.java deleted file mode 100644 index d8610bf..0000000 --- a/fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/SaveCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package dev.boxadactle.macrocraft.fabric.command; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.fabric.MacrocraftCommand; -import dev.boxadactle.macrocraft.gui.MacroSaveScreen; -import dev.boxadactle.macrocraft.macro.MacroState; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.network.chat.Component; - -public class SaveCommand extends MacrocraftCommand { - @Override - public String getName() { - return "save"; - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.executes(this::save); - } - - private int save(CommandContext context) { - if (MacroState.LOADED_MACRO == null) { - sendFeedback(Component.translatable("command.macrocraft.notLoaded")); - - return 1; - } - - ClientUtils.setScreen(new MacroSaveScreen(null)); - - return 0; - } -} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 0fa0949..59272da 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -26,6 +26,6 @@ "depends": { "fabricloader": ">=0.14", "minecraft": ">=1.20.5", - "boxlib": ">=13.0.0" + "boxlib": ">=13.1.0" } } diff --git a/gradle.properties b/gradle.properties index 9256602..4aabedc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true # Mod properties -mod_version = 4.0.0 +mod_version = 4.1.0 maven_group = dev.boxadactle archives_name = macrocraft enabled_platforms = fabric,neoforge @@ -16,7 +16,7 @@ fabric_loader_version = 0.15.11 fabric_api_version = 0.97.8+1.20.6 neoforge_version = 20.6.57-beta -boxlib_version=13.0.2 +boxlib_version=13.1.0 modmenu_version=10.0.0-beta.1 # publishing diff --git a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacroCraftEvents.java b/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacroCraftEvents.java index 1ae5be1..fef3aea 100644 --- a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacroCraftEvents.java +++ b/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacroCraftEvents.java @@ -20,7 +20,7 @@ public class MacroCraftEvents { @SubscribeEvent - public static void onClientTick(ClientTickEvent ignored) { + public static void onClientTick(ClientTickEvent.Pre ignored) { MacroState.tick(); } diff --git a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacroCraftNeoforge.java b/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacroCraftNeoforge.java index 97e182b..a8de0a7 100644 --- a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacroCraftNeoforge.java +++ b/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacroCraftNeoforge.java @@ -1,12 +1,7 @@ package dev.boxadactle.macrocraft.neoforge; -import dev.boxadactle.boxlib.neoforge.command.BCommandManager; import dev.boxadactle.macrocraft.MacroCraft; import dev.boxadactle.macrocraft.config.MacroCraftConfigScreen; -import dev.boxadactle.macrocraft.neoforge.command.ConfigCommand; -import dev.boxadactle.macrocraft.neoforge.command.PlayCommand; -import dev.boxadactle.macrocraft.neoforge.command.RecordCommand; -import dev.boxadactle.macrocraft.neoforge.command.SaveCommand; import net.neoforged.fml.ModLoadingContext; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.client.gui.IConfigScreenFactory; @@ -16,13 +11,6 @@ public class MacroCraftNeoforge { public MacroCraftNeoforge() { MacroCraft.init(); - BCommandManager.registerCommand("macro", list -> { - list.add(ConfigCommand::new); - list.add(PlayCommand::new); - list.add(RecordCommand::new); - list.add(SaveCommand::new); - }); - ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, () -> ((minecraft, screen) -> new MacroCraftConfigScreen(screen)) ); diff --git a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacrocraftCommand.java b/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacrocraftCommand.java deleted file mode 100644 index a5d70de..0000000 --- a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/MacrocraftCommand.java +++ /dev/null @@ -1,20 +0,0 @@ -package dev.boxadactle.macrocraft.neoforge; - -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.neoforge.command.BClientCommand; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.gui.MacroListScreen; -import net.minecraft.commands.CommandSourceStack; - -public abstract class MacrocraftCommand extends BClientCommand { - @Override - public String getCommandName() { - return "macro"; - } - - @Override - protected int onRootCommand(CommandContext context) { - ClientUtils.setScreen(new MacroListScreen(null)); - return 0; - } -} diff --git a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/ConfigCommand.java b/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/ConfigCommand.java deleted file mode 100644 index e751f42..0000000 --- a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/ConfigCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package dev.boxadactle.macrocraft.neoforge.command; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.config.MacroCraftConfigScreen; -import dev.boxadactle.macrocraft.neoforge.MacrocraftCommand; -import net.minecraft.commands.CommandSourceStack; - -public class ConfigCommand extends MacrocraftCommand { - @Override - public String getName() { - return "config"; - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.executes(this::openConfig); - } - - private int openConfig(CommandContext source) { - ClientUtils.setScreen(new MacroCraftConfigScreen(null)); - - return 0; - } -} diff --git a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/PlayCommand.java b/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/PlayCommand.java deleted file mode 100644 index ad0c257..0000000 --- a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/PlayCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package dev.boxadactle.macrocraft.neoforge.command; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.neoforge.MacrocraftCommand; -import dev.boxadactle.macrocraft.gui.MacroPlayScreen; -import net.minecraft.commands.CommandSourceStack; - -public class PlayCommand extends MacrocraftCommand { - @Override - public String getName() { - return "play"; - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.executes(this::onPlayCommand); - } - - private int onPlayCommand(CommandContext context) { - ClientUtils.setScreen(new MacroPlayScreen(null)); - - return 0; - } -} diff --git a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/RecordCommand.java b/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/RecordCommand.java deleted file mode 100644 index bf68837..0000000 --- a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/RecordCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -package dev.boxadactle.macrocraft.neoforge.command; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.neoforge.MacrocraftCommand; -import dev.boxadactle.macrocraft.gui.MacroRecordScreen; -import dev.boxadactle.macrocraft.macro.MacroState; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.commands.Commands; -import net.minecraft.network.chat.Component; - -public class RecordCommand extends MacrocraftCommand { - @Override - public String getName() { - return "record"; - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.executes(this::onRecordCommand); - - builder.then(Commands.literal("start").executes(this::onStartRecord)); - - builder.then(Commands.literal("stop").executes(this::onStopRecord)); - - builder.then(Commands.literal("pause").executes(this::onPauseRecord)); - } - - private int onRecordCommand(CommandContext context) { - ClientUtils.setScreen(new MacroRecordScreen(null)); - - return 0; - } - - private int onStartRecord(CommandContext context) { - if (MacroState.IS_RECORDING) { - sendFeedback(Component.translatable("command.macrocraft.recording.already")); - - return 1; - } - - if (MacroState.IS_PAUSED) { - MacroState.resumeRecording(); - - return 0; - } - - MacroState.startRecording(); - - sendFeedback(Component.translatable("command.macrocraft.recording.started")); - - return 0; - } - - private int onStopRecord(CommandContext context) { - if (!MacroState.IS_RECORDING) { - sendFeedback(Component.translatable("command.macrocraft.recording.not")); - - return 1; - } - - MacroState.stopRecording(); - - return 0; - } - - private int onPauseRecord(CommandContext context) { - if (!MacroState.IS_RECORDING) { - sendFeedback(Component.translatable("command.macrocraft.recording.not")); - - return 1; - } - - MacroState.pauseRecording(); - - return 0; - } -} diff --git a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/SaveCommand.java b/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/SaveCommand.java deleted file mode 100644 index 7350ee6..0000000 --- a/neoforge/src/main/java/dev/boxadactle/macrocraft/neoforge/command/SaveCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package dev.boxadactle.macrocraft.neoforge.command; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import dev.boxadactle.boxlib.util.ClientUtils; -import dev.boxadactle.macrocraft.neoforge.MacrocraftCommand; -import dev.boxadactle.macrocraft.gui.MacroSaveScreen; -import dev.boxadactle.macrocraft.macro.MacroState; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.network.chat.Component; - -public class SaveCommand extends MacrocraftCommand { - @Override - public String getName() { - return "save"; - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.executes(this::save); - } - - private int save(CommandContext context) { - if (MacroState.LOADED_MACRO == null) { - sendFeedback(Component.translatable("command.macrocraft.notLoaded")); - - return 1; - } - - ClientUtils.setScreen(new MacroSaveScreen(null)); - - return 0; - } -} diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index be3ce4b..0432e73 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -30,7 +30,7 @@ side = "BOTH" [[dependencies.macrocraft]] modId = "boxlib" type = "required" -versionRange = "[13.0.0, 14.0.0)" +versionRange = "[13.1.0, 14.0.0)" ordering = "NONE" side = "BOTH"