Search in sources :

Example 1 with MessagePlayOutSpawnMob

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSpawnMob 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);
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) MessagePlayOutSpawnMob(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSpawnMob) LanternLiving(org.lanternpowered.server.entity.LanternLiving)

Example 2 with MessagePlayOutSpawnMob

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSpawnMob in project LanternServer by LanternPowered.

the class PlayerEntityProtocol method sendStackEntry.

private void sendStackEntry(EntityProtocolUpdateContext context, int index, int type) {
    final ParameterList parameterList = new ByteBufParameterList(ByteBufferAllocator.unpooled());
    parameterList.add(EntityParameters.Base.FLAGS, (byte) 0x20);
    if (type == 55) {
        parameterList.add(EntityParameters.AbstractSlime.SIZE, -1);
    } else if (type == 101) {
        parameterList.add(EntityParameters.Ageable.IS_BABY, true);
    }
    context.sendToAll(() -> new MessagePlayOutSpawnMob(this.passengerStack[index], UUID.randomUUID(), type, getEntity().getPosition(), (byte) 0, (byte) 0, (byte) 0, Vector3d.ZERO, parameterList));
}
Also used : ByteBufParameterList(org.lanternpowered.server.network.entity.parameter.ByteBufParameterList) ParameterList(org.lanternpowered.server.network.entity.parameter.ParameterList) ByteBufParameterList(org.lanternpowered.server.network.entity.parameter.ByteBufParameterList) MessagePlayOutSpawnMob(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSpawnMob)

Aggregations

MessagePlayOutSpawnMob (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSpawnMob)2 Vector3d (com.flowpowered.math.vector.Vector3d)1 LanternLiving (org.lanternpowered.server.entity.LanternLiving)1 ByteBufParameterList (org.lanternpowered.server.network.entity.parameter.ByteBufParameterList)1 ParameterList (org.lanternpowered.server.network.entity.parameter.ParameterList)1