Search in sources :

Example 6 with PacketPlayOutEntityLook

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntity.PacketPlayOutEntityLook in project DragonsOnline by UniverseCraft.

the class PlayerNPC116R3 method refreshRotationFor.

public void refreshRotationFor(Player player) {
    // resync
    location = getEntity().getLocation();
    location.setYaw(originalYaw);
    PacketPlayOutEntityTeleport tp = new PacketPlayOutEntityTeleport();
    setField(tp, "a", getEntityId());
    setField(tp, "b", location.getX());
    setField(tp, "c", location.getY());
    setField(tp, "d", location.getZ());
    setField(tp, "e", getPacketRotation(location.getYaw()));
    setField(tp, "f", getPacketRotation(location.getPitch()));
    setField(tp, "g", handle.isOnGround());
    PacketPlayOutEntityLook look = new PacketPlayOutEntityLook(getEntityId(), getPacketRotation(location.getYaw()), getPacketRotation(location.getPitch()), handle.isOnGround());
    sync(() -> sendPacket(tp, player));
    sync(() -> sendPacket(look, player));
    sync(() -> sendPacket(new PacketPlayOutEntityHeadRotation(handle, getPacketRotation(location.getYaw())), player));
}
Also used : PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation) PacketPlayOutEntityTeleport(net.minecraft.server.v1_16_R3.PacketPlayOutEntityTeleport) PacketPlayOutEntityLook(net.minecraft.server.v1_16_R3.PacketPlayOutEntity.PacketPlayOutEntityLook)

Example 7 with PacketPlayOutEntityLook

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntity.PacketPlayOutEntityLook in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_10_R1 method setRotation.

@Override
public void setRotation(float yaw, float pitch) {
    if (offset != null) {
        yaw += offset.getYaw();
        pitch += offset.getPitch();
    }
    location.setYaw(yaw);
    location.setPitch(pitch);
    entity.h(yaw);
    entity.yaw = yaw;
    entity.pitch = pitch;
    byte byteYaw = convertYaw(yaw);
    PacketPlayOutEntityLook packet = new PacketPlayOutEntityLook(cache, byteYaw, convertPitch(pitch), false);
    PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, byteYaw);
    sendPackets(packet, head);
    if (type == EntityType.ARMOR_STAND)
        updateMeta();
}
Also used : PacketPlayOutEntityLook(net.minecraft.server.v1_10_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)

Example 8 with PacketPlayOutEntityLook

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntity.PacketPlayOutEntityLook in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_10_R1 method show.

@Override
public void show(@NotNull Player player) {
    PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
    if (connections.contains(connection))
        throw new IllegalArgumentException();
    connection.sendPacket(type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0));
    connection.sendPacket(new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true));
    connection.sendPacket(new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false));
    connection.sendPacket(new PacketPlayOutEntityVelocity(cache, motion.getX(), motion.getY(), motion.getZ()));
    connection.sendPacket(new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw())));
    PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
    if (equipment != null) {
        for (PacketPlayOutEntityEquipment packet : equipment) {
            connection.sendPacket(packet);
        }
    }
    // Inject the player's packet connection into this listener, so we can
    // show the player position/velocity/rotation changes
    connections.add(connection);
}
Also used : PacketPlayOutEntityLook(net.minecraft.server.v1_10_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)

Example 9 with PacketPlayOutEntityLook

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntity.PacketPlayOutEntityLook in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_11_R1 method setRotation.

@Override
public void setRotation(float yaw, float pitch) {
    if (offset != null) {
        yaw += offset.getYaw();
        pitch += offset.getPitch();
    }
    location.setYaw(yaw);
    location.setPitch(pitch);
    entity.h(yaw);
    entity.yaw = yaw;
    entity.pitch = pitch;
    byte byteYaw = convertYaw(yaw);
    PacketPlayOutEntityLook packet = new PacketPlayOutEntityLook(cache, byteYaw, convertPitch(pitch), false);
    PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, byteYaw);
    sendPackets(packet, head);
    if (type == EntityType.ARMOR_STAND)
        updateMeta();
}
Also used : PacketPlayOutEntityLook(net.minecraft.server.v1_11_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)

Example 10 with PacketPlayOutEntityLook

use of net.minecraft.server.v1_9_R2.PacketPlayOutEntity.PacketPlayOutEntityLook in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_11_R1 method show.

public void show() {
    // Construct the packets out of the loop to save resources, they will
    // be the same for each Player.
    Packet<?> spawn = type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0);
    PacketPlayOutEntityMetadata meta = new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true);
    PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw()));
    PacketPlayOutEntityLook look = new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false);
    PacketPlayOutEntityVelocity velocity = new PacketPlayOutEntityVelocity(cache, motion.getX(), motion.getY(), motion.getZ());
    for (Player temp : DistanceUtil.getPlayersInRange(location)) {
        PlayerConnection connection = ((CraftPlayer) temp).getHandle().playerConnection;
        if (connections.contains(connection)) {
            continue;
        }
        connection.sendPacket(spawn);
        connection.sendPacket(meta);
        connection.sendPacket(head);
        connection.sendPacket(velocity);
        connection.sendPacket(look);
        PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
        if (equipment != null) {
            for (PacketPlayOutEntityEquipment packet : equipment) {
                connection.sendPacket(packet);
            }
        }
        connections.add(connection);
    }
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer) PacketPlayOutEntityLook(net.minecraft.server.v1_11_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)

Aggregations

Player (org.bukkit.entity.Player)8 PacketPlayOutEntityLook (net.minecraft.server.v1_16_R3.PacketPlayOutEntity.PacketPlayOutEntityLook)4 PacketPlayOutEntityLook (net.minecraft.server.v1_10_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)3 PacketPlayOutEntityLook (net.minecraft.server.v1_11_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)3 PacketPlayOutEntityLook (net.minecraft.server.v1_12_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)3 PacketPlayOutEntityLook (net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook)3 PacketPlayOutEntityLook (net.minecraft.server.v1_14_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)3 PacketPlayOutEntityLook (net.minecraft.server.v1_15_R1.PacketPlayOutEntity.PacketPlayOutEntityLook)3 PacketPlayOutEntityLook (net.minecraft.server.v1_9_R2.PacketPlayOutEntity.PacketPlayOutEntityLook)3 PacketPlayOutEntityHeadRotation (net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation)1 PacketPlayOutEntityTeleport (net.minecraft.server.v1_16_R3.PacketPlayOutEntityTeleport)1 CraftPlayer (org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)1