Search in sources :

Example 16 with PacketPlayOutEntityHeadRotation

use of net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_16_R3 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, new Vec3D(motion.getX(), motion.getY(), motion.getZ())));
    connection.sendPacket(new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw())));
    PacketPlayOutEntityEquipment equipment = getEquipmentPacket();
    if (equipment != null)
        connection.sendPacket(equipment);
    // 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_16_R3.PacketPlayOutEntity.PacketPlayOutEntityLook)

Example 17 with PacketPlayOutEntityHeadRotation

use of net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation in project MechanicsMain by WeaponMechanics.

the class FakeEntity_1_16_R3 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.setHeadRotation(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_16_R3.PacketPlayOutEntity.PacketPlayOutEntityLook)

Example 18 with PacketPlayOutEntityHeadRotation

use of net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@SuppressWarnings("resource")
@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final NBTTagCompound tag = new NBTTagCompound();
    tag.setString("id", entityID);
    final World world = ((CraftWorld) w).getHandle();
    final Optional<Entity> entity = EntityTypes.a(tag, world);
    if (!entity.isPresent()) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.get().setPositionRotation(x, y, z, yaw, 0);
    world.addEntity(entity.get(), SpawnReason.SPAWNER_EGG);
    final PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(entity.get(), (byte) yaw);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(rotation);
}
Also used : Entity(net.minecraft.server.v1_16_R3.Entity) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) World(net.minecraft.server.v1_16_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 19 with PacketPlayOutEntityHeadRotation

use of net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final NBTTagCompound tag = new NBTTagCompound();
    tag.setString("id", entityID);
    final World world = ((CraftWorld) w).getHandle();
    final Entity entity = EntityTypes.a(tag, world);
    if (entity == null) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.setPositionRotation(x, y, z, yaw, 0);
    world.addEntity(entity, SpawnReason.SPAWNER_EGG);
    final PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(entity, (byte) yaw);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(rotation);
}
Also used : Entity(net.minecraft.server.v1_8_R3.Entity) NBTTagCompound(net.minecraft.server.v1_8_R3.NBTTagCompound) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) World(net.minecraft.server.v1_8_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 20 with PacketPlayOutEntityHeadRotation

use of net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@SuppressWarnings("resource")
@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final NBTTagCompound tag = new NBTTagCompound();
    tag.setString("id", entityID);
    final World world = ((CraftWorld) w).getHandle();
    final Optional<Entity> entity = EntityTypes.a(tag, world);
    if (!entity.isPresent()) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.get().setPositionRotation(x, y, z, yaw, 0);
    world.addEntity(entity.get(), SpawnReason.SPAWNER_EGG);
    final PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(entity.get(), (byte) yaw);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(rotation);
}
Also used : Entity(net.minecraft.server.v1_16_R1.Entity) NBTTagCompound(net.minecraft.server.v1_16_R1.NBTTagCompound) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_16_R1.PacketPlayOutEntityHeadRotation) CraftPlayer(org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer) CraftWorld(org.bukkit.craftbukkit.v1_16_R1.CraftWorld) World(net.minecraft.server.v1_16_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R1.CraftWorld)

Aggregations

PacketPlayOutEntityLook (net.minecraft.server.v1_16_R3.PacketPlayOutEntity.PacketPlayOutEntityLook)5 PacketPlayOutEntityHeadRotation (net.minecraft.server.v1_16_R3.PacketPlayOutEntityHeadRotation)5 PacketPlayOutEntityTeleport (net.minecraft.server.v1_16_R3.PacketPlayOutEntityTeleport)3 PacketPlayOutRelEntityMoveLook (net.minecraft.server.v1_16_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook)2 Entity (net.minecraft.server.v1_10_R1.Entity)1 NBTTagCompound (net.minecraft.server.v1_10_R1.NBTTagCompound)1 PacketPlayOutEntityHeadRotation (net.minecraft.server.v1_10_R1.PacketPlayOutEntityHeadRotation)1 World (net.minecraft.server.v1_10_R1.World)1 Entity (net.minecraft.server.v1_11_R1.Entity)1 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)1 PacketPlayOutEntityHeadRotation (net.minecraft.server.v1_11_R1.PacketPlayOutEntityHeadRotation)1 World (net.minecraft.server.v1_11_R1.World)1 Entity (net.minecraft.server.v1_12_R1.Entity)1 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)1 PacketPlayOutEntityHeadRotation (net.minecraft.server.v1_12_R1.PacketPlayOutEntityHeadRotation)1 World (net.minecraft.server.v1_12_R1.World)1 Entity (net.minecraft.server.v1_13_R2.Entity)1 NBTTagCompound (net.minecraft.server.v1_13_R2.NBTTagCompound)1 PacketPlayOutEntityHeadRotation (net.minecraft.server.v1_13_R2.PacketPlayOutEntityHeadRotation)1 World (net.minecraft.server.v1_13_R2.World)1