2022-01-04 16:57:57 +01:00
|
|
|
package com.minelittlepony.unicopia.command;
|
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation;
|
|
|
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
|
|
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
2023-09-05 00:40:41 +02:00
|
|
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
2022-01-04 16:57:57 +01:00
|
|
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
2023-07-29 20:54:49 +02:00
|
|
|
|
2022-01-04 16:57:57 +01:00
|
|
|
import net.minecraft.server.command.CommandManager;
|
|
|
|
import net.minecraft.server.command.ServerCommandSource;
|
|
|
|
|
|
|
|
public class EmoteCommand {
|
2023-09-05 00:40:41 +02:00
|
|
|
static LiteralArgumentBuilder<ServerCommandSource> create() {
|
|
|
|
return CommandManager
|
2022-01-04 16:57:57 +01:00
|
|
|
.literal("emote")
|
2023-07-29 20:54:49 +02:00
|
|
|
.then(CommandManager.argument("animation", Animation.argument()).executes(source -> apply(
|
2022-01-04 16:57:57 +01:00
|
|
|
source.getSource(),
|
2023-08-05 16:45:36 +02:00
|
|
|
source.getArgument("animation", Animation.class),
|
|
|
|
Animation.Recipient.ANYONE
|
2022-01-04 16:57:57 +01:00
|
|
|
)
|
|
|
|
).then(CommandManager.argument("duration", IntegerArgumentType.integer(1, 99)).executes(source -> apply(
|
|
|
|
source.getSource(),
|
|
|
|
source.getArgument("animation", Animation.class),
|
2023-08-05 16:45:36 +02:00
|
|
|
Animation.Recipient.ANYONE,
|
|
|
|
IntegerArgumentType.getInteger(source, "duration")
|
|
|
|
)
|
|
|
|
).then(CommandManager.argument("recipient_type", Animation.Recipient.argument()).executes(source -> apply(
|
|
|
|
source.getSource(),
|
|
|
|
source.getArgument("animation", Animation.class),
|
|
|
|
source.getArgument("recipient_type", Animation.Recipient.class),
|
|
|
|
IntegerArgumentType.getInteger(source, "duration")
|
2022-01-04 16:57:57 +01:00
|
|
|
)
|
2023-08-05 16:45:36 +02:00
|
|
|
))
|
2023-09-05 00:40:41 +02:00
|
|
|
));
|
2022-01-04 16:57:57 +01:00
|
|
|
}
|
|
|
|
|
2023-08-05 16:45:36 +02:00
|
|
|
static int apply(ServerCommandSource source, Animation animation, Animation.Recipient recipient) throws CommandSyntaxException {
|
|
|
|
return apply(source, animation, recipient, animation.getDuration());
|
2022-01-04 16:57:57 +01:00
|
|
|
}
|
|
|
|
|
2023-08-05 16:45:36 +02:00
|
|
|
static int apply(ServerCommandSource source, Animation animation, Animation.Recipient recipient, int duration) throws CommandSyntaxException {
|
|
|
|
Pony.of(source.getPlayer()).setAnimation(animation, recipient, duration);
|
2022-01-04 16:57:57 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|