Search in sources :

Example 1 with MessagePlayOutPlayerPositionAndLook

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook in project LanternServer by LanternPowered.

the class LanternPlayer method setLocationAndRotation.

@Override
public boolean setLocationAndRotation(Location<World> location, Vector3d rotation, EnumSet<RelativePositions> relativePositions) {
    final World oldWorld = getWorld();
    final boolean success = super.setLocationAndRotation(location, rotation, relativePositions);
    if (success) {
        final World world = location.getExtent();
        // Only send this if the world isn't changed, otherwise will the position be resend anyway
        if (oldWorld == world) {
            final Vector3d pos = location.getPosition();
            final MessagePlayOutPlayerPositionAndLook message = new MessagePlayOutPlayerPositionAndLook(pos.getX(), pos.getY(), pos.getZ(), (float) rotation.getX(), (float) rotation.getY(), Sets.immutableEnumSet(relativePositions), 0);
            this.session.send(message);
        }
    }
    return success;
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) World(org.spongepowered.api.world.World) LanternWorld(org.lanternpowered.server.world.LanternWorld) MessagePlayOutPlayerPositionAndLook(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook)

Example 2 with MessagePlayOutPlayerPositionAndLook

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook in project LanternServer by LanternPowered.

the class LanternPlayer method setPositionAndWorld.

@Override
public boolean setPositionAndWorld(World world, Vector3d position) {
    final LanternWorld oldWorld = this.getWorld();
    final boolean success = super.setPositionAndWorld(world, position);
    if (success && world == oldWorld) {
        this.session.send(new MessagePlayOutPlayerPositionAndLook(position.getX(), position.getY(), position.getZ(), 0, 0, RELATIVE_ROTATION, 0));
    }
    return success;
}
Also used : LanternWorld(org.lanternpowered.server.world.LanternWorld) MessagePlayOutPlayerPositionAndLook(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook)

Example 3 with MessagePlayOutPlayerPositionAndLook

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook in project LanternServer by LanternPowered.

the class LanternPlayer method setLocationAndRotation.

@Override
public boolean setLocationAndRotation(Location<World> location, Vector3d rotation) {
    final World oldWorld = getWorld();
    final boolean success = super.setLocationAndRotation(location, rotation);
    if (success) {
        final World world = location.getExtent();
        // Only send this if the world isn't changed, otherwise will the position be resend anyway
        if (oldWorld == world) {
            final Vector3d pos = location.getPosition();
            final MessagePlayOutPlayerPositionAndLook message = new MessagePlayOutPlayerPositionAndLook(pos.getX(), pos.getY(), pos.getZ(), (float) rotation.getX(), (float) rotation.getY(), Collections.emptySet(), 0);
            this.session.send(message);
        }
    }
    return success;
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) World(org.spongepowered.api.world.World) LanternWorld(org.lanternpowered.server.world.LanternWorld) MessagePlayOutPlayerPositionAndLook(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook)

Example 4 with MessagePlayOutPlayerPositionAndLook

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook in project LanternServer by LanternPowered.

the class LanternPlayer method setRotation.

@Override
public void setRotation(Vector3d rotation) {
    super.setRotation(rotation);
    final LanternWorld world = getWorld();
    if (world != null) {
        this.session.send(new MessagePlayOutPlayerPositionAndLook(0, 0, 0, (float) rotation.getX(), (float) rotation.getY(), RELATIVE_POSITION, 0));
    }
}
Also used : LanternWorld(org.lanternpowered.server.world.LanternWorld) MessagePlayOutPlayerPositionAndLook(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook)

Example 5 with MessagePlayOutPlayerPositionAndLook

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook in project LanternServer by LanternPowered.

the class LanternPlayer method setPosition.

@Override
public void setPosition(Vector3d position) {
    super.setPosition(position);
    final LanternWorld world = getWorld();
    if (world != null) {
        this.session.send(new MessagePlayOutPlayerPositionAndLook(position.getX(), position.getY(), position.getZ(), 0, 0, RELATIVE_ROTATION, 0));
    }
}
Also used : LanternWorld(org.lanternpowered.server.world.LanternWorld) MessagePlayOutPlayerPositionAndLook(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook)

Aggregations

MessagePlayOutPlayerPositionAndLook (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook)5 LanternWorld (org.lanternpowered.server.world.LanternWorld)5 Vector3d (com.flowpowered.math.vector.Vector3d)2 World (org.spongepowered.api.world.World)2