blob: 13f05d0bce332ca5d12f4e1cbe889bd5032b6919 [file] [log] [blame] [raw]
package li.cil.oc.server.drivers
import li.cil.oc.Config
import li.cil.oc.api.IBlockDriver
import li.cil.oc.common.tileentity.TileEntityScreen
import li.cil.oc.common.components.Screen
import net.minecraft.world.World
object ScreenDriver extends IBlockDriver {
// ----------------------------------------------------------------------- //
// IDriver
// ----------------------------------------------------------------------- //
def componentName = "screen"
def id(component: Any) = component.asInstanceOf[Screen].id
def id(component: Any, id: Int) = component.asInstanceOf[Screen].id = id
// ----------------------------------------------------------------------- //
// IBlockDriver
// ----------------------------------------------------------------------- //
def worksWith(world: World, x: Int, y: Int, z: Int) =
world.getBlockId(x, y, z) == Config.blockScreenId
def component(world: World, x: Int, y: Int, z: Int) =
world.getBlockTileEntity(x, y, z) match {
case tileEntity: TileEntityScreen => tileEntity.component
case _ => null
}
}