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.CommandDispatcher;
|
|
|
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
|
|
|
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 {
|
|
|
|
static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
|
|
|
dispatcher.register(CommandManager
|
|
|
|
.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(),
|
|
|
|
source.getArgument("animation", Animation.class)
|
|
|
|
)
|
|
|
|
).then(CommandManager.argument("duration", IntegerArgumentType.integer(1, 99)).executes(source -> apply(
|
|
|
|
source.getSource(),
|
|
|
|
source.getArgument("animation", Animation.class),
|
|
|
|
source.getArgument("duration", Integer.class)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int apply(ServerCommandSource source, Animation animation) throws CommandSyntaxException {
|
|
|
|
return apply(source, animation, animation.getDuration());
|
|
|
|
}
|
|
|
|
|
|
|
|
static int apply(ServerCommandSource source, Animation animation, int duration) throws CommandSyntaxException {
|
|
|
|
Pony.of(source.getPlayer()).setAnimation(animation, duration);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|