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());
}
}
}
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());
}
}
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);
}
}
Aggregations