runFillCommand

before i go to sleep
This commit is contained in:
Chayapak 2023-08-16 21:20:39 +07:00
parent 5ec6250570
commit 64fd0d1ad4
2 changed files with 27 additions and 0 deletions

View file

@ -3,6 +3,9 @@ package land.chipmunk.chipmunkmod.commands;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
@ -35,6 +38,14 @@ public class CoreCommand {
.then(literal("refill").executes(c -> refill(c)))
.then(literal("move").executes(c -> move(c)))
.then(
literal("runFillCommand")
.then(
argument("enabled", bool())
.executes(c -> runFillCommand(c))
)
)
);
}
@ -76,4 +87,16 @@ public class CoreCommand {
return Command.SINGLE_SUCCESS;
}
public static int runFillCommand(CommandContext<FabricClientCommandSource> context) {
final FabricClientCommandSource source = context.getSource();
final boolean bool = getBool(context, "enabled");
CommandCore.INSTANCE.runFillCommand = bool;
source.sendFeedback(Text.literal("Running fill commands are now " + (bool ? "enabled" : "disabled")));
return Command.SINGLE_SUCCESS;
}
}

View file

@ -26,6 +26,8 @@ public class CommandCore {
private Timer timer;
public boolean runFillCommand = true;
public static CommandCore INSTANCE = new CommandCore(MinecraftClient.getInstance(), ChipmunkMod.CONFIG.core.relativeArea);
public CommandCore (MinecraftClient client, BlockArea relativeArea) {
@ -79,6 +81,8 @@ public class CommandCore {
}
public void refill () {
if (!runFillCommand) return;
// final PositionManager position = client.position();
final BlockPos relStart = relativeArea.start;
final BlockPos relEnd = relativeArea.end;