This commit is contained in:
gnembon committed 2022-10-20 14:33:36 +02:00
1 parent ffa4fcf2a6
commit 9f776167e3
23 files changed
+179 -136

No files matched your search

@@ -8,12 +8,13 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.EntitySummonArgument;
import net.minecraft.core.Registry;
import static net.minecraft.commands.Commands.argument;
import static net.minecraft.commands.Commands.literal;
import static net.minecraft.commands.SharedSuggestionProvider.suggest;
import static net.minecraft.commands.arguments.ResourceArgument.getSummonableEntityType;
import static net.minecraft.commands.arguments.ResourceArgument.resource;
public class MobAICommand
{
@@ -21,20 +22,20 @@ public class MobAICommand
{
LiteralArgumentBuilder<CommandSourceStack> command = literal("track").
requires((player) -> CommandHelper.canUseCommand(player, CarpetSettings.commandTrackAI)).
then(argument("entity type", EntitySummonArgument.id()).
then(argument("entity type", resource(commandBuildContext, Registry.ENTITY_TYPE_REGISTRY)).
suggests( (c, b) -> suggest(MobAI.availbleTypes(), b)).
then(literal("clear").executes( (c) ->
{
MobAI.clearTracking(Registry.ENTITY_TYPE.get(EntitySummonArgument.getSummonableEntity(c, "entity type")));
MobAI.clearTracking(getSummonableEntityType(c, "entity type").value());
return 1;
}
)).
then(argument("aspect", StringArgumentType.word()).
suggests( (c, b) -> suggest(MobAI.availableFor(Registry.ENTITY_TYPE.get(EntitySummonArgument.getSummonableEntity(c, "entity type"))),b)).
suggests( (c, b) -> suggest(MobAI.availableFor(getSummonableEntityType(c, "entity type").value()),b)).
executes( (c) -> {
MobAI.startTracking(
Registry.ENTITY_TYPE.get(EntitySummonArgument.getSummonableEntity(c, "entity type")),
getSummonableEntityType(c, "entity type").value(),
MobAI.TrackingType.valueOf(StringArgumentType.getString(c, "aspect").toUpperCase())
);
return 1;