Search in sources :

Example 1 with BlockPropertyData

use of com.nukkitx.protocol.bedrock.data.BlockPropertyData in project Protocol by CloudburstMC.

the class StartGameSerializer_v428 method deserialize.

@Override
public void deserialize(ByteBuf buffer, BedrockPacketHelper helper, StartGamePacket packet, BedrockSession session) {
    packet.setUniqueEntityId(VarInts.readLong(buffer));
    packet.setRuntimeEntityId(VarInts.readUnsignedLong(buffer));
    packet.setPlayerGameType(GameType.from(VarInts.readInt(buffer)));
    packet.setPlayerPosition(helper.readVector3f(buffer));
    packet.setRotation(helper.readVector2f(buffer));
    this.readLevelSettings(buffer, helper, packet);
    packet.setLevelId(helper.readString(buffer));
    packet.setLevelName(helper.readString(buffer));
    packet.setPremiumWorldTemplateId(helper.readString(buffer));
    packet.setTrial(buffer.readBoolean());
    // new for v428
    packet.setPlayerMovementSettings(readSyncedPlayerMovementSettings(buffer, helper));
    packet.setCurrentTick(buffer.readLongLE());
    packet.setEnchantmentSeed(VarInts.readInt(buffer));
    helper.readArray(buffer, packet.getBlockProperties(), (buf, packetHelper) -> {
        String name = packetHelper.readString(buf);
        NbtMap properties = packetHelper.readTag(buf);
        return new BlockPropertyData(name, properties);
    });
    helper.readArray(buffer, packet.getItemEntries(), session, (buf, packetHelper, aSession) -> {
        String identifier = packetHelper.readString(buf);
        short id = buf.readShortLE();
        boolean componentBased = buf.readBoolean();
        if (identifier.equals(packetHelper.getBlockingItemIdentifier())) {
            aSession.getHardcodedBlockingId().set(id);
        }
        return new StartGamePacket.ItemEntry(identifier, id, componentBased);
    });
    packet.setMultiplayerCorrelationId(helper.readString(buffer));
    packet.setInventoriesServerAuthoritative(buffer.readBoolean());
}
Also used : BlockPropertyData(com.nukkitx.protocol.bedrock.data.BlockPropertyData) NbtMap(com.nukkitx.nbt.NbtMap)

Aggregations

NbtMap (com.nukkitx.nbt.NbtMap)1 BlockPropertyData (com.nukkitx.protocol.bedrock.data.BlockPropertyData)1