DebugMobSpawningCommand .java

net.minecraft.server.commands.DebugMobSpawningCommand (class, 33 lines): members: register. strings: "debugmobspawning". imports: NaturalSpawner, Commands.

net.minecraft.server.commandsclass33 linesserver1.2 KB

API Surface (1)

void register(final CommandDispatcher<CommandSourceStack> dispatcher)

String literals (1)

"debugmobspawning"

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

DebugMobSpawningCommand.java33 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.commands;
2
3
import com.mojang.brigadier.CommandDispatcher;
4
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
5
import net.minecraft.commands.CommandSourceStack;
6
import net.minecraft.commands.Commands;
7
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
8
import net.minecraft.core.BlockPos;
9
import net.minecraft.world.entity.MobCategory;
10
import net.minecraft.world.level.NaturalSpawner;
11
12
public class DebugMobSpawningCommand {
13
	public static void register(final CommandDispatcher<CommandSourceStack> dispatcher) {
14
		LiteralArgumentBuilder<CommandSourceStack> base = Commands.literal("debugmobspawning").requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS));
15
16
		for (MobCategory mobCategory : MobCategory.values()) {
17
			base.then(
18
				Commands.literal(mobCategory.getName())
19
					.then(
20
						Commands.argument("at", BlockPosArgument.blockPos()).executes(c -> spawnMobs(c.getSource(), mobCategory, BlockPosArgument.getLoadedBlockPos(c, "at")))
21
					)
22
			);
23
		}
24
25
		dispatcher.register(base);
26
	}
27
28
	private static int spawnMobs(final CommandSourceStack source, final MobCategory mobCategory, final BlockPos at) {
29
		NaturalSpawner.spawnCategoryForPosition(mobCategory, source.getLevel(), at);
30
		return 1;
31
	}
32
}
33

Decompiled Minecraft 26.3 source of DebugMobSpawningCommand (net/minecraft/server/commands/DebugMobSpawningCommand.java) with Mojang official mappings, stored verbatim on the site.