ExecuteCommand.java

net.minecraft.server.commands.ExecuteCommand

信息

  • 全限定名:net.minecraft.server.commands.ExecuteCommand
  • 类型:public class
  • 包:net.minecraft.server.commands
  • 源码路径:src/main/java/net/minecraft/server/commands/ExecuteCommand.java
  • 起始行号:L127
  • 职责:

    TODO

字段/常量

  • LOGGER

    • 类型: Logger
    • 修饰符: private static final
    • 源码定位: L128
    • 说明:

      TODO

  • MAX_TEST_AREA

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L129
    • 说明:

      TODO

  • ERROR_AREA_TOO_LARGE

    • 类型: Dynamic2CommandExceptionType
    • 修饰符: private static final
    • 源码定位: L130
    • 说明:

      TODO

  • ERROR_CONDITIONAL_FAILED

    • 类型: SimpleCommandExceptionType
    • 修饰符: private static final
    • 源码定位: L133
    • 说明:

      TODO

  • ERROR_CONDITIONAL_FAILED_COUNT

    • 类型: DynamicCommandExceptionType
    • 修饰符: private static final
    • 源码定位: L136
    • 说明:

      TODO

  • ERROR_FUNCTION_CONDITION_INSTANTATION_FAILURE

    • 类型: Dynamic2CommandExceptionType
    • 修饰符: public static final
    • 源码定位: L139
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.server.commands.ExecuteCommand.CommandNumericPredicate

    • 类型: interface
    • 修饰符: private
    • 源码定位: L1110
    • 说明:

      TODO

  • net.minecraft.server.commands.ExecuteCommand.CommandPredicate

    • 类型: interface
    • 修饰符: private
    • 源码定位: L1115
    • 说明:

      TODO

  • net.minecraft.server.commands.ExecuteCommand.ExecuteIfFunctionCustomModifier

    • 类型: class
    • 修饰符: private static
    • 源码定位: L1119
    • 说明:

      TODO

  • net.minecraft.server.commands.ExecuteCommand.IntBiPredicate

    • 类型: interface
    • 修饰符: private
    • 源码定位: L1148
    • 说明:

      TODO

构造器

方法

下面的方法块按源码顺序生成。

public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) @ L144

  • 方法名:register
  • 源码定位:L144
  • 返回类型:void
  • 修饰符:public static

参数:

  • dispatcher: CommandDispatcher
  • context: CommandBuildContext

说明:

TODO

private static ArgumentBuilder<CommandSourceStack,?> wrapStores(LiteralCommandNode<CommandSourceStack> execute, LiteralArgumentBuilder<CommandSourceStack> literal, boolean storeResult) @ L276

  • 方法名:wrapStores
  • 源码定位:L276
  • 返回类型:ArgumentBuilder<CommandSourceStack,?>
  • 修饰符:private static

参数:

  • execute: LiteralCommandNode
  • literal: LiteralArgumentBuilder
  • storeResult: boolean

说明:

TODO

private static CommandSourceStack storeValue(CommandSourceStack source, Collection<ScoreHolder> names, Objective objective, boolean storeResult) @ L416

  • 方法名:storeValue
  • 源码定位:L416
  • 返回类型:CommandSourceStack
  • 修饰符:private static

参数:

  • source: CommandSourceStack
  • names: Collection
  • objective: Objective
  • storeResult: boolean

说明:

TODO

private static CommandSourceStack storeValue(CommandSourceStack source, CustomBossEvent event, boolean storeIntoValue, boolean storeResult) @ L427

  • 方法名:storeValue
  • 源码定位:L427
  • 返回类型:CommandSourceStack
  • 修饰符:private static

参数:

  • source: CommandSourceStack
  • event: CustomBossEvent
  • storeIntoValue: boolean
  • storeResult: boolean

说明:

TODO

private static CommandSourceStack storeData(CommandSourceStack source, DataAccessor accessor, NbtPathArgument.NbtPath path, IntFunction<Tag> constructor, boolean storeResult) @ L438

  • 方法名:storeData
  • 源码定位:L438
  • 返回类型:CommandSourceStack
  • 修饰符:private static

参数:

  • source: CommandSourceStack
  • accessor: DataAccessor
  • path: NbtPathArgument.NbtPath
  • constructor: IntFunction
  • storeResult: boolean

说明:

TODO

private static boolean isChunkLoaded(ServerLevel level, BlockPos pos) @ L452

  • 方法名:isChunkLoaded
  • 源码定位:L452
  • 返回类型:boolean
  • 修饰符:private static

参数:

  • level: ServerLevel
  • pos: BlockPos

说明:

TODO

private static ArgumentBuilder<CommandSourceStack,?> addConditionals(CommandNode<CommandSourceStack> execute, LiteralArgumentBuilder<CommandSourceStack> parent, boolean expected, CommandBuildContext context) @ L458

  • 方法名:addConditionals
  • 源码定位:L458
  • 返回类型:ArgumentBuilder<CommandSourceStack,?>
  • 修饰符:private static

参数:

  • execute: CommandNode
  • parent: LiteralArgumentBuilder
  • expected: boolean
  • context: CommandBuildContext

说明:

TODO

private static int countItems(Iterable<?extends SlotProvider> sources, SlotRange slotRange, Predicate<ItemStack> predicate) @ L757

  • 方法名:countItems
  • 源码定位:L757
  • 返回类型:int
  • 修饰符:private static

参数:

  • sources: Iterable<?extends SlotProvider>
  • slotRange: SlotRange
  • predicate: Predicate

说明:

TODO

private static int countItems(CommandSourceStack source, BlockPos pos, SlotRange slotRange, Predicate<ItemStack> predicate) @ L778

  • 方法名:countItems
  • 源码定位:L778
  • 返回类型:int
  • 修饰符:private static

参数:

  • source: CommandSourceStack
  • pos: BlockPos
  • slotRange: SlotRange
  • predicate: Predicate

说明:

TODO

private static Command<CommandSourceStack> createNumericConditionalHandler(boolean expected, ExecuteCommand.CommandNumericPredicate condition) @ L797

  • 方法名:createNumericConditionalHandler
  • 源码定位:L797
  • 返回类型:Command
  • 修饰符:private static

参数:

  • expected: boolean
  • condition: ExecuteCommand.CommandNumericPredicate

说明:

TODO

private static int checkMatchingData(DataAccessor accessor, NbtPathArgument.NbtPath path) @ L817

  • 方法名:checkMatchingData
  • 源码定位:L817
  • 返回类型:int
  • 修饰符:private static

参数:

  • accessor: DataAccessor
  • path: NbtPathArgument.NbtPath

说明:

TODO

private static boolean checkScore(CommandContext<CommandSourceStack> context, ExecuteCommand.IntBiPredicate operation) @ L821

  • 方法名:checkScore
  • 源码定位:L821
  • 返回类型:boolean
  • 修饰符:private static

参数:

  • context: CommandContext
  • operation: ExecuteCommand.IntBiPredicate

说明:

TODO

private static boolean checkScore(CommandContext<CommandSourceStack> context, MinMaxBounds.Ints range) @ L832

  • 方法名:checkScore
  • 源码定位:L832
  • 返回类型:boolean
  • 修饰符:private static

参数:

  • context: CommandContext
  • range: MinMaxBounds.Ints

说明:

TODO

private static boolean checkStopwatch(CommandContext<CommandSourceStack> context, MinMaxBounds.Doubles range) @ L840

  • 方法名:checkStopwatch
  • 源码定位:L840
  • 返回类型:boolean
  • 修饰符:private static

参数:

  • context: CommandContext
  • range: MinMaxBounds.Doubles

说明:

TODO

private static boolean checkCustomPredicate(CommandSourceStack source, Holder<LootItemCondition> predicate) @ L853

  • 方法名:checkCustomPredicate
  • 源码定位:L853
  • 返回类型:boolean
  • 修饰符:private static

