-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44c6e07
commit 4459b6a
Showing
22 changed files
with
238 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
common/src/main/java/dev/boxadactle/macrocraft/command/MacroCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<BCommandSourceStack> 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<BCommandSourceStack> ignored) { | ||
Scheduling.schedule(1, () -> ClientUtils.setScreen(new MacroCraftConfigScreen(null))); | ||
|
||
return 0; | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
common/src/main/java/dev/boxadactle/macrocraft/command/PlaySubcommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<BCommandSourceStack, ?> getSubcommand() { | ||
return BCommandManager.literal("play").executes(this::onPlayCommand); | ||
} | ||
|
||
@Override | ||
public void build(ArgumentBuilder<BCommandSourceStack, ?> builder) { | ||
builder.then(BCommandManager.literal("gui").executes(this::openPlayGui)); | ||
} | ||
|
||
private int onPlayCommand(CommandContext<BCommandSourceStack> 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<BCommandSourceStack> ignored) { | ||
Scheduling.schedule(1, () -> ClientUtils.setScreen(new MacroPlayScreen(null))); | ||
|
||
return 0; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
common/src/main/java/dev/boxadactle/macrocraft/command/RecordSubcommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<BCommandSourceStack, ?> getSubcommand() { | ||
return BCommandManager.literal("record").executes(this::onRecordCommand); | ||
} | ||
|
||
@Override | ||
public void build(ArgumentBuilder<BCommandSourceStack, ?> 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<BCommandSourceStack> ignored) { | ||
Scheduling.schedule(1, () -> ClientUtils.setScreen(new MacroRecordScreen(null))); | ||
|
||
return 0; | ||
} | ||
|
||
private int onStartRecord(CommandContext<BCommandSourceStack> 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<BCommandSourceStack> 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<BCommandSourceStack> ignored) { | ||
if (!MacroState.IS_RECORDING) { | ||
MacroCraft.LOGGER.player.chat(Component.translatable("command.macrocraft.recording.not")); | ||
|
||
return 1; | ||
} | ||
|
||
MacroState.pauseRecording(); | ||
|
||
return 0; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
common/src/main/java/dev/boxadactle/macrocraft/command/SaveSubcommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<BCommandSourceStack, ?> getSubcommand() { | ||
return BCommandManager.literal("save").executes(this::save); | ||
} | ||
|
||
@Override | ||
public void build(ArgumentBuilder<BCommandSourceStack, ?> builder) { | ||
builder.then( | ||
BCommandManager.argument("filename", StringArgumentType.string()) | ||
.executes(this::saveFile) | ||
); | ||
} | ||
|
||
private int save(CommandContext<BCommandSourceStack> 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<BCommandSourceStack> 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
fabric/src/main/java/dev/boxadactle/macrocraft/fabric/MacrocraftCommand.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/ConfigCommand.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
fabric/src/main/java/dev/boxadactle/macrocraft/fabric/command/PlayCommand.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.