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

import ru.dbotthepony.kommons.io.readCollection
import ru.dbotthepony.kommons.io.readVector2i
import ru.dbotthepony.kommons.io.writeCollection
import ru.dbotthepony.kommons.io.writeStruct2i
import ru.dbotthepony.kommons.vector.Vector2i
import ru.dbotthepony.kstarbound.client.ClientConnection
import ru.dbotthepony.kstarbound.network.IClientPacket
import ru.dbotthepony.kstarbound.world.TileModification
import java.io.DataInputStream
import java.io.DataOutputStream

class TileModificationFailurePacket(val modifications: Collection<Pair<Vector2i, TileModification>>) : IClientPacket {
	constructor(stream: DataInputStream, isLegacy: Boolean) : this(stream.readCollection { stream.readVector2i() to TileModification.read(stream, isLegacy) })

	override fun write(stream: DataOutputStream, isLegacy: Boolean) {
		stream.writeCollection(modifications) { stream.writeStruct2i(it.first); it.second.write(stream, isLegacy) }
	}

	override fun play(connection: ClientConnection) {
		TODO("Not yet implemented")
	}
}