参数:

  • source: CommandSourceStack
  • predicate: Holder

说明:

TODO

private static Collection<CommandSourceStack> expect(CommandContext<CommandSourceStack> context, boolean expected, boolean result) @ L864

  • 方法名:expect
  • 源码定位:L864
  • 返回类型:Collection
  • 修饰符:private static

参数:

  • context: CommandContext
  • expected: boolean
  • result: boolean

说明:

TODO

private static ArgumentBuilder<CommandSourceStack,?> addConditional(CommandNode<CommandSourceStack> root, ArgumentBuilder<CommandSourceStack,?> argument, boolean expected, ExecuteCommand.CommandPredicate predicate) @ L868

  • 方法名:addConditional
  • 源码定位:L868
  • 返回类型:ArgumentBuilder<CommandSourceStack,?>
  • 修饰符:private static

参数:

  • root: CommandNode
  • argument: ArgumentBuilder<CommandSourceStack,?>
  • expected: boolean
  • predicate: ExecuteCommand.CommandPredicate

说明:

TODO

private static ArgumentBuilder<CommandSourceStack,?> addIfBlocksConditional(CommandNode<CommandSourceStack> root, ArgumentBuilder<CommandSourceStack,?> argument, boolean expected, boolean skipAir) @ L881

  • 方法名:addIfBlocksConditional
  • 源码定位:L881
  • 返回类型:ArgumentBuilder<CommandSourceStack,?>
  • 修饰符:private static

参数:

  • root: CommandNode
  • argument: ArgumentBuilder<CommandSourceStack,?>
  • expected: boolean
  • skipAir: boolean

说明:

TODO

private static int checkIfRegions(CommandContext<CommandSourceStack> context, boolean skipAir) @ L888

  • 方法名:checkIfRegions
  • 源码定位:L888
  • 返回类型:int
  • 修饰符:private static

参数:

  • context: CommandContext
  • skipAir: boolean

说明:

TODO

private static int checkUnlessRegions(CommandContext<CommandSourceStack> context, boolean skipAir) @ L898

  • 方法名:checkUnlessRegions
  • 源码定位:L898
  • 返回类型:int
  • 修饰符:private static

参数:

  • context: CommandContext
  • skipAir: boolean

说明:

TODO

private static OptionalInt checkRegions(CommandContext<CommandSourceStack> context, boolean skipAir) @ L908

  • 方法名:checkRegions
  • 源码定位:L908
  • 返回类型:OptionalInt
  • 修饰符:private static

参数:

  • context: CommandContext
  • skipAir: boolean

说明:

TODO

private static OptionalInt checkRegions(ServerLevel level, BlockPos startPos, BlockPos endPos, BlockPos destPos, boolean skipAir) @ L918

  • 方法名:checkRegions
  • 源码定位:L918
  • 返回类型:OptionalInt
  • 修饰符:private static

参数:

  • level: ServerLevel
  • startPos: BlockPos
  • endPos: BlockPos
  • destPos: BlockPos
  • skipAir: boolean

说明:

TODO

private static RedirectModifier<CommandSourceStack> expandOneToOneEntityRelation(Function<Entity,Optional<Entity>> unpacker) @ L982

  • 方法名:expandOneToOneEntityRelation
  • 源码定位:L982
  • 返回类型:RedirectModifier
  • 修饰符:private static

参数:

  • unpacker: Function<Entity,Optional>

说明:

TODO

private static RedirectModifier<CommandSourceStack> expandOneToManyEntityRelation(Function<Entity,Stream<Entity>> unpacker) @ L990

  • 方法名:expandOneToManyEntityRelation
  • 源码定位:L990
  • 返回类型:RedirectModifier
  • 修饰符:private static

参数:

  • unpacker: Function<Entity,Stream>

说明:

TODO

private static LiteralArgumentBuilder<CommandSourceStack> createRelationOperations(CommandNode<CommandSourceStack> execute, LiteralArgumentBuilder<CommandSourceStack> on) @ L998

  • 方法名:createRelationOperations
  • 源码定位:L998
  • 返回类型:LiteralArgumentBuilder
  • 修饰符:private static

参数:

  • execute: CommandNode
  • on: LiteralArgumentBuilder

说明:

TODO

private static CommandSourceStack spawnEntityAndRedirect(CommandSourceStack source, Holder.Reference<EntityType<?>> type) @ L1045

  • 方法名:spawnEntityAndRedirect
  • 源码定位:L1045
  • 返回类型:CommandSourceStack
  • 修饰符:private static

参数:

  • source: CommandSourceStack
  • type: Holder.Reference<EntityType<?>>

说明:

TODO

public static <T extends ExecutionCommandSource<T>> void scheduleFunctionConditionsAndTest(T originalSource, List<T> currentSources, Function<T,T> functionContextModifier, IntPredicate check, ContextChain<T> currentStep, CompoundTag parameters, ExecutionControl<T> output, InCommandFunction<CommandContext<T>,Collection<CommandFunction<T>>> functionGetter, ChainModifiers modifiers) @ L1050

  • 方法名:scheduleFunctionConditionsAndTest
  • 源码定位:L1050
  • 返回类型:<T extends ExecutionCommandSource> void
  • 修饰符:public static

参数:

  • originalSource: T
  • currentSources: List
  • functionContextModifier: Function<T,T>
  • check: IntPredicate
  • currentStep: ContextChain
  • parameters: CompoundTag
  • output: ExecutionControl
  • functionGetter: InCommandFunction<CommandContext,Collection<CommandFunction>>
  • modifiers: ChainModifiers

说明:

TODO

代码

public class ExecuteCommand {
    private static final Logger LOGGER = LogUtils.getLogger();
    private static final int MAX_TEST_AREA = 32768;
    private static final Dynamic2CommandExceptionType ERROR_AREA_TOO_LARGE = new Dynamic2CommandExceptionType(
        (max, count) -> Component.translatableEscape("commands.execute.blocks.toobig", max, count)
    );
    private static final SimpleCommandExceptionType ERROR_CONDITIONAL_FAILED = new SimpleCommandExceptionType(
        Component.translatable("commands.execute.conditional.fail")
    );
    private static final DynamicCommandExceptionType ERROR_CONDITIONAL_FAILED_COUNT = new DynamicCommandExceptionType(
        count -> Component.translatableEscape("commands.execute.conditional.fail_count", count)
    );
    @VisibleForTesting
    public static final Dynamic2CommandExceptionType ERROR_FUNCTION_CONDITION_INSTANTATION_FAILURE = new Dynamic2CommandExceptionType(
        (id, reason) -> Component.translatableEscape("commands.execute.function.instantiationFailure", id, reason)
    );
 
