blob: d933cb6081c9e0391b595ed5ead14aa490a4d60c [file] [log] [blame] [raw]
package li.cil.oc.common.tileentity
import cpw.mods.fml.common.network.Player
import li.cil.oc.api.{INetworkNode, INetworkMessage}
import net.minecraft.nbt.NBTTagCompound
class TileEntityKeyboard extends TileEntityRotatable with INetworkNode {
override def name = "keyboard"
override def receive(message: INetworkMessage) = {
super.receive(message)
message.data match {
case Array(p: Player, char: Char, code: Int) if message.name == "keyboard.keyDown" => {
// TODO check if player is close enough and only consume message if so
network.sendToAll(this, "signal", "key_down", char, code)
message.cancel() // One keyboard is enough.
None
}
case Array(p: Player, char: Char, code: Int) if message.name == "keyboard.keyUp" => {
// TODO check if player is close enough and only consume message if so
network.sendToAll(this, "signal", "key_up", char, code)
message.cancel() // One keyboard is enough.
None
}
case Array(p: Player, value: String) if message.name == "keyboard.clipboard" => {
// TODO check if player is close enough and only consume message if so
network.sendToAll(this, "signal", "clipboard", value)
message.cancel()
None
}
case _ => None
}
}
override def readFromNBT(nbt: NBTTagCompound) {
super.readFromNBT(nbt)
load(nbt)
}
override def writeToNBT(nbt: NBTTagCompound) {
super.writeToNBT(nbt)
save(nbt)
}
}