Commands (update 3 of 20)

This commit is contained in:
SD 2021-02-11 22:17:51 +05:30
parent fe1e12e571
commit 95d618af64
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5
2 changed files with 9 additions and 8 deletions

View file

@ -1,9 +1,12 @@
package org.dimdev.dimdoors.command;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import org.dimdev.dimdoors.util.TeleportUtil;
import net.minecraft.command.argument.DimensionArgumentType;
import net.minecraft.command.argument.Vec3ArgumentType;
import net.minecraft.entity.Entity;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
@ -16,8 +19,7 @@ public class DimTeleportCommand {
.then(CommandManager
.argument("dimension", DimensionArgumentType.dimension())
.executes(ctx -> {
ServerPlayerEntity player = ctx.getSource().getPlayer();
return teleport(player, DimensionArgumentType.getDimensionArgument(ctx, "dimension"), player.getPos());
return teleport(ctx.getSource().getEntity(), DimensionArgumentType.getDimensionArgument(ctx, "dimension"), ctx.getSource().getPosition());
})
.then(CommandManager
.argument("coordinates", Vec3ArgumentType.vec3())
@ -30,9 +32,8 @@ public class DimTeleportCommand {
);
}
private static int teleport(ServerPlayerEntity player, ServerWorld dimension, Vec3d pos) {
player.moveToWorld(dimension);
player.setPos(pos.x, pos.y, pos.z);
return 1;
private static int teleport(Entity entity, ServerWorld dimension, Vec3d pos) {
TeleportUtil.teleport(entity, dimension, pos, 0);
return Command.SINGLE_SUCCESS;
}
}
}

View file

@ -54,7 +54,7 @@ public class PocketCommand {
return 1;
}
public static void pocket(String group, String name, boolean setup, ServerPlayerEntity player) {
private static void pocket(String group, String name, boolean setup, ServerPlayerEntity player) {
try {
PocketTemplate template = SchematicHandler.INSTANCE.getTemplate(group, name);