Java Code Examples for com.nukkitx.protocol.bedrock.packet.MovePlayerPacket#setMode()

The following examples show how to use com.nukkitx.protocol.bedrock.packet.MovePlayerPacket#setMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BedrockMovePlayerTranslator.java    From Geyser with MIT License 5 votes vote down vote up
public void recalculatePosition(GeyserSession session, Entity entity, Vector3f currentPosition) {
    // Gravity might need to be reset...
    SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
    entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
    entityDataPacket.getMetadata().putAll(entity.getMetadata());
    session.sendUpstreamPacket(entityDataPacket);

    MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
    movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
    movePlayerPacket.setPosition(entity.getPosition());
    movePlayerPacket.setRotation(entity.getBedrockRotation());
    movePlayerPacket.setMode(MovePlayerPacket.Mode.RESET);
    session.sendUpstreamPacket(movePlayerPacket);
}
 
Example 2
Source File: MovePlayerSerializer_v354.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, MovePlayerPacket packet) {
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readVector3f(buffer));
    packet.setMode(Mode.values()[buffer.readByte()]);
    packet.setOnGround(buffer.readBoolean());
    packet.setRidingRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    if (packet.getMode() == Mode.TELEPORT) {
        packet.setTeleportationCause(TeleportationCause.byId(buffer.readIntLE()));
        packet.setEntityType(buffer.readIntLE());
    }
}
 
Example 3
Source File: MovePlayerSerializer_v388.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, MovePlayerPacket packet) {
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readVector3f(buffer));
    packet.setMode(Mode.values()[buffer.readByte()]);
    packet.setOnGround(buffer.readBoolean());
    packet.setRidingRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    if (packet.getMode() == Mode.TELEPORT) {
        packet.setTeleportationCause(TeleportationCause.byId(buffer.readIntLE()));
        packet.setEntityType(buffer.readIntLE());
    }
}
 
Example 4
Source File: MovePlayerSerializer_v340.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, MovePlayerPacket packet) {
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readVector3f(buffer));
    packet.setMode(Mode.values()[buffer.readByte()]);
    packet.setOnGround(buffer.readBoolean());
    packet.setRidingRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    if (packet.getMode() == Mode.TELEPORT) {
        packet.setTeleportationCause(TeleportationCause.byId(buffer.readIntLE()));
        packet.setEntityType(buffer.readIntLE());
    }
}
 
Example 5
Source File: MovePlayerSerializer_v313.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, MovePlayerPacket packet) {
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readVector3f(buffer));
    packet.setMode(Mode.values()[buffer.readByte()]);
    packet.setOnGround(buffer.readBoolean());
    packet.setRidingRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    if (packet.getMode() == Mode.TELEPORT) {
        packet.setTeleportationCause(TeleportationCause.byId(buffer.readIntLE()));
        packet.setEntityType(buffer.readIntLE());
    }
}
 
Example 6
Source File: MovePlayerSerializer_v361.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, MovePlayerPacket packet) {
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readVector3f(buffer));
    packet.setMode(Mode.values()[buffer.readByte()]);
    packet.setOnGround(buffer.readBoolean());
    packet.setRidingRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    if (packet.getMode() == Mode.TELEPORT) {
        packet.setTeleportationCause(TeleportationCause.byId(buffer.readIntLE()));
        packet.setEntityType(buffer.readIntLE());
    }
}
 
Example 7
Source File: MovePlayerSerializer_v332.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, MovePlayerPacket packet) {
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readVector3f(buffer));
    packet.setMode(Mode.values()[buffer.readByte()]);
    packet.setOnGround(buffer.readBoolean());
    packet.setRidingRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    if (packet.getMode() == Mode.TELEPORT) {
        packet.setTeleportationCause(TeleportationCause.byId(buffer.readIntLE()));
        packet.setEntityType(buffer.readIntLE());
    }
}
 
Example 8
Source File: MovePlayerSerializer_v291.java    From Protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void deserialize(ByteBuf buffer, MovePlayerPacket packet) {
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPosition(BedrockUtils.readVector3f(buffer));
    packet.setRotation(BedrockUtils.readVector3f(buffer));
    packet.setMode(Mode.values()[buffer.readByte()]);
    packet.setOnGround(buffer.readBoolean());
    packet.setRidingRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    if (packet.getMode() == Mode.TELEPORT) {
        packet.setTeleportationCause(TeleportationCause.byId(buffer.readIntLE()));
        packet.setEntityType(buffer.readIntLE());
    }
}