Search in sources :

Example 31 with Packet

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

the class Block_1_9_R2 method getMultiBlockMaskPacket.

private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
    net.minecraft.server.v1_9_R2.Chunk chunk = ((CraftChunk) blocks.get(0).getChunk()).getHandle();
    // Setup default information
    PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(0, new short[0], chunk);
    PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] changes = new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[blocks.size()];
    for (int i = 0; i < blocks.size(); i++) {
        Block block = blocks.get(i);
        // Where the block is relative to the chunk it is in
        int x = block.getX() & 0xF;
        int y = block.getY();
        int z = block.getZ() & 0xF;
        // Setting the (x, y, z) location into VarInt format
        short location = (short) (x << 12 | y | z << 8);
        // If mask is null, then undo the mask. Otherwise set the mask
        if (mask == null) {
            changes[i] = packet.new MultiBlockChangeInfo(location, chunk);
        } else {
            changes[i] = packet.new MultiBlockChangeInfo(location, mask);
        }
    }
    ReflectionUtil.setField(multiBlockChangeB, packet, changes);
    return packet;
}
Also used : PacketPlayOutMultiBlockChange(net.minecraft.server.v1_9_R2.PacketPlayOutMultiBlockChange) Block(org.bukkit.block.Block) CraftChunk(org.bukkit.craftbukkit.v1_9_R2.CraftChunk)

Example 32 with Packet

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

the class FakeEntity_1_9_R2 method setPositionRotation.

@Override
public void setPositionRotation(short dx, short dy, short dz, byte yaw, byte pitch) {
    PacketPlayOutRelEntityMoveLook packet = new PacketPlayOutRelEntityMoveLook(cache, dx, dy, dz, yaw, pitch, false);
    PacketPlayOutEntityHeadRotation head = new PacketPlayOutEntityHeadRotation(entity, convertYaw(yaw));
    sendPackets(packet, head);
}
Also used : PacketPlayOutRelEntityMoveLook(net.minecraft.server.v1_9_R2.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook)

Example 33 with Packet

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

the class FakeEntity_1_9_R2 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_9_R2.PacketPlayOutEntity.PacketPlayOutEntityLook)

Example 34 with Packet

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

the class FakeEntity_1_9_R2 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_9_R2.PacketPlayOutEntity.PacketPlayOutEntityLook)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)10 Location (org.bukkit.Location)9 CraftPlayer (org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)5 Packet (com.yahoo.fs4.Packet)4 Player (org.bukkit.entity.Player)4 BasicPacket (com.yahoo.fs4.BasicPacket)3 ChannelTimeoutException (com.yahoo.fs4.ChannelTimeoutException)3 QueryPacket (com.yahoo.fs4.QueryPacket)3 Packet (ejip123.Packet)3 GetDocSumsPacket (com.yahoo.fs4.GetDocSumsPacket)2 PingPacket (com.yahoo.fs4.PingPacket)2 PongPacket (com.yahoo.fs4.PongPacket)2 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)2 InvalidChannelException (com.yahoo.fs4.mplex.InvalidChannelException)2 Result (com.yahoo.search.Result)2 IOException (java.io.IOException)2 Packet (net.minecraft.server.v1_10_R1.Packet)2 Packet (net.minecraft.server.v1_15_R1.Packet)2 Packet (net.minecraft.server.v1_8_R3.Packet)2 PacketPlayOutEntityLook (net.minecraft.server.v1_9_R2.PacketPlayOutEntity.PacketPlayOutEntityLook)2