Mojang Mappings

This commit is contained in:
skippyall
2026-04-29 08:51:37 +02:00
parent cc9fedd63b
commit f5202a4264
140 changed files with 1646 additions and 1675 deletions
@@ -6,31 +6,30 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import io.github.skippyall.minions.docs.DocsManager;
import net.minecraft.command.argument.IdentifierArgumentType;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.Identifier;
import java.util.concurrent.CompletableFuture;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.ResourceLocationArgument;
import net.minecraft.resources.ResourceLocation;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.commands.Commands.argument;
import static net.minecraft.commands.Commands.literal;
public class DocsSubcommand {
public static final LiteralArgumentBuilder<ServerCommandSource> DOCS = literal("docs")
public static final LiteralArgumentBuilder<CommandSourceStack> DOCS = literal("docs")
.then(
argument("docName", IdentifierArgumentType.identifier())
argument("docName", ResourceLocationArgument.id())
.suggests(DocsSubcommand::getSuggestions)
.executes(DocsSubcommand::execute)
);
public static CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> context, SuggestionsBuilder builder) {
public static CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandSourceStack> context, SuggestionsBuilder builder) {
DocsManager.getDocsEntryIds().forEach(id -> builder.suggest(id.toString()));
return CompletableFuture.completedFuture(builder.build());
}
public static int execute(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
Identifier id = IdentifierArgumentType.getIdentifier(context, "docName");
DocsManager.showDocsEntry(context.getSource().getPlayerOrThrow(), id);
public static int execute(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ResourceLocation id = ResourceLocationArgument.getId(context, "docName");
DocsManager.showDocsEntry(context.getSource().getPlayerOrException(), id);
return 1;
}
}
@@ -4,21 +4,20 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import io.github.skippyall.minions.minion.MinionData;
import io.github.skippyall.minions.minion.MinionPersistentState;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import java.util.Collection;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.commands.Commands.literal;
public class ListSubcommand {
public static final LiteralArgumentBuilder<ServerCommandSource> LIST = literal("list")
public static final LiteralArgumentBuilder<CommandSourceStack> LIST = literal("list")
.executes(ListSubcommand::list);
public static int list(CommandContext<ServerCommandSource> context) {
public static int list(CommandContext<CommandSourceStack> context) {
Collection<MinionData> minions = MinionPersistentState.get(context.getSource().getServer()).getMinionData().values();
for (MinionData minion : minions) {
context.getSource().sendFeedback(() -> Text.literal(minion.name() + "(" + minion.uuid() + "):" + minion.isSpawned()), false);
context.getSource().sendSuccess(() -> Component.literal(minion.name() + "(" + minion.uuid() + "):" + minion.isSpawned()), false);
}
return 0;
}
@@ -9,16 +9,15 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import io.github.skippyall.minions.minion.MinionData;
import io.github.skippyall.minions.minion.MinionPersistentState;
import io.github.skippyall.minions.minion.MinionProfileUtils;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public class MinionArgument {
public static final SimpleCommandExceptionType MINION_NOT_PRESENT = new SimpleCommandExceptionType(Text.translatable("minions.command.minion.not_present"));
public static final SimpleCommandExceptionType MINION_NOT_PRESENT = new SimpleCommandExceptionType(Component.translatable("minions.command.minion.not_present"));
public static final MinionSuggestionProvider SUGGESTION_PROVIDER = new MinionSuggestionProvider();
@@ -38,9 +37,9 @@ public class MinionArgument {
return data.get();
}
public static class MinionSuggestionProvider implements SuggestionProvider<ServerCommandSource> {
public static class MinionSuggestionProvider implements SuggestionProvider<CommandSourceStack> {
@Override
public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> context, SuggestionsBuilder builder) throws CommandSyntaxException {
public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandSourceStack> context, SuggestionsBuilder builder) throws CommandSyntaxException {
for (MinionData data : MinionPersistentState.get(context.getSource().getServer()).getMinionDataList()) {
builder.suggest(data.name());
}
@@ -3,15 +3,15 @@ package io.github.skippyall.minions.command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import io.github.skippyall.minions.MinionsConfig;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.commands.Commands.literal;
public class MinionsCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess access, CommandManager.RegistrationEnvironment environment) {
LiteralArgumentBuilder<ServerCommandSource> builder = literal("minions")
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext access, Commands.CommandSelection environment) {
LiteralArgumentBuilder<CommandSourceStack> builder = literal("minions")
.then(SpawnSubcommand.SPAWN)
.then(ListSubcommand.LIST)
.then(DocsSubcommand.DOCS)
@@ -4,21 +4,21 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import io.github.skippyall.minions.mixinhelper.antimobcap.ChunkLevelManager$DistanceFromNearestPlayerTrackerAccessor;
import io.github.skippyall.minions.mixinhelper.antimobcap.ChunkLevelManagerAccessor;
import io.github.skippyall.minions.mixins.antimobcap.ServerChunkManagerAccessor;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.world.ChunkLevelManager;
import net.minecraft.text.Text;
import io.github.skippyall.minions.mixins.antimobcap.ServerChunkCacheAccessor;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.DistanceManager;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.commands.Commands.literal;
public class MobCapDebugSubcommand {
public static final LiteralArgumentBuilder<ServerCommandSource> MOB_CAP_DEBUG = literal("mobcapdebug")
public static final LiteralArgumentBuilder<CommandSourceStack> MOB_CAP_DEBUG = literal("mobcapdebug")
.executes(MobCapDebugSubcommand::mobcapdebugCommand);
public static int mobcapdebugCommand(CommandContext<ServerCommandSource> context) {
ChunkLevelManager levelManager = ((ServerChunkManagerAccessor)context.getSource().getWorld().getChunkManager()).getLevelManager();
public static int mobcapdebugCommand(CommandContext<CommandSourceStack> context) {
DistanceManager levelManager = ((ServerChunkCacheAccessor)context.getSource().getLevel().getChunkSource()).getDistanceManager();
int tickedChunkCount = ((ChunkLevelManager$DistanceFromNearestPlayerTrackerAccessor)((ChunkLevelManagerAccessor)levelManager).minions$getMinionless()).minions$getTickedChunkCount();
context.getSource().sendFeedback(() -> Text.of(String.valueOf(tickedChunkCount)), false);
context.getSource().sendSuccess(() -> Component.nullToEmpty(String.valueOf(tickedChunkCount)), false);
return 0;
}
}
@@ -6,24 +6,24 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import io.github.skippyall.minions.minion.MinionData;
import io.github.skippyall.minions.minion.fakeplayer.MinionFakePlayer;
import net.minecraft.command.argument.PosArgument;
import net.minecraft.command.argument.Vec3ArgumentType;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.coordinates.Coordinates;
import net.minecraft.commands.arguments.coordinates.Vec3Argument;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.commands.Commands.argument;
import static net.minecraft.commands.Commands.literal;
public class SpawnSubcommand {
public static final LiteralArgumentBuilder<ServerCommandSource> SPAWN = literal("spawn")
.requires(source -> source.hasPermissionLevel(2))
public static final LiteralArgumentBuilder<CommandSourceStack> SPAWN = literal("spawn")
.requires(source -> source.hasPermission(2))
.then(argument("minion", StringArgumentType.word())
.suggests(MinionArgument.SUGGESTION_PROVIDER)
.then(argument("pos", Vec3ArgumentType.vec3())
.then(argument("pos", Vec3Argument.vec3())
.executes(context ->
spawnCommand(
context.getSource(),
StringArgumentType.getString(context, "minion"),
Vec3ArgumentType.getPosArgument(context, "pos"),
Vec3Argument.getCoordinates(context, "pos"),
false
)
)
@@ -32,7 +32,7 @@ public class SpawnSubcommand {
spawnCommand(
context.getSource(),
StringArgumentType.getString(context, "minion"),
Vec3ArgumentType.getPosArgument(context, "pos"),
Vec3Argument.getCoordinates(context, "pos"),
BoolArgumentType.getBool(context, "force")
)
)
@@ -47,9 +47,9 @@ public class SpawnSubcommand {
))
);
public static int spawnCommand(ServerCommandSource source, String minion, PosArgument pos, boolean force) throws CommandSyntaxException {
public static int spawnCommand(CommandSourceStack source, String minion, Coordinates pos, boolean force) throws CommandSyntaxException {
MinionData data = MinionArgument.parse(source.getServer(), minion);
MinionFakePlayer.spawnMinion(data, source.getWorld(), pos != null ? pos.getPos(source) : null, pos != null ? pos.getRotation(source) : null, force);
MinionFakePlayer.spawnMinion(data, source.getLevel(), pos != null ? pos.getPosition(source) : null, pos != null ? pos.getRotation(source) : null, force);
return 0;
}
}
@@ -3,33 +3,32 @@ package io.github.skippyall.minions.command;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import io.github.skippyall.minions.Minions;
import net.minecraft.block.Blocks;
import net.minecraft.command.argument.BlockPosArgumentType;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import java.util.Collection;
import java.util.HashSet;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.commands.Commands.argument;
import static net.minecraft.commands.Commands.literal;
public class TestSubcommand {
public static LiteralArgumentBuilder<ServerCommandSource> TEST = literal("test")
.then(argument("pos", BlockPosArgumentType.blockPos())
public static LiteralArgumentBuilder<CommandSourceStack> TEST = literal("test")
.then(argument("pos", BlockPosArgument.blockPos())
.executes(TestSubcommand::execute)
);
private static int execute(CommandContext<ServerCommandSource> context) {
private static int execute(CommandContext<CommandSourceStack> context) {
try {
BlockPos pos = BlockPosArgumentType.getBlockPos(context, "pos");
Collection<BlockPos> result = findInputs(context.getSource().getWorld(), pos);
BlockPos pos = BlockPosArgument.getBlockPos(context, "pos");
Collection<BlockPos> result = findInputs(context.getSource().getLevel(), pos);
for (BlockPos resultPos : result) {
context.getSource().sendFeedback(() -> Text.literal(resultPos.toShortString()), false);
context.getSource().sendSuccess(() -> Component.literal(resultPos.toShortString()), false);
}
} catch (Throwable e) {
Minions.LOGGER.error("Error", e);
@@ -37,7 +36,7 @@ public class TestSubcommand {
return 0;
}
private static Collection<BlockPos> findInputs(World world, BlockPos pos) {
private static Collection<BlockPos> findInputs(Level world, BlockPos pos) {
//positions that are already processed
Collection<BlockPos> visitedPositions = new HashSet<>();
//positions we are currently looking at
@@ -53,7 +52,7 @@ public class TestSubcommand {
for(BlockPos currentPosition : currentPositions) {
for(Direction dir : Direction.values()) {
//check each neighbor of the current positions
BlockPos newPos = currentPosition.offset(dir);
BlockPos newPos = currentPosition.relative(dir);
//Do not check blocks that were already checked
if(!visitedPositions.contains(newPos)) {
if (world.getBlockState(newPos).getBlock() == Blocks.REDSTONE_BLOCK) {