Skip to content

Commit

Permalink
Add border command to Forge
Browse files Browse the repository at this point in the history
  • Loading branch information
pop4959 committed Feb 13, 2024
1 parent 324f042 commit 87a13cf
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions forge/src/main/java/org/popcraft/chunky/ChunkyForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static net.minecraft.commands.Commands.argument;
import static net.minecraft.commands.Commands.literal;
import static net.minecraft.commands.arguments.DimensionArgument.dimension;
import static net.minecraft.commands.arguments.EntityArgument.player;

@Mod(ChunkyForge.MOD_ID)
public class ChunkyForge {
Expand Down Expand Up @@ -139,6 +140,27 @@ public void onRegisterCommands(final RegisterCommandsEvent event) {
registerArguments(command, literal(CommandLiteral.WORLDBORDER));
registerArguments(command, literal(CommandLiteral.WORLD),
argument(CommandLiteral.WORLD, dimension()));
final LiteralArgumentBuilder<CommandSourceStack> borderCommand = literal(CommandLiteral.BORDER)
.requires(serverCommandSource -> chunky != null && chunky.getCommands().containsKey(CommandLiteral.BORDER))
.executes(command.getCommand());
registerArguments(borderCommand, literal(CommandLiteral.ADD),
argument(CommandLiteral.WORLD, dimension()),
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES),
argument(CommandLiteral.CENTER_X, word()),
argument(CommandLiteral.CENTER_Z, word()),
argument(CommandLiteral.RADIUS_X, word()),
argument(CommandLiteral.RADIUS_Z, word()));
registerArguments(borderCommand, literal(CommandLiteral.BYPASS),
argument(CommandLiteral.PLAYER, player()));
registerArguments(borderCommand, literal(CommandLiteral.HELP));
registerArguments(borderCommand, literal(CommandLiteral.LIST));
registerArguments(borderCommand, literal(CommandLiteral.LOAD),
argument(CommandLiteral.WORLD, dimension()));
registerArguments(borderCommand, literal(CommandLiteral.REMOVE),
argument(CommandLiteral.WORLD, dimension()));
registerArguments(borderCommand, literal(CommandLiteral.WRAP),
argument(CommandLiteral.WRAP, word()));
registerArguments(command, borderCommand);
event.getDispatcher().register(command);
}

Expand Down
22 changes: 22 additions & 0 deletions neoforge/src/main/java/org/popcraft/chunky/ChunkyNeoForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static net.minecraft.commands.Commands.argument;
import static net.minecraft.commands.Commands.literal;
import static net.minecraft.commands.arguments.DimensionArgument.dimension;
import static net.minecraft.commands.arguments.EntityArgument.player;

@Mod(ChunkyNeoForge.MOD_ID)
public class ChunkyNeoForge {
Expand Down Expand Up @@ -139,6 +140,27 @@ public void onRegisterCommands(final RegisterCommandsEvent event) {
registerArguments(command, literal(CommandLiteral.WORLDBORDER));
registerArguments(command, literal(CommandLiteral.WORLD),
argument(CommandLiteral.WORLD, dimension()));
final LiteralArgumentBuilder<CommandSourceStack> borderCommand = literal(CommandLiteral.BORDER)
.requires(serverCommandSource -> chunky != null && chunky.getCommands().containsKey(CommandLiteral.BORDER))
.executes(command.getCommand());
registerArguments(borderCommand, literal(CommandLiteral.ADD),
argument(CommandLiteral.WORLD, dimension()),
argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES),
argument(CommandLiteral.CENTER_X, word()),
argument(CommandLiteral.CENTER_Z, word()),
argument(CommandLiteral.RADIUS_X, word()),
argument(CommandLiteral.RADIUS_Z, word()));
registerArguments(borderCommand, literal(CommandLiteral.BYPASS),
argument(CommandLiteral.PLAYER, player()));
registerArguments(borderCommand, literal(CommandLiteral.HELP));
registerArguments(borderCommand, literal(CommandLiteral.LIST));
registerArguments(borderCommand, literal(CommandLiteral.LOAD),
argument(CommandLiteral.WORLD, dimension()));
registerArguments(borderCommand, literal(CommandLiteral.REMOVE),
argument(CommandLiteral.WORLD, dimension()));
registerArguments(borderCommand, literal(CommandLiteral.WRAP),
argument(CommandLiteral.WRAP, word()));
registerArguments(command, borderCommand);
event.getDispatcher().register(command);
}

Expand Down

0 comments on commit 87a13cf

Please sign in to comment.