use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSpawnPlayer in project LanternServer by LanternPowered.
the class HumanoidEntityProtocol method spawn.
@Override
protected void spawn(EntityProtocolUpdateContext context) {
final int entityId = getRootEntityId();
final Vector3d rot = this.entity.getRotation();
final Vector3d headRot = this.entity instanceof LanternLiving ? ((LanternLiving) this.entity).getHeadRotation() : null;
final Vector3d pos = this.entity.getPosition();
final Vector3d vel = this.entity.getVelocity();
final double yaw = rot.getY();
final double pitch = headRot != null ? headRot.getX() : rot.getX();
context.sendToAllExceptSelf(() -> new MessagePlayOutSpawnPlayer(entityId, this.entity.getUniqueId(), pos, wrapAngle(yaw), wrapAngle(pitch), fillParameters(true)));
if (headRot != null) {
context.sendToAllExceptSelf(() -> new MessagePlayOutEntityHeadLook(entityId, wrapAngle(headRot.getY())));
}
if (!vel.equals(Vector3d.ZERO)) {
context.sendToAllExceptSelf(() -> new MessagePlayOutEntityVelocity(entityId, vel.getX(), vel.getY(), vel.getZ()));
}
spawnWithEquipment(context);
}
Aggregations