Entitys and Protocollib

Discussion in 'Spigot Plugin Development' started by mindgamesnl, May 10, 2017.

  1. Hey all! im back again with a protocollib related question/problem/whatever

    What i want to do is send packets to the player that an entity has been teleported to cords

    Here is what i tried:
    Code (Java):

    public static void setLoc(float yaw, float pitch,Float x, Float y, Float z, ArmorStand as, Player player)
        PacketContainer pc = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
        pc.getIntegers().write(0, Integer.valueOf(as.getEntityId()));
                .write(0, Byte.valueOf((byte)getCompressedAngle(x)))
                .write(1, Byte.valueOf((byte)getCompressedAngle(y)))
                .write(2, Byte.valueOf((byte)getCompressedAngle(z)))
                .write(3, Byte.valueOf((byte)getCompressedAngle(yaw)))
                .write(4, Byte.valueOf((byte)getCompressedAngle(pitch)));
        pc.getBooleans().write(0, Boolean.valueOf(true));
            ProtocolLibrary.getProtocolManager().sendServerPacket(player, pc);
        catch (InvocationTargetException e)

    public static int getCompressedAngle(float value)
        return (int)(value * 256.0F / 360.0F);
    But this gives the following error
    Code (Text):

    com.comphenix.protocol.reflect.FieldAccessException: Field index out of bounds. (Index: 2, Size: 2)
    Some one who can tell me what im doing wrong (and how to correct it)

    Thanks :)
  2. full stacktrace? or that is all?