blob: 17a2df45a69cca4d253b6b3bc0c73f4d0b6b0d53 [file] [log] [blame] [raw]
package li.cil.oc.common.block
import li.cil.oc.common.tileentity
import net.minecraft.world.{World, IBlockAccess}
import net.minecraftforge.common.ForgeDirection
abstract class Computer extends Delegate {
override def hasTileEntity = true
override def canConnectToRedstone(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) =
world.getBlockTileEntity(x, y, z) match {
case computer: tileentity.Computer => computer.isOutputEnabled
case _ => false
}
override def isProvidingStrongPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) =
isProvidingWeakPower(world, x, y, z, side)
override def isProvidingWeakPower(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) =
world.getBlockTileEntity(x, y, z) match {
case computer: tileentity.Computer => computer.output(side) max 0 min 15
case _ => super.isProvidingWeakPower(world, x, y, z, side)
}
override def neighborBlockChanged(world: World, x: Int, y: Int, z: Int, blockId: Int) =
world.getBlockTileEntity(x, y, z) match {
case computer: tileentity.Computer => computer.checkRedstoneInputChanged()
case _ => // Ignore.
}
}