Semi Fixed Dimteleport command.
This commit is contained in:
parent
61a96abbeb
commit
3011e58caf
2 changed files with 85 additions and 25 deletions
|
@ -1,13 +1,28 @@
|
||||||
package org.dimdev.dimdoors;
|
package org.dimdev.dimdoors;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.FloatArgumentType;
|
||||||
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||||
|
import net.minecraft.command.arguments.CoordinateArgument;
|
||||||
|
import net.minecraft.command.arguments.DimensionArgumentType;
|
||||||
|
import net.minecraft.command.arguments.RotationArgumentType;
|
||||||
|
import net.minecraft.command.arguments.Vec3ArgumentType;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.server.command.CommandManager;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import org.dimdev.dimdoors.block.ModBlocks;
|
import org.dimdev.dimdoors.block.ModBlocks;
|
||||||
|
import org.dimdev.dimdoors.commands.CommandDimTeleport;
|
||||||
import org.dimdev.dimdoors.entity.ModEntityTypes;
|
import org.dimdev.dimdoors.entity.ModEntityTypes;
|
||||||
import org.dimdev.dimdoors.item.ModItems;
|
import org.dimdev.dimdoors.item.ModItems;
|
||||||
import org.dimdev.dimdoors.pockets.SchematicHandler;
|
import org.dimdev.dimdoors.pockets.SchematicHandler;
|
||||||
import org.dimdev.dimdoors.rift.targets.*;
|
import org.dimdev.dimdoors.rift.targets.*;
|
||||||
import org.dimdev.dimdoors.world.ModBiomes;
|
import org.dimdev.dimdoors.world.ModBiomes;
|
||||||
import org.dimdev.dimdoors.world.ModDimensions;
|
import org.dimdev.dimdoors.world.ModDimensions;
|
||||||
|
import org.dimdev.util.TeleportUtil;
|
||||||
|
|
||||||
public class DimensionalDoorsInitializer implements ModInitializer {
|
public class DimensionalDoorsInitializer implements ModInitializer {
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,6 +33,8 @@ public class DimensionalDoorsInitializer implements ModInitializer {
|
||||||
ModEntityTypes.init();
|
ModEntityTypes.init();
|
||||||
ModBiomes.init();
|
ModBiomes.init();
|
||||||
|
|
||||||
|
registerCommands();
|
||||||
|
|
||||||
VirtualTarget.registry.put("available_link", RandomTarget.class);
|
VirtualTarget.registry.put("available_link", RandomTarget.class);
|
||||||
VirtualTarget.registry.put("escape", EscapeTarget.class);
|
VirtualTarget.registry.put("escape", EscapeTarget.class);
|
||||||
VirtualTarget.registry.put("global", GlobalReference.class);
|
VirtualTarget.registry.put("global", GlobalReference.class);
|
||||||
|
@ -34,4 +51,9 @@ public class DimensionalDoorsInitializer implements ModInitializer {
|
||||||
|
|
||||||
SchematicHandler.INSTANCE.loadSchematics();
|
SchematicHandler.INSTANCE.loadSchematics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerCommands() {
|
||||||
|
CommandRegistry.INSTANCE.register(false, CommandDimTeleport::register);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,66 @@
|
||||||
//package org.dimdev.dimdoors.commands;
|
package org.dimdev.dimdoors.commands;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.mojang.brigadier.Command;
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.FloatArgumentType;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import com.mojang.datafixers.types.JsonOps;
|
||||||
|
import net.minecraft.command.arguments.*;
|
||||||
|
import net.minecraft.command.suggestion.SuggestionProviders;
|
||||||
|
import net.minecraft.datafixer.NbtOps;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.server.command.CommandManager;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.sound.SoundCategory;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
|
import org.dimdev.util.TeleportUtil;
|
||||||
|
|
||||||
|
public class CommandDimTeleport {
|
||||||
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
|
dispatcher.register(CommandManager.literal("dimteleport")
|
||||||
|
.then(CommandManager
|
||||||
|
.argument("dimension", DimensionArgumentType.dimension())
|
||||||
|
.executes(ctx -> {
|
||||||
|
ServerPlayerEntity player = ctx.getSource().getPlayer();
|
||||||
|
return teleport(player, DimensionArgumentType.getDimensionArgument(ctx, "dimension"), player.getPos(), player.getYaw(1.0f));
|
||||||
|
}))
|
||||||
|
.then(CommandManager
|
||||||
|
.argument("coordinates", Vec3ArgumentType.vec3())
|
||||||
|
.executes(ctx -> {
|
||||||
|
ServerPlayerEntity player = ctx.getSource().getPlayer();
|
||||||
|
return teleport(player, DimensionArgumentType.getDimensionArgument(ctx, "dimension"), Vec3ArgumentType.getVec3(ctx, "coordinates"), player.getYaw(1.0f));
|
||||||
|
}))
|
||||||
|
.then(CommandManager
|
||||||
|
.argument("yaw", FloatArgumentType.floatArg())
|
||||||
|
.executes(ctx -> teleport(ctx.getSource().getPlayer(), DimensionArgumentType.getDimensionArgument(ctx, "dimension"), Vec3ArgumentType.getVec3(ctx, "coordinates"), FloatArgumentType.getFloat(ctx, "yaw")))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
|
||||||
|
NbtOps nbtOps = NbtOps.INSTANCE;
|
||||||
|
JsonOps jsonOps = JsonOps.INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int teleport(ServerPlayerEntity player, DimensionType dimension, Vec3d coordinates, float yaw) {
|
||||||
|
try {
|
||||||
|
TeleportUtil.teleport(player, dimension, coordinates, yaw);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
//import net.minecraft.command.CommandBase;
|
// @Override1
|
||||||
//import net.minecraft.command.CommandException;
|
|
||||||
//import net.minecraft.command.ICommandSender;
|
|
||||||
//import net.minecraft.command.WrongUsageException;
|
|
||||||
//import net.minecraft.command.arguments.CoordinateArgument;
|
|
||||||
//import net.minecraft.command.arguments.CoordinateArgumentument;
|
|
||||||
//import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
//import net.minecraft.server.MinecraftServer;
|
|
||||||
//import net.minecraft.util.math.BlockPos;
|
|
||||||
//import net.minecraft.util.math.Vec3d;
|
|
||||||
//import net.minecraftforge.common.DimensionManager;
|
|
||||||
//import org.dimdev.util.Location;
|
|
||||||
//import org.dimdev.util.TeleportUtil;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//import java.util.Arrays;
|
|
||||||
//import java.util.Collections;
|
|
||||||
//import java.util.List;
|
|
||||||
//import java.util.stream.Collectors;
|
|
||||||
//
|
|
||||||
//public class CommandDimTeleport extends CommandBase {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String getName() {
|
// public String getName() {
|
||||||
// return "dimteleport";
|
// return "dimteleport";
|
||||||
// }
|
// }
|
||||||
|
@ -70,4 +108,4 @@
|
||||||
// return args.length > 1 && args.length <= 4 ? getTabCompletionCoordinate(args, 1, targetPos) : Collections.emptyList();
|
// return args.length > 1 && args.length <= 4 ? getTabCompletionCoordinate(args, 1, targetPos) : Collections.emptyList();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//}
|
}
|
||||||
|
|
Loading…
Reference in a new issue