use of org.lanternpowered.server.entity.LanternLiving in project LanternServer by LanternPowered.
the class CreatureEntityProtocol method spawn.
@Override
protected void spawn(EntityProtocolUpdateContext context) {
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();
final double headYaw = headRot != null ? headRot.getY() : 0;
context.sendToAllExceptSelf(() -> new MessagePlayOutSpawnMob(getRootEntityId(), this.entity.getUniqueId(), getMobType(), pos, wrapAngle(yaw), wrapAngle(pitch), wrapAngle(headYaw), vel, fillParameters(true)));
spawnWithEquipment(context);
}
use of org.lanternpowered.server.entity.LanternLiving 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);
}
use of org.lanternpowered.server.entity.LanternLiving in project LanternServer by LanternPowered.
the class EntityProtocol method handleEvent.
@Override
protected void handleEvent(EntityProtocolUpdateContext context, EntityEvent event) {
if (event instanceof CollectEntityEvent) {
final LanternLiving collector = (LanternLiving) ((CollectEntityEvent) event).getCollector();
context.getId(collector).ifPresent(id -> {
final int count = ((CollectEntityEvent) event).getCollectedItemsCount();
context.sendToAll(() -> new MessagePlayOutEntityCollectItem(id, getRootEntityId(), count));
});
} else {
super.handleEvent(context, event);
}
}
Aggregations