package ru.dbotthepony.kstarbound.network.packets.clientbound

import ru.dbotthepony.kommons.io.readSignedVarLong
import ru.dbotthepony.kommons.io.writeSignedVarLong
import ru.dbotthepony.kstarbound.client.ClientConnection
import ru.dbotthepony.kstarbound.network.IClientPacket
import java.io.DataInputStream
import java.io.DataOutputStream
import kotlin.math.roundToLong

class UniverseTimeUpdatePacket(val time: Double) : IClientPacket {
	constructor(stream: DataInputStream, isLegacy: Boolean) : this(if (isLegacy) stream.readSignedVarLong() * 0.05 else stream.readDouble())

	override fun write(stream: DataOutputStream, isLegacy: Boolean) {
		if (isLegacy)
			stream.writeSignedVarLong((time / 0.05).roundToLong())
		else
			stream.writeDouble(time)
	}

	override fun play(connection: ClientConnection) {

	}
}