    public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context) {
        LiteralCommandNode<CommandSourceStack> execute = dispatcher.register(
            Commands.literal("execute").requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
        );
        dispatcher.register(
            Commands.literal("execute")
                .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
                .then(Commands.literal("run").redirect(dispatcher.getRoot()))
                .then(addConditionals(execute, Commands.literal("if"), true, context))
                .then(addConditionals(execute, Commands.literal("unless"), false, context))
                .then(Commands.literal("as").then(Commands.argument("targets", EntityArgument.entities()).fork(execute, c -> {
                    List<CommandSourceStack> result = Lists.newArrayList();
 
                    for (Entity entity : EntityArgument.getOptionalEntities(c, "targets")) {
                        result.add(c.getSource().withEntity(entity));
                    }
 
                    return result;
                })))
                .then(Commands.literal("at").then(Commands.argument("targets", EntityArgument.entities()).fork(execute, c -> {
                    List<CommandSourceStack> result = Lists.newArrayList();
 
                    for (Entity entity : EntityArgument.getOptionalEntities(c, "targets")) {
                        result.add(
                            c.getSource().withLevel((ServerLevel)entity.level()).withPosition(entity.position()).withRotation(entity.getRotationVector())
                        );
                    }
 
                    return result;
                })))
                .then(
                    Commands.literal("store")
                        .then(wrapStores(execute, Commands.literal("result"), true))
                        .then(wrapStores(execute, Commands.literal("success"), false))
                )
                .then(
                    Commands.literal("positioned")
                        .then(
                            Commands.argument("pos", Vec3Argument.vec3())
                                .redirect(execute, c -> c.getSource().withPosition(Vec3Argument.getVec3(c, "pos")).withAnchor(EntityAnchorArgument.Anchor.FEET))
                        )
                        .then(Commands.literal("as").then(Commands.argument("targets", EntityArgument.entities()).fork(execute, c -> {
                            List<CommandSourceStack> result = Lists.newArrayList();
 
                            for (Entity entity : EntityArgument.getOptionalEntities(c, "targets")) {
                                result.add(c.getSource().withPosition(entity.position()));
                            }
 
                            return result;
                        })))
                        .then(Commands.literal("over").then(Commands.argument("heightmap", HeightmapTypeArgument.heightmap()).redirect(execute, c -> {
                            Vec3 position = c.getSource().getPosition();
                            ServerLevel level = c.getSource().getLevel();
                            double x = position.x();
                            double z = position.z();
                            if (!level.hasChunk(SectionPos.blockToSectionCoord(x), SectionPos.blockToSectionCoord(z))) {
                                throw BlockPosArgument.ERROR_NOT_LOADED.create();
                            } else {
                                int height = level.getHeight(HeightmapTypeArgument.getHeightmap(c, "heightmap"), Mth.floor(x), Mth.floor(z));
                                return c.getSource().withPosition(new Vec3(x, height, z));
                            }
                        })))
                )
                .then(
                    Commands.literal("rotated")
                        .then(
                            Commands.argument("rot", RotationArgument.rotation())
                                .redirect(execute, c -> c.getSource().withRotation(RotationArgument.getRotation(c, "rot").getRotation(c.getSource())))
                        )
                        .then(Commands.literal("as").then(Commands.argument("targets", EntityArgument.entities()).fork(execute, c -> {
                            List<CommandSourceStack> result = Lists.newArrayList();
 
                            for (Entity entity : EntityArgument.getOptionalEntities(c, "targets")) {
                                result.add(c.getSource().withRotation(entity.getRotationVector()));
                            }
 
                            return result;
                        })))
                )
                .then(
                    Commands.literal("facing")
                        .then(
                            Commands.literal("entity")
                                .then(
                                    Commands.argument("targets", EntityArgument.entities())
                                        .then(Commands.argument("anchor", EntityAnchorArgument.anchor()).fork(execute, c -> {
                                            List<CommandSourceStack> result = Lists.newArrayList();
                                            EntityAnchorArgument.Anchor anchor = EntityAnchorArgument.getAnchor(c, "anchor");
 
                                            for (Entity entity : EntityArgument.getOptionalEntities(c, "targets")) {
                                                result.add(c.getSource().facing(entity, anchor));
                                            }
 
                                            return result;
                                        }))
                                )
                        )
                        .then(Commands.argument("pos", Vec3Argument.vec3()).redirect(execute, c -> c.getSource().facing(Vec3Argument.getVec3(c, "pos"))))
                )
                .then(
                    Commands.literal("align")
                        .then(
                            Commands.argument("axes", SwizzleArgument.swizzle())
                                .redirect(execute, c -> c.getSource().withPosition(c.getSource().getPosition().align(SwizzleArgument.getSwizzle(c, "axes"))))
                        )
                )
                .then(
                    Commands.literal("anchored")
                        .then(
                            Commands.argument("anchor", EntityAnchorArgument.anchor())
                                .redirect(execute, c -> c.getSource().withAnchor(EntityAnchorArgument.getAnchor(c, "anchor")))
                        )
                )
                .then(
                    Commands.literal("in")
                        .then(
                            Commands.argument("dimension", DimensionArgument.dimension())
                                .redirect(execute, c -> c.getSource().withLevel(DimensionArgument.getDimension(c, "dimension")))
                        )
                )
                .then(
                    Commands.literal("summon")
                        .then(
                            Commands.argument("entity", ResourceArgument.resource(context, Registries.ENTITY_TYPE))
                                .suggests(SuggestionProviders.cast(SuggestionProviders.SUMMONABLE_ENTITIES))
                                .redirect(execute, c -> spawnEntityAndRedirect(c.getSource(), ResourceArgument.getSummonableEntityType(c, "entity")))
                        )
                )
                .then(createRelationOperations(execute, Commands.literal("on")))
        );
    }
 
    private static ArgumentBuilder<CommandSourceStack, ?> wrapStores(
        LiteralCommandNode<CommandSourceStack> execute, LiteralArgumentBuilder<CommandSourceStack> literal, boolean storeResult
    ) {
        literal.then(
            Commands.literal("score")
                .then(
                    Commands.argument("targets", ScoreHolderArgument.scoreHolders())
                        .suggests(ScoreHolderArgument.SUGGEST_SCORE_HOLDERS)
                        .then(
                            Commands.argument("objective", ObjectiveArgument.objective())
                                .redirect(
                                    execute,
                                    c -> storeValue(
                                        c.getSource(),
                                        ScoreHolderArgument.getNamesWithDefaultWildcard(c, "targets"),
                                        ObjectiveArgument.getObjective(c, "objective"),
                                        storeResult
                                    )
                                )
                        )
                )
        );
        literal.then(
            Commands.literal("bossbar")
                .then(
                    Commands.argument("id", IdentifierArgument.id())
                        .suggests(BossBarCommands.SUGGEST_BOSS_BAR)
                        .then(Commands.literal("value").redirect(execute, c -> storeValue(c.getSource(), BossBarCommands.getBossBar(c), true, storeResult)))
                        .then(Commands.literal("max").redirect(execute, c -> storeValue(c.getSource(), BossBarCommands.getBossBar(c), false, storeResult)))
                )
        );
 
        for (DataCommands.DataProvider provider : DataCommands.TARGET_PROVIDERS) {
            provider.wrap(
                literal,
                p -> p.then(
                    Commands.argument("path", NbtPathArgument.nbtPath())
                        .then(
                            Commands.literal("int")
                                .then(
                                    Commands.argument("scale", DoubleArgumentType.doubleArg())
                                        .redirect(
                                            execute,
                                            c -> storeData(
                                                c.getSource(),
                                                provider.access(c),
                                                NbtPathArgument.getPath(c, "path"),
                                                v -> IntTag.valueOf((int)(v * DoubleArgumentType.getDouble(c, "scale"))),
                                                storeResult
                                            )
                                        )
                                )
                        )
                        .then(
                            Commands.literal("float")
                                .then(
                                    Commands.argument("scale", DoubleArgumentType.doubleArg())
                                        .redirect(
                                            execute,
                                            c -> storeData(
                                                c.getSource(),
                                                provider.access(c),
                                                NbtPathArgument.getPath(c, "path"),
                                                v -> FloatTag.valueOf((float)(v * DoubleArgumentType.getDouble(c, "scale"))),
                                                storeResult
                                            )
                                        )
                                )
                        )
                        .then(
                            Commands.literal("short")
                                .then(
                                    Commands.argument("scale", DoubleArgumentType.doubleArg())
                                        .redirect(
                                            execute,
                                            c -> storeData(
                                                c.getSource(),
                                                provider.access(c),
                                                NbtPathArgument.getPath(c, "path"),
                                                v -> ShortTag.valueOf((short)(v * DoubleArgumentType.getDouble(c, "scale"))),
                                                storeResult
                                            )
                                        )
                                )
                        )
                        .then(
                            Commands.literal("long")
                                .then(
                                    Commands.argument("scale", DoubleArgumentType.doubleArg())
                                        .redirect(
                                            execute,
                                            c -> storeData(
                                                c.getSource(),
                                                provider.access(c),
                                                NbtPathArgument.getPath(c, "path"),
                                                v -> LongTag.valueOf((long)(v * DoubleArgumentType.getDouble(c, "scale"))),
                                                storeResult
                                            )
                                        )
                                )
                        )
                        .then(
                            Commands.literal("double")
                                .then(
                                    Commands.argument("scale", DoubleArgumentType.doubleArg())
                                        .redirect(
                                            execute,
                                            c -> storeData(
                                                c.getSource(),
                                                provider.access(c),
                                                NbtPathArgument.getPath(c, "path"),
                                                v -> DoubleTag.valueOf(v * DoubleArgumentType.getDouble(c, "scale")),
                                                storeResult
                                            )
                                        )
                                )
                        )
                        .then(
                            Commands.literal("byte")
                                .then(
                                    Commands.argument("scale", DoubleArgumentType.doubleArg())
                                        .redirect(
                                            execute,
                                            c -> storeData(
                                                c.getSource(),
                                                provider.access(c),
                                                NbtPathArgument.getPath(c, "path"),
                                                v -> ByteTag.valueOf((byte)(v * DoubleArgumentType.getDouble(c, "scale"))),
                                                storeResult
                                            )
                                        )
                                )
                        )
                )
            );
        }
 
        return literal;
    }
 
    private static CommandSourceStack storeValue(CommandSourceStack source, Collection<ScoreHolder> names, Objective objective, boolean storeResult) {
        Scoreboard scoreboard = source.getServer().getScoreboard();
        return source.withCallback((success, result) -> {
            for (ScoreHolder name : names) {
                ScoreAccess score = scoreboard.getOrCreatePlayerScore(name, objective);
                int value = storeResult ? result : (success ? 1 : 0);
                score.set(value);
            }
        }, CommandResultCallback::chain);
    }
 
    private static CommandSourceStack storeValue(CommandSourceStack source, CustomBossEvent event, boolean storeIntoValue, boolean storeResult) {
        return source.withCallback((success, result) -> {
            int value = storeResult ? result : (success ? 1 : 0);
            if (storeIntoValue) {
                event.setValue(value);
            } else {
                event.setMax(value);
            }
        }, CommandResultCallback::chain);
    }
 
    private static CommandSourceStack storeData(
        CommandSourceStack source, DataAccessor accessor, NbtPathArgument.NbtPath path, IntFunction<Tag> constructor, boolean storeResult
    ) {
        return source.withCallback((success, result) -> {
            try {
                CompoundTag data = accessor.getData();
                int value = storeResult ? result : (success ? 1 : 0);
                path.set(data, constructor.apply(value));
                accessor.setData(data);
            } catch (CommandSyntaxException var8) {
            }
        }, CommandResultCallback::chain);
    }
 
    private static boolean isChunkLoaded(ServerLevel level, BlockPos pos) {
        ChunkPos chunkPos = ChunkPos.containing(pos);
        LevelChunk chunk = level.getChunkSource().getChunkNow(chunkPos.x(), chunkPos.z());
        return chunk == null ? false : chunk.getFullStatus() == FullChunkStatus.ENTITY_TICKING && level.areEntitiesLoaded(chunkPos.pack());
    }
 
    private static ArgumentBuilder<CommandSourceStack, ?> addConditionals(
        CommandNode<CommandSourceStack> execute, LiteralArgumentBuilder<CommandSourceStack> parent, boolean expected, CommandBuildContext context
    ) {
        parent.then(
                Commands.literal("block")
                    .then(
                        Commands.argument("pos", BlockPosArgument.blockPos())
                            .then(
                                addConditional(
                                    execute,
                                    Commands.argument("block", BlockPredicateArgument.blockPredicate(context)),
                                    expected,
                                    c -> BlockPredicateArgument.getBlockPredicate(c, "block")
                                        .test(new BlockInWorld(c.getSource().getLevel(), BlockPosArgument.getLoadedBlockPos(c, "pos"), true))
                                )
                            )
                    )
            )
            .then(
                Commands.literal("biome")
                    .then(
                        Commands.argument("pos", BlockPosArgument.blockPos())
                            .then(
                                addConditional(
                                    execute,
                                    Commands.argument("biome", ResourceOrTagArgument.resourceOrTag(context, Registries.BIOME)),
                                    expected,
                                    c -> ResourceOrTagArgument.getResourceOrTag(c, "biome", Registries.BIOME)
                                        .test(c.getSource().getLevel().getBiome(BlockPosArgument.getLoadedBlockPos(c, "pos")))
                                )
                            )
                    )
            )
            .then(
                Commands.literal("loaded")
                    .then(
                        addConditional(
                            execute,
                            Commands.argument("pos", BlockPosArgument.blockPos()),
                            expected,
                            c -> isChunkLoaded(c.getSource().getLevel(), BlockPosArgument.getBlockPos(c, "pos"))
                        )
                    )
            )
            .then(
                Commands.literal("dimension")
                    .then(
                        addConditional(
                            execute,
                            Commands.argument("dimension", DimensionArgument.dimension()),
                            expected,
                            c -> DimensionArgument.getDimension(c, "dimension") == c.getSource().getLevel()
                        )
                    )
            )
            .then(
                Commands.literal("score")
                    .then(
                        Commands.argument("target", ScoreHolderArgument.scoreHolder())
                            .suggests(ScoreHolderArgument.SUGGEST_SCORE_HOLDERS)
                            .then(
                                Commands.argument("targetObjective", ObjectiveArgument.objective())
                                    .then(
                                        Commands.literal("=")
                                            .then(
                                                Commands.argument("source", ScoreHolderArgument.scoreHolder())
                                                    .suggests(ScoreHolderArgument.SUGGEST_SCORE_HOLDERS)
                                                    .then(
                                                        addConditional(
                                                            execute,
                                                            Commands.argument("sourceObjective", ObjectiveArgument.objective()),
                                                            expected,
                                                            c -> checkScore(c, (a, b) -> a == b)
                                                        )
                                                    )
                                            )
                                    )
                                    .then(
                                        Commands.literal("<")
                                            .then(
                                                Commands.argument("source", ScoreHolderArgument.scoreHolder())
                                                    .suggests(ScoreHolderArgument.SUGGEST_SCORE_HOLDERS)
                                                    .then(
                                                        addConditional(
                                                            execute,
                                                            Commands.argument("sourceObjective", ObjectiveArgument.objective()),
                                                            expected,
                                                            c -> checkScore(c, (a, b) -> a < b)
                                                        )
                                                    )
                                            )
                                    )
                                    .then(
                                        Commands.literal("<=")
                                            .then(
                                                Commands.argument("source", ScoreHolderArgument.scoreHolder())
                                                    .suggests(ScoreHolderArgument.SUGGEST_SCORE_HOLDERS)
                                                    .then(
                                                        addConditional(
                                                            execute,
                                                            Commands.argument("sourceObjective", ObjectiveArgument.objective()),
                                                            expected,
                                                            c -> checkScore(c, (a, b) -> a <= b)
                                                        )
                                                    )
                                            )
                                    )
                                    .then(
                                        Commands.literal(">")
                                            .then(
                                                Commands.argument("source", ScoreHolderArgument.scoreHolder())
                                                    .suggests(ScoreHolderArgument.SUGGEST_SCORE_HOLDERS)
                                                    .then(
                                                        addConditional(
                                                            execute,
                                                            Commands.argument("sourceObjective", ObjectiveArgument.objective()),
                                                            expected,
                                                            c -> checkScore(c, (a, b) -> a > b)
                                                        )
                                                    )
                                            )
                                    )
                                    .then(
                                        Commands.literal(">=")
                                            .then(
                                                Commands.argument("source", ScoreHolderArgument.scoreHolder())
                                                    .suggests(ScoreHolderArgument.SUGGEST_SCORE_HOLDERS)
                                                    .then(
                                                        addConditional(
                                                            execute,
                                                            Commands.argument("sourceObjective", ObjectiveArgument.objective()),
                                                            expected,
                                                            c -> checkScore(c, (a, b) -> a >= b)
                                                        )
                                                    )
                                            )
                                    )
                                    .then(
                                        Commands.literal("matches")
                                            .then(
                                                addConditional(
                                                    execute,
                                                    Commands.argument("range", RangeArgument.intRange()),
                                                    expected,
                                                    c -> checkScore(c, RangeArgument.Ints.getRange(c, "range"))
                                                )
                                            )
                                    )
                            )
                    )
            )
            .then(
                Commands.literal("blocks")
                    .then(
                        Commands.argument("start", BlockPosArgument.blockPos())
                            .then(
                                Commands.argument("end", BlockPosArgument.blockPos())
                                    .then(
                                        Commands.argument("destination", BlockPosArgument.blockPos())
                                            .then(addIfBlocksConditional(execute, Commands.literal("all"), expected, false))
                                            .then(addIfBlocksConditional(execute, Commands.literal("masked"), expected, true))
                                    )
                            )
                    )
            )
            .then(
                Commands.literal("entity")
                    .then(
                        Commands.argument("entities", EntityArgument.entities())
                            .fork(execute, c -> expect(c, expected, !EntityArgument.getOptionalEntities(c, "entities").isEmpty()))
                            .executes(createNumericConditionalHandler(expected, c -> EntityArgument.getOptionalEntities(c, "entities").size()))
                    )
            )
            .then(
                Commands.literal("predicate")
                    .then(
                        addConditional(
                            execute,
                            Commands.argument("predicate", ResourceOrIdArgument.lootPredicate(context)),
                            expected,
                            c -> checkCustomPredicate(c.getSource(), ResourceOrIdArgument.getLootPredicate(c, "predicate"))
                        )
                    )
            )
            .then(
                Commands.literal("function")
                    .then(
                        Commands.argument("name", FunctionArgument.functions())
                            .suggests(FunctionCommand.SUGGEST_FUNCTION)
                            .fork(execute, new ExecuteCommand.ExecuteIfFunctionCustomModifier(expected))
                    )
            )
            .then(
                Commands.literal("items")
                    .then(
                        Commands.literal("entity")
                            .then(
                                Commands.argument("entities", EntityArgument.entities())
                                    .then(
                                        Commands.argument("slots", SlotsArgument.slots())
                                            .then(
                                                Commands.argument("item_predicate", ItemPredicateArgument.itemPredicate(context))
                                                    .fork(
                                                        execute,
                                                        c -> expect(
                                                            c,
                                                            expected,
                                                            countItems(
                                                                    EntityArgument.getEntities(c, "entities"),
                                                                    SlotsArgument.getSlots(c, "slots"),
                                                                    ItemPredicateArgument.getItemPredicate(c, "item_predicate")
                                                                )
                                                                > 0
                                                        )
                                                    )
                                                    .executes(
                                                        createNumericConditionalHandler(
                                                            expected,
                                                            c -> countItems(
                                                                EntityArgument.getEntities(c, "entities"),
                                                                SlotsArgument.getSlots(c, "slots"),
                                                                ItemPredicateArgument.getItemPredicate(c, "item_predicate")
                                                            )
                                                        )
                                                    )
                                            )
                                    )
                            )
                    )
                    .then(
                        Commands.literal("block")
                            .then(
                                Commands.argument("pos", BlockPosArgument.blockPos())
                                    .then(
                                        Commands.argument("slots", SlotsArgument.slots())
                                            .then(
                                                Commands.argument("item_predicate", ItemPredicateArgument.itemPredicate(context))
                                                    .fork(
                                                        execute,
                                                        c -> expect(
                                                            c,
                                                            expected,
                                                            countItems(
                                                                    c.getSource(),
                                                                    BlockPosArgument.getLoadedBlockPos(c, "pos"),
                                                                    SlotsArgument.getSlots(c, "slots"),
                                                                    ItemPredicateArgument.getItemPredicate(c, "item_predicate")
                                                                )
                                                                > 0
                                                        )
                                                    )
                                                    .executes(
                                                        createNumericConditionalHandler(
                                                            expected,
                                                            c -> countItems(
                                                                c.getSource(),
                                                                BlockPosArgument.getLoadedBlockPos(c, "pos"),
                                                                SlotsArgument.getSlots(c, "slots"),
                                                                ItemPredicateArgument.getItemPredicate(c, "item_predicate")
                                                            )
                                                        )
                                                    )
                                            )
                                    )
                            )
                    )
            )
            .then(
                Commands.literal("stopwatch")
                    .then(
                        Commands.argument("id", IdentifierArgument.id())
                            .suggests(StopwatchCommand.SUGGEST_STOPWATCHES)
                            .then(
                                addConditional(
                                    execute,
                                    Commands.argument("range", RangeArgument.floatRange()),
                                    expected,
                                    c -> checkStopwatch(c, RangeArgument.Floats.getRange(c, "range"))
                                )
                            )
                    )
            );
 
        for (DataCommands.DataProvider provider : DataCommands.SOURCE_PROVIDERS) {
            parent.then(
                provider.wrap(
                    Commands.literal("data"),
                    p -> p.then(
                        Commands.argument("path", NbtPathArgument.nbtPath())
                            .fork(execute, c -> expect(c, expected, checkMatchingData(provider.access(c), NbtPathArgument.getPath(c, "path")) > 0))
                            .executes(createNumericConditionalHandler(expected, c -> checkMatchingData(provider.access(c), NbtPathArgument.getPath(c, "path"))))
                    )
                )
            );
        }
 
        return parent;
    }
 
    private static int countItems(Iterable<? extends SlotProvider> sources, SlotRange slotRange, Predicate<ItemStack> predicate) {
        int count = 0;
 
        for (SlotProvider slotProvider : sources) {
            IntList slots = slotRange.slots();
 
            for (int i = 0; i < slots.size(); i++) {
                int slotId = slots.getInt(i);
                SlotAccess slot = slotProvider.getSlot(slotId);
                if (slot != null) {
                    ItemStack contents = slot.get();
                    if (predicate.test(contents)) {
                        count += contents.getCount();
                    }
                }
            }
        }
 
        return count;
    }
 
    private static int countItems(CommandSourceStack source, BlockPos pos, SlotRange slotRange, Predicate<ItemStack> predicate) throws CommandSyntaxException {
        int count = 0;
        Container container = ItemCommands.getContainer(source, pos, ItemCommands.ERROR_SOURCE_NOT_A_CONTAINER);
        int containerSize = container.getContainerSize();
        IntList slots = slotRange.slots();
 
        for (int i = 0; i < slots.size(); i++) {
            int slotId = slots.getInt(i);
            if (slotId >= 0 && slotId < containerSize) {
                ItemStack contents = container.getItem(slotId);
                if (predicate.test(contents)) {
                    count += contents.getCount();
                }
            }
        }
 
        return count;
    }
 
    private static Command<CommandSourceStack> createNumericConditionalHandler(boolean expected, ExecuteCommand.CommandNumericPredicate condition) {
        return expected ? c -> {
            int count = condition.test(c);
            if (count > 0) {
                c.getSource().sendSuccess(() -> Component.translatable("commands.execute.conditional.pass_count", count), false);
                return count;
            } else {
                throw ERROR_CONDITIONAL_FAILED.create();
            }
        } : c -> {
            int count = condition.test(c);
            if (count == 0) {
                c.getSource().sendSuccess(() -> Component.translatable("commands.execute.conditional.pass"), false);
                return 1;
            } else {
                throw ERROR_CONDITIONAL_FAILED_COUNT.create(count);
            }
        };
    }
 
    private static int checkMatchingData(DataAccessor accessor, NbtPathArgument.NbtPath path) throws CommandSyntaxException {
        return path.countMatching(accessor.getData());
    }
 
    private static boolean checkScore(CommandContext<CommandSourceStack> context, ExecuteCommand.IntBiPredicate operation) throws CommandSyntaxException {
        ScoreHolder target = ScoreHolderArgument.getName(context, "target");
        Objective targetObjective = ObjectiveArgument.getObjective(context, "targetObjective");
        ScoreHolder source = ScoreHolderArgument.getName(context, "source");
        Objective sourceObjective = ObjectiveArgument.getObjective(context, "sourceObjective");
        Scoreboard scoreboard = context.getSource().getServer().getScoreboard();
        ReadOnlyScoreInfo a = scoreboard.getPlayerScoreInfo(target, targetObjective);
        ReadOnlyScoreInfo b = scoreboard.getPlayerScoreInfo(source, sourceObjective);
        return a != null && b != null ? operation.test(a.value(), b.value()) : false;
    }
 
    private static boolean checkScore(CommandContext<CommandSourceStack> context, MinMaxBounds.Ints range) throws CommandSyntaxException {
        ScoreHolder target = ScoreHolderArgument.getName(context, "target");
        Objective targetObjective = ObjectiveArgument.getObjective(context, "targetObjective");
        Scoreboard scoreboard = context.getSource().getServer().getScoreboard();
        ReadOnlyScoreInfo scoreInfo = scoreboard.getPlayerScoreInfo(target, targetObjective);
        return scoreInfo == null ? false : range.matches(scoreInfo.value());
    }
 
    private static boolean checkStopwatch(CommandContext<CommandSourceStack> context, MinMaxBounds.Doubles range) throws CommandSyntaxException {
        Identifier id = IdentifierArgument.getId(context, "id");
        Stopwatches stopwatches = context.getSource().getServer().getStopwatches();
        Stopwatch stopwatch = stopwatches.get(id);
        if (stopwatch == null) {
            throw StopwatchCommand.ERROR_DOES_NOT_EXIST.create(id);
        } else {
            long currentTime = Stopwatches.currentTime();
            double elapsedSeconds = stopwatch.elapsedSeconds(currentTime);
            return range.matches(elapsedSeconds);
        }
    }
 
    private static boolean checkCustomPredicate(CommandSourceStack source, Holder<LootItemCondition> predicate) {
        ServerLevel level = source.getLevel();
        LootParams lootParams = new LootParams.Builder(level)
            .withParameter(LootContextParams.ORIGIN, source.getPosition())
            .withOptionalParameter(LootContextParams.THIS_ENTITY, source.getEntity())
            .create(LootContextParamSets.COMMAND);
        LootContext context = new LootContext.Builder(lootParams).create(Optional.empty());
        context.pushVisitedElement(LootContext.createVisitedEntry(predicate.value()));
        return predicate.value().test(context);
    }
 
    private static Collection<CommandSourceStack> expect(CommandContext<CommandSourceStack> context, boolean expected, boolean result) {
        return (Collection<CommandSourceStack>)(result == expected ? Collections.singleton(context.getSource()) : Collections.emptyList());
    }
 
    private static ArgumentBuilder<CommandSourceStack, ?> addConditional(
        CommandNode<CommandSourceStack> root, ArgumentBuilder<CommandSourceStack, ?> argument, boolean expected, ExecuteCommand.CommandPredicate predicate
    ) {
        return argument.fork(root, c -> expect(c, expected, predicate.test(c))).executes(c -> {
            if (expected == predicate.test(c)) {
                c.getSource().sendSuccess(() -> Component.translatable("commands.execute.conditional.pass"), false);
                return 1;
            } else {
                throw ERROR_CONDITIONAL_FAILED.create();
            }
        });
    }
 
    private static ArgumentBuilder<CommandSourceStack, ?> addIfBlocksConditional(
        CommandNode<CommandSourceStack> root, ArgumentBuilder<CommandSourceStack, ?> argument, boolean expected, boolean skipAir
    ) {
        return argument.fork(root, c -> expect(c, expected, checkRegions(c, skipAir).isPresent()))
            .executes(expected ? c -> checkIfRegions(c, skipAir) : c -> checkUnlessRegions(c, skipAir));
    }
 
    private static int checkIfRegions(CommandContext<CommandSourceStack> context, boolean skipAir) throws CommandSyntaxException {
        OptionalInt count = checkRegions(context, skipAir);
        if (count.isPresent()) {
            context.getSource().sendSuccess(() -> Component.translatable("commands.execute.conditional.pass_count", count.getAsInt()), false);
            return count.getAsInt();
        } else {
            throw ERROR_CONDITIONAL_FAILED.create();
        }
    }
 
    private static int checkUnlessRegions(CommandContext<CommandSourceStack> context, boolean skipAir) throws CommandSyntaxException {
        OptionalInt count = checkRegions(context, skipAir);
        if (count.isPresent()) {
            throw ERROR_CONDITIONAL_FAILED_COUNT.create(count.getAsInt());
        } else {
            context.getSource().sendSuccess(() -> Component.translatable("commands.execute.conditional.pass"), false);
            return 1;
        }
    }
 
    private static OptionalInt checkRegions(CommandContext<CommandSourceStack> context, boolean skipAir) throws CommandSyntaxException {
        return checkRegions(
            context.getSource().getLevel(),
            BlockPosArgument.getLoadedBlockPos(context, "start"),
            BlockPosArgument.getLoadedBlockPos(context, "end"),
            BlockPosArgument.getLoadedBlockPos(context, "destination"),
            skipAir
        );
    }
 
    private static OptionalInt checkRegions(ServerLevel level, BlockPos startPos, BlockPos endPos, BlockPos destPos, boolean skipAir) throws CommandSyntaxException {
        BoundingBox from = BoundingBox.fromCorners(startPos, endPos);
        BoundingBox destination = BoundingBox.fromCorners(destPos, destPos.offset(from.getLength()));
        BlockPos offset = new BlockPos(destination.minX() - from.minX(), destination.minY() - from.minY(), destination.minZ() - from.minZ());
        long area = (long)from.getXSpan() * from.getYSpan() * from.getZSpan();
        if (area > 32768L) {
            throw ERROR_AREA_TOO_LARGE.create(32768, area);
        } else {
            int count = 0;
            RegistryAccess registryAccess = level.registryAccess();
 
            try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(LOGGER)) {
                for (int z = from.minZ(); z <= from.maxZ(); z++) {
                    for (int y = from.minY(); y <= from.maxY(); y++) {
                        for (int x = from.minX(); x <= from.maxX(); x++) {
                            BlockPos sourcePos = new BlockPos(x, y, z);
                            BlockPos destinationPos = sourcePos.offset(offset);
                            BlockState sourceBlock = level.getBlockState(sourcePos);
                            if (!skipAir || !sourceBlock.is(Blocks.AIR)) {
                                if (sourceBlock != level.getBlockState(destinationPos)) {
                                    return OptionalInt.empty();
                                }
 
                                BlockEntity sourceBlockEntity = level.getBlockEntity(sourcePos);
                                BlockEntity destinationBlockEntity = level.getBlockEntity(destinationPos);
                                if (sourceBlockEntity != null) {
                                    if (destinationBlockEntity == null) {
                                        return OptionalInt.empty();
                                    }
 
                                    if (destinationBlockEntity.getType() != sourceBlockEntity.getType()) {
                                        return OptionalInt.empty();
                                    }
 
                                    if (!sourceBlockEntity.components().equals(destinationBlockEntity.components())) {
                                        return OptionalInt.empty();
                                    }
 
                                    TagValueOutput sourceOutput = TagValueOutput.createWithContext(
                                        reporter.forChild(sourceBlockEntity.problemPath()), registryAccess
                                    );
                                    sourceBlockEntity.saveCustomOnly(sourceOutput);
                                    CompoundTag sourceTag = sourceOutput.buildResult();
                                    TagValueOutput destinationOutput = TagValueOutput.createWithContext(
                                        reporter.forChild(destinationBlockEntity.problemPath()), registryAccess
                                    );
                                    destinationBlockEntity.saveCustomOnly(destinationOutput);
                                    CompoundTag destinationTag = destinationOutput.buildResult();
                                    if (!sourceTag.equals(destinationTag)) {
                                        return OptionalInt.empty();
                                    }
                                }
 
                                count++;
                            }
                        }
                    }
                }
            }
 
            return OptionalInt.of(count);
        }
    }
 
    private static RedirectModifier<CommandSourceStack> expandOneToOneEntityRelation(Function<Entity, Optional<Entity>> unpacker) {
        return context -> {
            CommandSourceStack source = context.getSource();
            Entity entity = source.getEntity();
            return entity == null ? List.of() : unpacker.apply(entity).filter(e -> !e.isRemoved()).map(e -> List.of(source.withEntity(e))).orElse(List.of());
        };
    }
 
    private static RedirectModifier<CommandSourceStack> expandOneToManyEntityRelation(Function<Entity, Stream<Entity>> unpacker) {
        return context -> {
            CommandSourceStack source = context.getSource();
            Entity entity = source.getEntity();
            return entity == null ? List.of() : unpacker.apply(entity).filter(e -> !e.isRemoved()).map(source::withEntity).toList();
        };
    }
 
    private static LiteralArgumentBuilder<CommandSourceStack> createRelationOperations(
        CommandNode<CommandSourceStack> execute, LiteralArgumentBuilder<CommandSourceStack> on
    ) {
        return on.then(
                Commands.literal("owner")
                    .fork(
                        execute,
                        expandOneToOneEntityRelation(
                            e -> e instanceof OwnableEntity ownableEntity ? Optional.ofNullable(ownableEntity.getOwner()) : Optional.empty()
                        )
                    )
            )
            .then(
                Commands.literal("leasher")
                    .fork(
                        execute,
                        expandOneToOneEntityRelation(e -> e instanceof Leashable leashable ? Optional.ofNullable(leashable.getLeashHolder()) : Optional.empty())
                    )
            )
            .then(
                Commands.literal("target")
                    .fork(
                        execute,
                        expandOneToOneEntityRelation(e -> e instanceof Targeting targeting ? Optional.ofNullable(targeting.getTarget()) : Optional.empty())
                    )
            )
            .then(
                Commands.literal("attacker")
                    .fork(
                        execute,
                        expandOneToOneEntityRelation(
                            e -> e instanceof Attackable attackable ? Optional.ofNullable(attackable.getLastAttacker()) : Optional.empty()
                        )
                    )
            )
            .then(Commands.literal("vehicle").fork(execute, expandOneToOneEntityRelation(e -> Optional.ofNullable(e.getVehicle()))))
            .then(Commands.literal("controller").fork(execute, expandOneToOneEntityRelation(e -> Optional.ofNullable(e.getControllingPassenger()))))
            .then(
                Commands.literal("origin")
                    .fork(
                        execute,
                        expandOneToOneEntityRelation(e -> e instanceof TraceableEntity traceable ? Optional.ofNullable(traceable.getOwner()) : Optional.empty())
                    )
            )
            .then(Commands.literal("passengers").fork(execute, expandOneToManyEntityRelation(e -> e.getPassengers().stream())));
    }
 
    private static CommandSourceStack spawnEntityAndRedirect(CommandSourceStack source, Holder.Reference<EntityType<?>> type) throws CommandSyntaxException {
        Entity entity = SummonCommand.createEntity(source, type, source.getPosition(), new CompoundTag(), true);
        return source.withEntity(entity);
    }
 
    public static <T extends ExecutionCommandSource<T>> void scheduleFunctionConditionsAndTest(
        T originalSource,
        List<T> currentSources,
        Function<T, T> functionContextModifier,
        IntPredicate check,
        ContextChain<T> currentStep,
        @Nullable CompoundTag parameters,
        ExecutionControl<T> output,
        InCommandFunction<CommandContext<T>, Collection<CommandFunction<T>>> functionGetter,
        ChainModifiers modifiers
    ) {
        List<T> filteredSources = new ArrayList<>(currentSources.size());
 
        Collection<CommandFunction<T>> functionsToRun;
        try {
            functionsToRun = functionGetter.apply(currentStep.getTopContext().copyFor(originalSource));
        } catch (CommandSyntaxException var18) {
            originalSource.handleError(var18, modifiers.isForked(), output.tracer());
            return;
        }
 
        int functionCount = functionsToRun.size();
        if (functionCount != 0) {
            List<InstantiatedFunction<T>> instantiatedFunctions = new ArrayList<>(functionCount);
 
            try {
                for (CommandFunction<T> function : functionsToRun) {
                    try {
                        instantiatedFunctions.add(function.instantiate(parameters, originalSource.dispatcher()));
                    } catch (FunctionInstantiationException var17) {
                        throw ERROR_FUNCTION_CONDITION_INSTANTATION_FAILURE.create(function.id(), var17.messageComponent());
                    }
                }
            } catch (CommandSyntaxException var19) {
                originalSource.handleError(var19, modifiers.isForked(), output.tracer());
            }
 
            for (T source : currentSources) {
                T newFunctionContext = (T)functionContextModifier.apply(source.clearCallbacks());
                CommandResultCallback functionCallback = (success, result) -> {
                    if (check.test(result)) {
                        filteredSources.add(source);
                    }
                };
                output.queueNext(new IsolatedCall<>(o -> {
                    for (InstantiatedFunction<T> function : instantiatedFunctions) {
                        o.queueNext(new CallFunction<>(function, o.currentFrame().returnValueConsumer(), true).bind(newFunctionContext));
                    }
 
                    o.queueNext(FallthroughTask.instance());
                }, functionCallback));
            }
 
            ContextChain<T> nextStage = currentStep.nextStage();
            String input = currentStep.getTopContext().getInput();
            output.queueNext(new BuildContexts.Continuation<>(input, nextStage, modifiers, originalSource, filteredSources));
        }
    }
 
    @FunctionalInterface
    private interface CommandNumericPredicate {
        int test(CommandContext<CommandSourceStack> c) throws CommandSyntaxException;
    }
 
    @FunctionalInterface
    private interface CommandPredicate {
        boolean test(CommandContext<CommandSourceStack> c) throws CommandSyntaxException;
    }
 
    private static class ExecuteIfFunctionCustomModifier implements CustomModifierExecutor.ModifierAdapter<CommandSourceStack> {
        private final IntPredicate check;
 
        private ExecuteIfFunctionCustomModifier(boolean check) {
            this.check = check ? value -> value != 0 : value -> value == 0;
        }
 
        public void apply(
            CommandSourceStack originalSource,
            List<CommandSourceStack> currentSources,
            ContextChain<CommandSourceStack> currentStep,
            ChainModifiers modifiers,
            ExecutionControl<CommandSourceStack> output
        ) {
            ExecuteCommand.scheduleFunctionConditionsAndTest(
                originalSource,
                currentSources,
                FunctionCommand::modifySenderForExecution,
                this.check,
                currentStep,
                null,
                output,
                c -> FunctionArgument.getFunctions(c, "name"),
                modifiers
            );
        }
    }
 
    @FunctionalInterface
    private interface IntBiPredicate {
        boolean test(int a, int b);
    }
}

