Search in sources :

Example 1 with Entity

use of me.xjcyan1de.cyanbot.world.Entity in project CyanBot by XjCyan1de.

the class PacketWorldEntityEvents method onMove.

public void onMove(ServerEntityMovementPacket packet, boolean pos, boolean rot) {
    final Entity entity = world.getEntityMap().get(packet.getEntityId());
    if (entity != null) {
        if (pos) {
            entity.addLoc(packet.getMovementX(), packet.getMovementY(), packet.getMovementZ());
            entity.setOnGround(packet.isOnGround());
        }
        if (rot) {
            entity.setYaw(packet.getYaw());
            entity.setPitch(packet.getPitch());
        }
    }
}
Also used : Entity(me.xjcyan1de.cyanbot.world.Entity)

Example 2 with Entity

use of me.xjcyan1de.cyanbot.world.Entity in project CyanBot by XjCyan1de.

the class PacketWorldEntityEvents method on.

@EventHandler
public void on(ServerEntityTeleportPacket packet) {
    final Entity entity = world.getEntityMap().get(packet.getEntityId());
    if (entity != null) {
        entity.setX(packet.getX());
        entity.setY(packet.getY());
        entity.setZ(packet.getZ());
        entity.setPitch(packet.getPitch());
        entity.setYaw(packet.getYaw());
    }
}
Also used : Entity(me.xjcyan1de.cyanbot.world.Entity) EventHandler(me.xjcyan1de.cyanbot.listeners.event.EventHandler)

Example 3 with Entity

use of me.xjcyan1de.cyanbot.world.Entity 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

Entity (me.xjcyan1de.cyanbot.world.Entity)3 Bot (me.xjcyan1de.cyanbot.Bot)1 EventHandler (me.xjcyan1de.cyanbot.listeners.event.EventHandler)1 TimerCount (me.xjcyan1de.cyanbot.utils.schedule.TimerCount)1 Location (me.xjcyan1de.cyanbot.world.Location)1