Skip to content
This repository was archived by the owner on Sep 12, 2025. It is now read-only.

Commit b1765ee

Browse files
author
Andrei Hava
committed
teleport commands
1 parent 109a5d6 commit b1765ee

4 files changed

Lines changed: 62 additions & 63 deletions

File tree

.idea/workspace.xml

Lines changed: 40 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### 20.1.0-alpha7
2+
_Admin powers_
3+
- Code refactoring
4+
- Tweak the translations for the configuration entries
5+
- Add the `/buildersvoid` root command and its `/bv` short variant.
6+
- Add the `teleport` command and its `tp` short variant.
7+
18
### 20.1.0-alpha6
29
_Buttons and levers_
310
- Add Cloth Config as a dependency

common/src/generated/resources/assets/buildersvoid/lang/en_us.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"config.buildersvoid.cooldown": "Void Pearl Cooldown Length",
2+
"config.buildersvoid.cooldown": "Cooldown Length",
33
"config.buildersvoid.cooldown.tooltip": "Void Pearl usage cooldown length, in ticks",
4-
"config.buildersvoid.enableCooldown": "Enable Void Pearl Cooldown",
4+
"config.buildersvoid.enableCooldown": "Enable Cooldown",
55
"config.buildersvoid.enableCooldown.tooltip": "Enables a cooldown when using any of the Void Pearl variants",
66
"config.buildersvoid.title": "Builder's Void",
77
"item.buildersvoid.linked_void_pearl": "Linked Void Pearl",

common/src/main/java/dev/detpikachu/buildersvoid/command/ModCommands.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mojang.brigadier.context.CommandContext;
44
import com.mojang.brigadier.exceptions.CommandSyntaxException;
5+
import dev.detpikachu.buildersvoid.logic.TeleportLogic;
56
import net.blay09.mods.balm.api.command.BalmCommands;
67
import net.minecraft.commands.CommandSourceStack;
78
import net.minecraft.commands.Commands;
@@ -24,7 +25,7 @@ public static void initialize(BalmCommands commands) {
2425
final var teleport = Commands.literal("teleport")
2526
.requires(BalmCommands.requirePermission(PERM_TELEPORT))
2627
.then(Commands.argument("target", EntityArgument.player())
27-
.executes(ModCommands::onTeleportTarget)
28+
.executes(ModCommands::onTeleportTargetPlayer)
2829
)
2930
.then(Commands.argument("source", EntityArgument.player())
3031
.then(Commands.argument("target", EntityArgument.player())
@@ -38,21 +39,22 @@ public static void initialize(BalmCommands commands) {
3839
});
3940
}
4041

41-
private static int onTeleportTarget(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
42-
final EntitySelector target = context.getArgument("target", EntitySelector.class);
43-
44-
context.getSource().sendSystemMessage(target.findSinglePlayer(context.getSource()).getName());
42+
private static int onTeleportTargetPlayer(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
43+
final var target = context.getArgument("target", EntitySelector.class);
44+
final var sourcePlayer = context.getSource().getPlayer();
45+
final var targetPlayer = target.findSinglePlayer(context.getSource());
4546

47+
TeleportLogic.teleportIntoVoid(sourcePlayer, targetPlayer.getUUID(), false);
4648
return 0;
4749
}
4850

49-
private static int onTeleportSourceToTarget(CommandContext<CommandSourceStack> context) {
50-
final EntitySelector source = context.getArgument("source", EntitySelector.class);
51-
final EntitySelector target = context.getArgument("target", EntitySelector.class);
51+
private static int onTeleportSourceToTarget(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
52+
final var source = context.getArgument("source", EntitySelector.class);
53+
final var sourcePlayer = source.findSinglePlayer(context.getSource());
54+
final var target = context.getArgument("target", EntitySelector.class);
55+
final var targetPlayer = target.findSinglePlayer(context.getSource());
5256

57+
TeleportLogic.teleportIntoVoid(sourcePlayer, targetPlayer.getUUID(), false);
5358
return 0;
5459
}
55-
56-
private static void teleportSourceToTarget() {
57-
}
5860
}

0 commit comments

Comments
 (0)