Search in sources :

Example 1 with EntityTeleportMessage

use of net.glowstone.net.message.play.entity.EntityTeleportMessage in project Glowstone by GlowstoneMC.

the class GlowItemFrame method generateTeleportMessage.

void generateTeleportMessage(BlockFace face) {
    int xoffset = 0;
    int zoffset = 0;
    int yaw = 0;
    switch(getFacingNumber(face)) {
        case 1:
            xoffset = -32;
            yaw = 64;
            break;
        case 2:
            zoffset = -32;
            yaw = -128;
            break;
        case 3:
            xoffset = 32;
            yaw = -64;
            break;
        case 0:
            zoffset = 32;
            yaw = 0;
            break;
    }
    Location itemframelocation = location;
    Key key = new Key(itemframelocation.getBlockX() >> 4, itemframelocation.getBlockZ() >> 4);
    for (GlowPlayer player : getWorld().getRawPlayers()) {
        if (player.canSeeChunk(key)) {
            double x = location.getX();
            double y = location.getY();
            double z = location.getZ();
            player.getSession().send(new EntityTeleportMessage(id, x + xoffset, y, z + zoffset, yaw, 0));
        }
    }
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) EntityTeleportMessage(net.glowstone.net.message.play.entity.EntityTeleportMessage) Key(net.glowstone.chunk.GlowChunk.Key) Location(org.bukkit.Location)

Aggregations

Key (net.glowstone.chunk.GlowChunk.Key)1 GlowPlayer (net.glowstone.entity.GlowPlayer)1 EntityTeleportMessage (net.glowstone.net.message.play.entity.EntityTeleportMessage)1 Location (org.bukkit.Location)1