import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import net.minecraft.client.Minecraft;
-import net.minecraft.command.CommandSource;
-import net.minecraft.command.Commands;
-import net.minecraft.command.ISuggestionProvider;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.CommandSource;
+import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
private static final String COMMAND = "bbor:spawningSphere";
private static final String CALCULATE_SPAWNABLE = "calculateSpawnable";
- public static void register(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
- LiteralArgumentBuilder command = Commands.literal(COMMAND)
- .then(Commands.literal(ArgumentNames.SET)
- .then(Commands.argument(ArgumentNames.POS, Arguments.point())
+ public static void register(CommandDispatcher<CommandSource> commandDispatcher) {
+ LiteralArgumentBuilder command = CommandManager.literal(COMMAND)
+ .then(CommandManager.literal(ArgumentNames.SET)
+ .then(CommandManager.argument(ArgumentNames.POS, Arguments.point())
.executes(SpawningSphereCommand::setSphere))
.executes(SpawningSphereCommand::setSphere))
- .then(Commands.literal(ArgumentNames.CLEAR)
+ .then(CommandManager.literal(ArgumentNames.CLEAR)
.executes(context -> {
boolean cleared = SpawningSphereProvider.clearSphere();
CommandHelper.feedback(context, format);
return 0;
}))
- .then(Commands.literal(CALCULATE_SPAWNABLE)
+ .then(CommandManager.literal(CALCULATE_SPAWNABLE)
.executes(context -> {
if (!SpawningSphereProvider.hasSpawningSphereInDimension(Player.getDimensionId())) {
CommandHelper.feedback(context, "bbor.commands.spawningSphere.notSet");
}
Counts counts = new Counts();
- World world = Minecraft.getInstance().world;
+ World world = MinecraftClient.getInstance().world;
SpawningSphereProvider.calculateSpawnableSpacesCount(pos -> {
counts.spawnable++;
- if (world.getLightFor(LightType.SKY, pos) > 7)
+ if (world.getLightLevel(LightType.SKY, pos) > 7)
counts.nightSpawnable++;
});
SpawningSphereProvider.setSpawnableSpacesCount(counts.spawnable);
commandDispatcher.register(command);
}
- public static int setSphere(CommandContext<CommandSource> context) throws CommandSyntaxException {
+ public static int setSphere(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
SpawningSphereProvider.setSphere(Arguments.getPoint(context, ArgumentNames.POS).snapXZ(0.5d));
CommandHelper.feedback(context, "bbor.commands.spawningSphere.set");