22w42a
This commit is contained in:
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;
|
||||
|
||||
@@ -8,10 +8,10 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
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.commands.arguments.coordinates.BlockPosArgument;
|
||||
import net.minecraft.commands.synchronization.SuggestionProviders;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -19,6 +19,8 @@ import net.minecraft.world.entity.Mob;
|
||||
|
||||
import static net.minecraft.commands.Commands.argument;
|
||||
import static net.minecraft.commands.Commands.literal;
|
||||
import static net.minecraft.commands.arguments.ResourceArgument.getSummonableEntityType;
|
||||
import static net.minecraft.commands.arguments.ResourceArgument.resource;
|
||||
|
||||
public class PerimeterInfoCommand
|
||||
{
|
||||
@@ -35,12 +37,12 @@ public class PerimeterInfoCommand
|
||||
c.getSource(),
|
||||
BlockPosArgument.getSpawnablePos(c, "center position"),
|
||||
null)).
|
||||
then(argument("mob",EntitySummonArgument.id()).
|
||||
then(argument("mob", resource(commandBuildContext, Registry.ENTITY_TYPE_REGISTRY)).
|
||||
suggests(SuggestionProviders.SUMMONABLE_ENTITIES).
|
||||
executes( (c) -> perimeterDiagnose(
|
||||
c.getSource(),
|
||||
BlockPosArgument.getSpawnablePos(c, "center position"),
|
||||
EntitySummonArgument.getSummonableEntity(c, "mob").toString()
|
||||
getSummonableEntityType(c, "mob").key().location().toString()
|
||||
))));
|
||||
dispatcher.register(command);
|
||||
}
|
||||
@@ -58,7 +60,7 @@ public class PerimeterInfoCommand
|
||||
});
|
||||
if (!(baseEntity instanceof Mob))
|
||||
{
|
||||
Messenger.m(source, "r /perimeterinfo requires a mob entity to test agains.");
|
||||
Messenger.m(source, "r /perimeterinfo requires a mob entity to test against.");
|
||||
if (baseEntity != null) baseEntity.discard();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user