引用的其他类

  • MinMaxBounds

    • 引用位置: 参数
  • CommandBuildContext

    • 引用位置: 参数
  • CommandSourceStack

    • 引用位置: 参数/返回值
  • Commands

    • 引用位置: 方法调用
    • 关联成员: Commands.argument(), Commands.hasPermission(), Commands.literal()
  • ExecutionCommandSource

    • 引用位置: 返回值
  • DimensionArgument

    • 引用位置: 方法调用
    • 关联成员: DimensionArgument.dimension(), DimensionArgument.getDimension()
  • EntityAnchorArgument

    • 引用位置: 方法调用
    • 关联成员: EntityAnchorArgument.anchor(), EntityAnchorArgument.getAnchor()
  • EntityArgument

    • 引用位置: 方法调用
    • 关联成员: EntityArgument.entities(), EntityArgument.getEntities(), EntityArgument.getOptionalEntities()
  • HeightmapTypeArgument

    • 引用位置: 方法调用
    • 关联成员: HeightmapTypeArgument.getHeightmap(), HeightmapTypeArgument.heightmap()
  • IdentifierArgument

    • 引用位置: 方法调用
    • 关联成员: IdentifierArgument.getId(), IdentifierArgument.id()
  • NbtPathArgument

    • 引用位置: 参数/方法调用
    • 关联成员: NbtPathArgument.getPath(), NbtPathArgument.nbtPath()
  • ObjectiveArgument

    • 引用位置: 方法调用
    • 关联成员: ObjectiveArgument.getObjective(), ObjectiveArgument.objective()
  • RangeArgument

    • 引用位置: 方法调用
    • 关联成员: RangeArgument.Floats.getRange(), RangeArgument.Ints.getRange(), RangeArgument.floatRange(), RangeArgument.intRange()
  • ResourceArgument

    • 引用位置: 方法调用
    • 关联成员: ResourceArgument.getSummonableEntityType(), ResourceArgument.resource()
  • ResourceOrIdArgument

    • 引用位置: 方法调用
    • 关联成员: ResourceOrIdArgument.getLootPredicate(), ResourceOrIdArgument.lootPredicate()
  • ResourceOrTagArgument

    • 引用位置: 方法调用
    • 关联成员: ResourceOrTagArgument.getResourceOrTag(), ResourceOrTagArgument.resourceOrTag()
  • ScoreHolderArgument

    • 引用位置: 方法调用
    • 关联成员: ScoreHolderArgument.getName(), ScoreHolderArgument.getNamesWithDefaultWildcard(), ScoreHolderArgument.scoreHolder(), ScoreHolderArgument.scoreHolders()
  • SlotsArgument

    • 引用位置: 方法调用
    • 关联成员: SlotsArgument.getSlots(), SlotsArgument.slots()
  • BlockPredicateArgument

    • 引用位置: 方法调用
    • 关联成员: BlockPredicateArgument.blockPredicate(), BlockPredicateArgument.getBlockPredicate()
  • BlockPosArgument

    • 引用位置: 方法调用
    • 关联成员: BlockPosArgument.blockPos(), BlockPosArgument.getBlockPos(), BlockPosArgument.getLoadedBlockPos()
  • RotationArgument

    • 引用位置: 方法调用
    • 关联成员: RotationArgument.getRotation(), RotationArgument.rotation()
  • SwizzleArgument

    • 引用位置: 方法调用
    • 关联成员: SwizzleArgument.getSwizzle(), SwizzleArgument.swizzle()
  • Vec3Argument

    • 引用位置: 方法调用
    • 关联成员: Vec3Argument.getVec3(), Vec3Argument.vec3()
  • FunctionArgument

    • 引用位置: 方法调用
    • 关联成员: FunctionArgument.functions(), FunctionArgument.getFunctions()
  • ItemPredicateArgument

    • 引用位置: 方法调用
    • 关联成员: ItemPredicateArgument.getItemPredicate(), ItemPredicateArgument.itemPredicate()
  • ChainModifiers

    • 引用位置: 参数
  • ExecutionControl

    • 引用位置: 参数
  • FallthroughTask

    • 引用位置: 方法调用
    • 关联成员: FallthroughTask.instance()
  • CommandFunction

    • 引用位置: 参数
  • SuggestionProviders

    • 引用位置: 方法调用
    • 关联成员: SuggestionProviders.cast()
  • BlockPos

    • 引用位置: 参数/构造调用
    • 关联成员: BlockPos()
  • Holder

    • 引用位置: 参数
  • SectionPos

    • 引用位置: 方法调用
    • 关联成员: SectionPos.blockToSectionCoord()
  • ByteTag

    • 引用位置: 方法调用
    • 关联成员: ByteTag.valueOf()
  • CompoundTag

    • 引用位置: 参数/构造调用
    • 关联成员: CompoundTag()
  • DoubleTag

    • 引用位置: 方法调用
    • 关联成员: DoubleTag.valueOf()
  • FloatTag

    • 引用位置: 方法调用
    • 关联成员: FloatTag.valueOf()
  • IntTag

    • 引用位置: 方法调用
    • 关联成员: IntTag.valueOf()
  • LongTag

    • 引用位置: 方法调用
    • 关联成员: LongTag.valueOf()
  • ShortTag

    • 引用位置: 方法调用
    • 关联成员: ShortTag.valueOf()
  • Tag

    • 引用位置: 参数
  • Component

    • 引用位置: 方法调用
    • 关联成员: Component.translatable(), Component.translatableEscape()
  • CustomBossEvent

    • 引用位置: 参数
  • BossBarCommands

    • 引用位置: 方法调用
    • 关联成员: BossBarCommands.getBossBar()
  • InCommandFunction

    • 引用位置: 参数
  • ItemCommands

    • 引用位置: 方法调用
    • 关联成员: ItemCommands.getContainer()
  • SummonCommand

    • 引用位置: 方法调用
    • 关联成员: SummonCommand.createEntity()
  • DataAccessor

    • 引用位置: 参数
  • ServerLevel

    • 引用位置: 参数
  • Mth

    • 引用位置: 方法调用
    • 关联成员: Mth.floor()
  • ProblemReporter

    • 引用位置: 方法调用/构造调用
    • 关联成员: ProblemReporter.ScopedCollector(), ScopedCollector()
  • Stopwatches

    • 引用位置: 方法调用
    • 关联成员: Stopwatches.currentTime()
  • Entity

    • 引用位置: 参数
  • EntityType

    • 引用位置: 参数
  • SlotProvider

    • 引用位置: 参数
  • SlotRange

    • 引用位置: 参数
  • ItemStack

    • 引用位置: 参数
  • ChunkPos

    • 引用位置: 方法调用
    • 关联成员: ChunkPos.containing()
  • BlockInWorld

    • 引用位置: 构造调用
    • 关联成员: BlockInWorld()
  • BoundingBox

    • 引用位置: 方法调用
    • 关联成员: BoundingBox.fromCorners()
  • TagValueOutput

    • 引用位置: 方法调用
    • 关联成员: TagValueOutput.createWithContext()
  • LootContext

    • 引用位置: 方法调用/构造调用
    • 关联成员: Builder(), LootContext.Builder(), LootContext.createVisitedEntry()
  • LootParams

    • 引用位置: 方法调用/构造调用
    • 关联成员: Builder(), LootParams.Builder()
  • LootItemCondition

    • 引用位置: 参数
  • Vec3

    • 引用位置: 构造调用
    • 关联成员: Vec3()
  • Objective

    • 引用位置: 参数
  • ScoreHolder

    • 引用位置: 参数