Search in sources :

Example 1 with TimerCount

use of me.xjcyan1de.cyanbot.utils.schedule.TimerCount in project CyanBot by XjCyan1de.

the class CommandWhere method execute.

@Override
public void execute(CommandEvent event) {
    final Bot bot = event.getBot();
    final Entity entity = event.has(0, "я") ? bot.getWorld().getPlayer(event.getSender()) : bot.getWorld().getPlayer(event.arg(0));
    if (entity != null) {
        Schedule.cancel(timerTask);
        final Location loc = bot.getLoc();
        timerTask = Schedule.timer(new TimerCount(() -> {
            final float pitch = loc.getPitch();
            final float yaw = loc.getYaw();
            loc.setDir(entity.getX() - loc.getX(), entity.getY() - loc.getY(), entity.getZ() - loc.getZ());
            loc.setYaw(smoothly(loc.getYaw(), yaw));
            loc.setPitch(smoothly(loc.getPitch(), pitch));
            System.out.println(loc.getYaw() + " " + loc.getPitch());
        }, 100) {

            @Override
            public boolean cancel() {
                timerTask = null;
                bot.sendMessage("Та вижу я!");
                return super.cancel();
            }
        }, 50, 50);
    }
}
Also used : Entity(me.xjcyan1de.cyanbot.world.Entity) Bot(me.xjcyan1de.cyanbot.Bot) TimerCount(me.xjcyan1de.cyanbot.utils.schedule.TimerCount) Location(me.xjcyan1de.cyanbot.world.Location)

Aggregations

Bot (me.xjcyan1de.cyanbot.Bot)1 TimerCount (me.xjcyan1de.cyanbot.utils.schedule.TimerCount)1 Entity (me.xjcyan1de.cyanbot.world.Entity)1 Location (me.xjcyan1de.cyanbot.world.Location)1